跳转到主要内容
POST
/
v1
/
chat
/
completions
cURL
curl --request POST \
  --url https://api.ttapi.io/v1/chat/completions \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "model": "<string>",
  "stream": "false"
}
'
{
  "id": "chatcmpl-9ugiTupGJUmeRNqyqUvYO34GOUzyv",
  "object": "chat.completion",
  "created": 1723297597,
  "model": "gpt-3.5-turbo-0125",
  "choices": [
    {
      "index": 0,
      "message": {
        "content": "你好!有什么可以帮助你的吗?",
        "role": "assistant",
        "refusal": null
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 11,
    "completion_tokens": 17,
    "total_tokens": 28
  }
}
TTAPI中转 Grok Chat Completions 接口,请求 header 使用 TTAPI 平台密钥,其余所有请求参数及响应参数与官方一致, 具体参考Grok官方文档

授权

Authorization
string
header
必填

请前往 TTAPI 控制台 获取 API 密钥。

请求体

application/json
messages
object[]
必填
示例:
[{ "role": "user", "content": "Hello!" }]
model
string
必填

使用模型,详见支持模型

stream
boolean
默认值:false

是否使用服务器发送的事件逐步传输响应

响应

成功响应

id
string
示例:

"chatcmpl-9ugiTupGJUmeRNqyqUvYO34GOUzyv"

object
string
示例:

"chat.completion"

created
integer
示例:

1723297597

model
string
示例:

"gpt-3.5-turbo-0125"

choices
object[]
usage
object
Last modified on March 16, 2026