全部產品
Search
文件中心

API Gateway:管理Model API

更新時間:Sep 30, 2025

Model API適用於面向人工智慧應用開發的團隊,提供了更加靈活和智能的AI網關配置和調試能力。它可以用於各種AI代理、AI觀測、消費者鑒權、Alibaba Content Security Service防護等外掛程式的預置。本文主要介紹了如何建立、編輯、調試和刪除Model API。

建立Model API

  1. 開啟AI網關控制台執行個體頁面,在頂部功能表列選擇目標執行個體所在地區,並單擊目標執行個體ID

  2. 在左側導覽列,單擊Model API,然後單擊建立Model API

  3. 選擇使用情境,並單擊對應情境的建立按鈕。

    不同的情境會影響後續協議可選項與系統自動建立的預設路由,當前支援:

    • 文本產生(Text):支援 OpenAI 相容協議和 Anthropic 協議

    • 圖片產生(Image)

    • 視頻產生(Video)

    • 語音合成(Audio)

    • 向量化(Embedding)

    • 文本排序(Rerank)

    • 其他(Others)

  4. 配置基本資料。

    在彈窗中先完成選擇使用情境,進入建立Model API表單後,您可按以下說明進行配置:

    • 協議:不同協議對應該情境下的一組內建預設路由,用於快速產生常用的 OpenAI/DashScope/vLLM 等相容介面。

    • API名稱:您可自訂API名稱,需注意名稱必須全域唯一(同一帳號下不可重複),支援英文、數字、底線“_”、“-”,且不超過64個字元。

    • 網域名稱:訪問該 API 的網域名稱,支援選擇多個。網域名稱與基本路徑 BasePath 的組合必須唯一。

      如果還沒有網域名稱,請單擊右側添加網域名稱按鈕完成建立
    • Base Path:配置API的基本請求路徑,預設為 /。可選擇是否啟用轉寄至後端服務時移除

      說明

      開啟轉寄至後端服務時移除後,當請求轉寄到後端服務時,系統會自動移除請求路徑中的BasePath部分。例如:

      • BasePath設定為 /api

      • 原始請求路徑 /api/users

      • 實際轉寄到後端的路徑變為 /users

    • AI 請求觀測: 開啟後可查看 Metrics、Logging、Tracing 資訊。Logging 與 Tracing 依賴 SLS 日誌投遞服務。可勾選開啟記錄請求內容記錄響應內容,開啟後將記錄對大模型的請求或大模型返回的Context。

      重要

      啟用後系統會記錄所有 AI 請求內容(包括請求體 body)到訪問日誌,請妥善配置 SLS 並做好資料安全防護。

    • 大模型服務: 支援單模型服務多模型服務(按模型名稱)多模型服務(按權重)

      • 單模型服務:選擇 1 個 AI 服務,並可設定模型名稱(可透傳或改寫)。

      • 多模型服務(按模型名稱):根據請求體中的模型名按規則匹配到不同服務;匹配規則支援萬用字元 ?*,例如 qwen-* 可匹配 qwen-maxqwen-long

      • 多模型服務(按權重):選擇多個 AI 服務並設定權重,支援透傳或改寫模型名。

    • Fallback: 可開啟並按順序配置多條 Fallback 策略(可複用同一服務)。

    • 首包逾時:用於控制流程式響應中從請求發送到接收到第一個響應包之間的最大等待時間,適用於對響應延遲敏感的流式互動情境。(單位為毫秒,設為0時表示不啟用)。

    • 資源群組:支援選擇預設或已有資源群組,也可建立。資源群組用於對賬戶資源分組管理、授權與監控。

      如需建立新的資源群組,您可以單擊建立資源群組完成建立。
  5. 確認配置參數並單擊確定完成建立。

預設路由說明

下面為您介紹在不同使用情境下選擇不同協議時,系統自動建立的預設路由

文本產生(Text)

協議:OpenAI 相容(OpenAI/v1

路由名稱

路徑

方法

說明

create-chat-completion

/v1/chat/completions

POST

Creates a model response for the given chat conversation。

create-completion

/v1/completions

POST

Creates a completion for the provided prompt and parameters。

協議:Anthropic(Anthropic

Anthropic協議專為Claude等Anthropic系列模型設計,提供原生的訊息格式和互動方式。該協議適用於需要使用Anthropic原生API格式的應用情境。

說明

支援該協議的大模型供應商包括:阿里雲百鍊(Qwen)、Claude、月之暗面(Moonshot)、智譜 AI(ZhipuAI)等。以上供應商AI服務自動支援Anthropic協議,無需額外配置。

路由名稱

路徑

方法

說明

create-message

/v1/messages

POST

Creates a message for the given chat conversation using Anthropic's native message format。

圖片產生(Image)

協議:阿里雲百鍊圖片產生

路由名稱

路徑

方法

說明

dashscope-text-to-image-synthesis

/api/v1/services/aigc/text2image/image-synthesis

POST

Generate a text-to-image synthesis image。

dashscope-image-to-image-synthesis

/api/v1/services/aigc/image2image/image-synthesis

POST

Generate an image-to-image synthesis image。

dashscope-image-to-image-outpainting

/api/v1/services/aigc/image2image/out-painting

POST

Generate an image-to-image outpainting image。

dashscope-virtual-model-generation

/api/v1/services/aigc/virtualmodel/generation

POST

Generate a virtual model image。

dashscope-background-generation

/api/v1/services/aigc/background-generation/generation

POST

Generate a background generation image。

tasks

/api/v1/tasks

GET/POST/PUT/PATCH/DELETE

Manage asynchronous tasks。

協議:OpenAI 相容

路由名稱

路徑

方法

說明

openai-image-generation

/api/v1/images/generations

POST

Generate an image。

openai-image-edit

/api/v1/images/edits

POST

Edit an image。

openai-image-variation

/api/v1/images/variations

POST

Variation an image。

協議:ComfyUI

路由名稱

路徑

方法

說明

comfyui-websocket

/ws

GET

WebSocket endpoint for real-time communication with the server.

comfyui-embeddings

/embeddings

GET

Retrieve a list of the names of embeddings available.

comfyui-extensions

/extensions

GET

Retrieve a list of the extensions registering a WEB_DIRECTORY.

comfyui-features

/features

GET

Retrieve server features and capabilities.

comfyui-models

/models

GET

Retrieve a list of available model types.

comfyui-models-folder

/models/{folder}

GET

Retrieve models in a specific folder.

comfyui-workflow-templates

/workflow_templates

GET

Retrieve a map of custom node modules and associated template workflows.

comfyui-upload-image

/upload/image

POST

Upload an image.

comfyui-upload-mask

/upload/mask

POST

Upload a mask.

comfyui-view

/view

GET

View an image. Lots of options.

comfyui-view-metadata

/view_metadata/

GET

Retrieve metadata for a model.

comfyui-system-stats

/system_stats

GET

Retrieve information about the system (python version, devices, vram etc).

comfyui-prompt

/prompt

GET/POST

Retrieve current queue status and execution information or submit a prompt to the queue.

comfyui-object-info

/object_info

GET

Retrieve details of all node types.

comfyui-object-info-class

/object_info/{node_class}

GET

Retrieve details of one node type.

comfyui-history

/history

GET/POST

Retrieve the queue history.

comfyui-history-prompt-id

/history/{prompt_id}

GET

Retrieve the queue history for a specific prompt.

comfyui-queue

/queue

GET/POST

Retrieve the current state of the execution queue or manage queue operations.

comfyui-interrupt

/interrupt

POST

Stop the current workflow execution.

comfyui-free

/free

POST

Free memory by unloading specified models.

comfyui-userdata

/userdata

GET

List user data files in a specified directory.

comfyui-userdata-v2

/v2/userdata

GET

Enhanced version that lists files and directories in structured format.

comfyui-userdata-file

/userdata/{file}

GET/POST/DELETE

Retrieve, upload, update or delete a specific user data file.

comfyui-userdata-file-move

/userdata/{file}/move/{dest}

POST

Move or rename a user data file.

comfyui-users

/users

GET/POST

Get user information or create a new user.

視頻產生(Video)

協議:阿里雲百鍊視頻產生

路由名稱

路徑

方法

說明

dashscope-video-generation-synthesis

/api/v1/services/aigc/video-generation/video-synthesis

POST

Generate a video-generation synthesis video。

dashscope-image-to-video-synthesis

/api/v1/services/aigc/image2video/video-synthesis

POST

Generate an image-to-video synthesis video。

tasks

/api/v1/tasks

GET/POST/PUT/PATCH/DELETE

Manage asynchronous tasks。

語音合成(Audio)

協議:阿里雲百鍊語音合成

路由名稱

路徑

方法

說明

dashscope-text-to-audio-synthesis

/api-ws/v1/inference

GET

Generate a text-to-audio synthesis audio。

協議:OpenAI 相容(OpenAI/v1

路由名稱

路徑

方法

說明

openai-audio-speech

/api/v1/audio/speech

POST

Generate speech audio。

向量化(Embedding)

協議:OpenAI 相容(OpenAI/v1

路由名稱

路徑

方法

說明

create-embedding

/v1/embeddings

POST

Creates an embedding vector representing the input text。

文本排序(Rerank)

協議:阿里雲百鍊文本排序

路由名稱

路徑

方法

說明

rerank

/api/v1/services/rerank/text-rerank/text-rerank

POST

Rerank the given documents to be sorted based on query relevance。

協議:vLLM(vLLM

路由名稱

路徑

方法

說明

rerank

/v1/rerank

POST

Rerank the given documents to be sorted based on query relevance。

其他(Others)

協議:OpenAI 相容(OpenAI/v1

路由名稱

路徑

方法

說明

models

/v1/models

GET/POST/PUT/PATCH/DELETE

Manage models。

files

/v1/files

GET/POST/PUT/PATCH/DELETE

Manage files。

batches

/v1/batches

GET/POST/PUT/PATCH/DELETE

Manage batches。

fine-tuning

/v1/fine_tuning

GET/POST/PUT/PATCH/DELETE

Manage fine-tuning jobs。

說明

相容性說明:對於支援Anthropic協議的大模型供應商(阿里雲百鍊、Claude、月之暗面、智譜 AI等),建立AI服務時會自動支援多種協議,包括OpenAI相容協議和Anthropic協議,使用者可根據需要選擇合適的協議建立Model API。

編輯Model API

  1. 開啟AI網關控制台執行個體頁面,在頂部功能表列選擇目標執行個體所在地區,並單擊目標執行個體ID

  2. 在左側導覽列,單擊Model API,單擊目標API操作列的編輯。在編輯Model API面板中修改相關參數配置。關於配置參數說明,請參見建立Model API

  3. 確認配置資訊並單擊確定

調試Model API

說明

當前只支援文本產生的/v1/chat/completions調試。

  1. 開啟AI網關控制台執行個體頁面,在頂部功能表列選擇目標執行個體所在地區,並單擊目標執行個體ID

  2. 在左側導覽列,選擇Model API,單擊目標API操作列的調試

  3. 調試面板中,選擇網域名稱和模型,按需開啟流式請求開關、配置參數設定和自訂參數。在右側模型返回頁簽中,輸入調試內容並單擊發送進行調試。

    image

刪除Model API

  1. 開啟AI網關控制台執行個體頁面,在頂部功能表列選擇目標執行個體所在地區,並單擊目標執行個體ID

  2. 在左側導覽列,選擇Model API,單擊目標API操作列下的刪除,在確認刪除的彈框中輸入API名稱,然後單擊刪除