跳转到主要内容
POST
/
gpt-5-2
/
v1
/
chat
/
completions
聊天完成
curl --request POST \
  --url https://api.kie.ai/gpt-5-2/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "这张图片里有什么?"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://file.aiquickdraw.com/custom-page/akr/section-images/1759055072437dqlsclj2.png"
          }
        }
      ]
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "web_search"
      }
    }
  ],
  "reasoning_effort": "high"
}
'
{
  "id": "chatcmpl-example-123",
  "object": "chat.completion",
  "created": 1741569952,
  "model": "gpt-5-2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好,有什么可以帮你的吗?",
        "refusal": null,
        "annotations": []
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 50,
    "total_tokens": 60
  }
}

多模态

支持文本和图像输入

实时搜索

启用联网搜索增强

推理力度

可调节推理力度级别

灵活角色

支持多种消息角色

统一媒体文件格式

messages 参数的 content 数组中,目前仅支持图像。所有图像文件使用相同的格式结构:
  • type 字段始终为 "image_url"
  • image_url 字段名称保持不变
  • 唯一变化的是 url 值,它指向相应的图像地址
例如:{ type: 'image_url', image_url: { url: '...' } } 结构。

Tools 参数

tools 参数是一个可选数组,允许您启用联网搜索增强。
使用此格式启用联网搜索增强:
{
  "type": "function",
  "function": {
    "name": "web_search"
  }
}
这将通过联网搜索启用实时信息检索。
{
  "id": "chatcmpl-example-123",
  "object": "chat.completion",
  "created": 1741569952,
  "model": "gpt-5-2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好,有什么可以帮你的吗?",
        "refusal": null,
        "annotations": []
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 50,
    "total_tokens": 60
  }
}

授权

Authorization
string
header
必填

所有 API 都需要通过 Bearer Token 进行身份验证。

获取 API Key:

  1. 访问 API Key 管理页面 获取您的 API Key

使用方法: 添加到请求头: Authorization: Bearer YOUR_API_KEY

注意:

  • 请妥善保管您的 API Key,不要与他人分享
  • 如果您怀疑 API Key 已泄露,请立即在管理页面重置

请求体

application/json
messages
object[]
必填

消息对象数组。每个消息都有一个角色和内容。

统一媒体文件格式:

在 content 数组中,目前仅支持图像。所有图像文件使用相同的格式结构:

  • type 字段始终为 "image_url"
  • image_url 字段名称保持不变
  • 唯一变化的是 url 值,它指向相应的图像地址

例如:{ type: 'image_url', image_url: { url: '...' } } 结构。

Minimum array length: 1
tools
object[]

可选,模型可以调用的工具数组。支持联网搜索:{"type": "function", "function": {"name": "web_search"}} - 通过联网搜索启用实时信息检索。

reasoning_effort
enum<string>
默认值:high

推理的力度。低力度响应更快,高力度响应更慢但解决更复杂的问题。默认为 "high"。

可用选项:
low,
high

响应

请求成功。返回标准的聊天完成格式。

id
string

聊天完成的唯一标识符

示例:

"chatcmpl-example-123"

object
string

对象类型

示例:

"chat.completion"

created
integer<int64>

完成创建时的 Unix 时间戳

示例:

1677652288

model
string

模型名称

示例:

"gpt-5-2"

choices
object[]

完成选项数组

usage
object