Skip to Content
aicentos
API 介面聊天介面OpenAI

ChatCompletions 格式

最後更新於:

聊天(Chat)原生 OpenAI 格式

POST /chat/completions

驗證

將 API Key 存入環境變數 AICENTOS_API_KEY;shell 範例會將其值展開至 Authorization: Bearer 標頭。

在控制台「權杖管理」取得的 API 金鑰

位置:header

請求主體

application/json

TypeScript 型別定義

在 TypeScript 中使用 request body 型別

回應主體

application/json

application/json

application/json

application/json

export AICENTOS_API_KEY="sk-your-aicentos-api-key"

curl -X POST "https://aicentos.com/v1/chat/completions" \
  -H "Authorization: Bearer $AICENTOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{    "model": "gpt-4o-mini",    "messages": [      {        "role": "user",        "content": "用一句話介紹你自己"      }    ]  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "system",
        "content": "string",
        "name": "string"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
{
  "error": {
    "message": "Incorrect API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}