跳转到主要内容
POST
/
v1
/
messages
cURL
curl --request POST \
  --url https://api.ttapi.io/v1/messages \
  --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>",
  "max_tokens": 123,
  "...": "<unknown>"
}
'
{
  "id": "msg_018zZJf8ZJf8ZJf8ZJf8ZJf8ZJf8",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": " Hello! My name is Claude."
    }
  ],
  "model": "claude-2.0",
  "stop_reason": "stop_sequence",
  "usage": {
    "input_tokens": 15,
    "output_tokens": 22
  }
}

授权

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支持模型

max_tokens
number
必填

max_tokens
请注意,我们的模型可能会在达到此最大值之前停止。此参数仅指定要生成的绝对最大标记数。

...
...

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

响应

成功响应

id
string
必填

消息唯一标识

示例:

"msg_018zZJf8ZJf8ZJf8ZJf8ZJf8ZJf8"

type
string
必填

响应类型

示例:

"message"

role
string
必填

角色标识

示例:

"assistant"

content
object[]
必填

消息内容列表

model
string
必填

使用的模型版本

示例:

"claude-2.0"

usage
object
必填

token 使用统计

stop_reason
string | null

停止原因

示例:

"stop_sequence"

Last modified on March 12, 2026