API 参考
thistoken.ai API 完整参考文档,与 OpenAI API 完全兼容
基础 URL
https://api.thistoken.ai认证
所有 API 请求都需要在 Header 中携带 API Key:
Authorization: Bearer YOUR_API_KEY接口列表
POST
/v1/chat/completions创建聊天补全
参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 模型名称,如 gpt-4o, claude-3.5-sonnet |
| messages | array | 是 | 消息数组,包含 role 和 content |
| temperature | number | 否 | 采样温度,0-2,默认 1 |
| max_tokens | integer | 否 | 最大生成 token 数 |
| stream | boolean | 否 | 是否流式输出,默认 false |
示例请求
curl https://api.thistoken.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'POST
/v1/embeddings创建文本嵌入向量
参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 嵌入模型名称,如 text-embedding-3-small |
| input | string|array | 是 | 要嵌入的文本 |
示例请求
curl https://api.thistoken.ai/v1/embeddings \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "Hello world"
}'GET
/v1/models获取可用模型列表
示例请求
curl https://api.thistoken.ai/v1/models \
-H "Authorization: Bearer $API_KEY"POST
/v1/images/generations生成图像
参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 图像模型,如 dall-e-3 |
| prompt | string | 是 | 图像描述 |
| size | string | 否 | 图像尺寸,如 1024x1024 |
示例请求
curl https://api.thistoken.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "dall-e-3",
"prompt": "A cute cat",
"size": "1024x1024"
}'错误码
| 错误码 | 说明 |
|---|---|
| 400 | 请求参数错误 |
| 401 | 认证失败,API Key 无效 |
| 402 | 余额不足 |
| 429 | 请求过于频繁,触发限流 |
| 500 | 服务器内部错误 |