跳转到主要内容
POST
/
gemini
/
chat
/
completions
cURL
curl --request POST \
  --url https://api.ttapi.io/gemini/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>"
}
'
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "你好!很高兴和你聊天。\n\n有什么可以帮你的吗?或者想聊点什么? 😊",
        "role": "assistant"
      }
    }
  ],
  "created": 1757472417,
  "id": "oebAaMTvMfCUjMcP_prYwAs",
  "model": "gemini-2.5-pro",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 21,
    "prompt_tokens": 3,
    "total_tokens": 1466
  }
}

授权

TT-API-KEY
string
header
必填

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

请求体

application/json
messages
json
必填

消息

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

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

...
...

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

响应

成功响应(stream=false 返回JSON,stream=true 返回Gemini流式)

choices
object[]
必填

响应结果列表

created
integer
必填

响应创建时间戳(秒)

示例:

1757472417

id
string
必填

请求唯一标识

示例:

"oebAaMTvMfCUjMcP_prYwAs"

model
string
必填

使用的 Gemini 模型版本

示例:

"gemini-2.5-pro"

object
string
必填

响应对象类型

示例:

"chat.completion"

usage
object
必填

token 使用统计

Last modified on March 12, 2026