聊天(Chat)原生 OpenAI 格式
ChatCompletions 格式
鉴权
bearerAuth 鉴权Bearer <token>
在控制台「令牌管理」获取的 API Key
位置: header
请求体
application/json
TypeScript 类型定义
在 TypeScript 中使用 request body 类型
响应体
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/chat/completions" \ -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"
}
}