跳转到主要内容
POST
/
v1
/
chat
/
completions
cURL
curl --request POST \
  --url https://api.ttapi.io/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --header 'TT-API-KEY: <api-key>' \
  --data '
{
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "model": "<string>",
  "...": "<unknown>"
}
'
{
  "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
  }
}

授权

TT-API-KEY
string
header
必填

授权字段,控制台获取授权信息

请求体

application/json
messages
json
必填

聊天message数组

示例:
[
  {
    "role": "system",
    "content": "You are a helpful assistant."
  },
  { "role": "user", "content": "Hello!" }
]
model
string
必填

ttapi支持使用的模型,详见GPT支持模型

...
...

其他具体详见官方文档,所有参数同步官方文档

响应

成功响应

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 12, 2026