Skip to content
目录

Curl 调用

请求

复制并运行以下代码,将$API_KEY替换成你的 key。

语言模型

plain
curl --location 'https://ai-maas.wair.ac.cn/maas/v1/chat/completions' \
--header 'Authorization: Bearer $API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "model": "taichu_llm",
  "messages": [
      {
          "role": "user",
          "content": "你好"
      }
  ],
  "stream": false
}'

图文模型

plain
curl --location 'https://ai-maas.wair.ac.cn/maas/v1/chat/completions' \
--header 'Authorization: Bearer $API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "stream": true,
    "model": "taichu2_mm",
    "messages": [
        {
            "content": [
                {
                    "type": "text",
                    "text": "图片中的人口总量是多少?男性多还是女性多?"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://zdtc-cdn.wair.ac.cn/assets/caption_2_file_1.jpeg"
                    }
                }
            ],
            "role": "user"
        }
    ]
}'

非流式响应

plain
{
  "id": "cmpl-91113f8d8e294790ba6394d47dc5f5ce",
  "object": "chat.completion",
  "created": 1713521143,
  "model": "taichu_llm",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!有什么问题或者需要帮助的地方吗?我在这里随时准备回答您的问题。"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 11,
    "total_tokens": 30,
    "completion_tokens": 19
  }
}

流式响应

plain
data: {"id":"cmpl-2b26345bafae4059ba3f5d644f05a70f","object":"chat.completion.chunk","created":1713521047,"model":"taichu_llm","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":""}],"usage":{"prompt_tokens":0,"total_tokens":0,"completion_tokens":0}}

data: {"id":"cmpl-2b26345bafae4059ba3f5d644f05a70f","object":"chat.completion.chunk","created":1713521047,"model":"taichu_llm","choices":[{"index":0,"delta":{"role":"","content":"你好"},"finish_reason":""}],"usage":{"prompt_tokens":0,"total_tokens":0,"completion_tokens":0}}

...

data: {"id":"cmpl-2b26345bafae4059ba3f5d644f05a70f","object":"chat.completion.chunk","created":1713521047,"model":"taichu_llm","choices":[{"index":0,"delta":{"role":"","content":"。"},"finish_reason":""}],"usage":{"prompt_tokens":0,"total_tokens":0,"completion_tokens":0}}

data: {"id":"cmpl-2b26345bafae4059ba3f5d644f05a70f","object":"chat.completion.chunk","created":1713521047,"model":"taichu_llm","choices":[{"index":0,"delta":{"role":"","content":""},"finish_reason":"stop"}],"usage":{"prompt_tokens":11,"total_tokens":30,"completion_tokens":19}}

data: [DONE]