Create and manage inference services

Updated at:

An inference service is a model inference instance in your workspace. Create one from a ModelGallery preset or a custom model, then manage and call it from the console.

Create an inference service from a custom model

Custom models let you use private models already uploaded to OSS, NAS, or Intelligent Computing CPFS. Configure the inference image and startup command manually.

  1. Log in to PAI console. In the left navigation pane, select Model Deployment > InferX, then select a workspace on the right to enter InferX.

  2. In the InferX left navigation pane, click Service, and go to the Inference Service tab.

  3. Click Create Service, and configure the basic information:

  4. Parameter

    Description

    Service Name

    Supports lowercase letters, digits, and underscores. Must start with a lowercase letter. Names must be unique within a region.

    Model Type

    Select Custom Model.

    Cache Service

    (Optional) Select a KV Cache service you've already created.

    Note

    Inference services bound to the same KV Cache service share a single KV cache, reducing time to first token (TTFT) and improving throughput. Well-suited for multi-turn dialogue, RAG, and other workloads with high prefix reuse. Create a KV Cache service before enabling this option. For details, see Create and manage a KV cache service.

    Enable PD Separation

    When enabled, the Prefill (pre-fill) and Decode stages run on separate nodes. Configure the image, command, and resource spec for each node type independently. Recommended for high-throughput workloads that benefit from per-stage resource tuning.

  5. Configure the service and resources. If PD disaggregation is enabled, configure the Prefill and Decode nodes separately on their respective tabs.

    Configure the following parameters:

    Parameter

    Description

    Image Configuration

    Select Alibaba Cloud Image(built-in inference frameworks, recommended), Custom Image, or enter the Runtime Image Address directly.

    Storage Mount

    Mount the storage containing your model files. Supports OSS, general-purpose NAS, high-performance NAS, and Intelligent Computing CPFS.

    Run Command

    The shell command to start the inference service, for example, python3 -m sglang.launch_server --port 8000 --model-path /mnt/model. When PD disaggregation is enabled, specify separate startup commands for Prefill and Decode nodes.

    Port Number

    The port the inference service listens on. Default is 8000. Must match the port specified in the startup command.

    Environment Variables

    (Optional) Add runtime environment variables. Maximum 100 variables.

    Select Resource Type, and configure the parameters for the selected type. Available resource types vary by deployment template — check the options shown on the page.

    Resource Type

    Parameter description

    Public Resources

    • Replicas: Default is 1. Adjust based on your needs.

    • Deployment Resources: Select an instance type from the spec list. Multiple instance specs can be configured; the system tries them in order. Enable spot mode to reduce costs.

    EAS Resource Group

    • EAS Resource Group: Select a purchased EAS dedicated resource group. The page shows current GPU/CPU/memory usage and total capacity.

    • Resource Configuration: Enter replicas × GPU (cards) × CPU (cores) × memory (GB) × system disk (GB).

      Note

      Check that the resource group has enough remaining capacity.

    Resource Quota

    • Resource Quota: Select a purchased quota.

    • Priority: Range 1–9. Higher values indicate higher priority.

    • Resource Configuration: Enter replicas × GPU (cards) × CPU (cores) × memory (GB) × system disk (GB).

  6. Review the cost estimate at the bottom, then click Deployment.

Manage inference services

Common operations

Actions

Description

Update

In the Actions column, click Update to modify the service configuration (resource specs, image, startup command). The service restarts automatically when the update takes effect.

Stop

In the Actions column, click Stop. A stopped service no longer accepts requests and isn't billed while stopped. Restart it when needed.

Scaling

In the Actions column, click Scaling and change the replica count in the dialog. The system scales according to the current resource configuration. New instances enter the Creating state and start receiving traffic once ready.

Restart

In the Actions column, click Restart. The service reinitializes to clear abnormal runtime states. The service is briefly unavailable during the restart.

Delete

In the Actions column, click Delete. The service and all its instances are permanently removed. This action can't be undone.

Operation Protection

In the Actions column, click Operation Protection to set the change protection level for the service.

  • None: The service is in normal state. All operations are allowed.

  • All Operation Protection: All change operations are blocked to prevent accidental modifications from affecting production.

  • Dangerous Operation Protection: Stop and delete operations are blocked to prevent accidental removal of production services.

Call inference services

InferX provides two types of endpoints. Choose the one that matches your use case:

Endpoint

When to use

How to get it

Workspace unified endpoint

Traffic is distributed across services by smart routing based on policy. Use for multi-service load balancing and affinity routing.

On the overview page, click Call Information to view the base URL and API key.

Inference service direct endpoint

Connects directly to a specific inference service, bypassing smart routing. Use when targeting a specific model service or for debugging.

In the inference service list, click Invoke on the target service to get its Base URL and token.

InferX exposes an OpenAI-compatible API. Append the path (such as /v1/chat/completions) to the Base URL and include Authorization: Bearer <API_KEY> in the request header for authentication.

Call with curl

curl -X POST "<BASE_URL>/v1/chat/completions" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<your-model>",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ],
    "stream": false
  }'

Call with the Python OpenAI SDK

from openai import OpenAI

client = OpenAI(
    api_key="<API_KEY>",
    base_url="<BASE_URL>/v1",
)

response = client.chat.completions.create(
    model="<your-model>",
    messages=[
        {"role": "user", "content": "Hello!"}
    ],
)

print(response.choices[0].message.content)