All Products
Search
Document Center

API Gateway:Access PAI-deployed models through AI Gateway

Last Updated:Aug 19, 2026

Access a model deployed on Platform for AI (PAI) through AI Gateway.

Prerequisites

Important

When using a private endpoint, the AI gateway instance and PAI-deployed model must be in the same VPC.

Procedure

Step 1: Create an AI service

  1. Log on to the AI Gateway console.

  2. In the navigation pane on the left, choose Instance. In the top menu bar, select a region.

  3. On the Instance page, click the target instance ID.

  4. In the navigation pane on the left, choose Service, then click the Services tab.

  5. Click Create Service. In the Create Service panel, configure the following parameters:

    Parameter

    Description

    Service Source

    Select AI service.

    Service Name

    Enter a service name, such as pai.

    Large Model Supplier

    Select the model provider. In this example, select PAI-EAS. If you haven't deployed a model with PAI-EAS, complete Deploy a model with one click first.

    Workspace

    The PAI workspace, such as pai_xqrj0u0t******.

    EAS Service

    Select the PAI-deployed model, such as Qwen3-32B.

    ConnectionType

    Select the network type (public or private). This example uses private network.

    API key

    Automatically retrieved by the AI gateway for the PAI-deployed model.

    Note

    This key authenticates communication between the AI gateway and PAI-EAS.

    HealthyCheck

    Enable or disable health checks for the service.

Step 2: Create a Model API

  1. Log on to the AI Gateway console.

  2. In the navigation pane on the left, choose Instance. In the top menu bar, select a region.

  3. On the Instance page, click the target instance ID.

  4. In the navigation pane on the left, choose Model API, then click Create Model API.

  5. In the Create Model API panel, configure the following:

  6. Click OK to create the Model API.

Step 3: Debug the Model API

  1. In the Actions column of the target Model API, click Debug.

  2. In the Debug panel, under Select Model, select your PAI-deployed model and interact with it on the Model Returned tab.

    Important

    On the Model Response tab, the /v1/chat/completions API is used by default. To use other APIs, select cURL command or Raw Output to debug with curl or an SDK.

  3. [Example] Call the completions endpoint with a cURL command:

    1. On the cURL command tab, copy the code sample provided by the AI gateway.

    2. Replace the url in the code sample with /v1/completions.

    3. Modify the data(body) section to match the /v1/completions format:

    curl --location 'http://env-cxxx-cn-wulanchabu.alicloudapi.com/v1/completions' \
      --header 'Content-Type: application/json' \
      --data '{"model": "DeepSeek-R1-Distill-Qwen-1.5B","prompt": "can you help me with"}'
    {"id":"cmpl-d057e88b-ebb0-456f-89d6-79d431ed0ed9","object":"text_completion","created":1739929451,"model":"DeepSeek-R1-Distill-Qwen-1.5B","choices":[{"index":0,"text":" this math problem?\n\nI think about the idea of moving the focus point of the","logprobs":null,"finish_reason":"length","stop_reason":null,"prompt_logprobs":null}],"usage":{"prompt_tokens":6,"total_tokens":22,"completion_tokens":16,"prompt_tokens_details":null}}