ChatGPT API 中文文档
  1. 💬 聊天接口(支持多种格式)
ChatGPT API 中文文档
  • 导言
  • 发出请求
  • 模型(Models)
    • 模型对象
    • 列出模型
      GET
  • 💬 聊天接口(支持多种格式)
    • API聊天完成响应对象
    • 聊天接口
      POST
    • OpenAI 格式(Chat Completions)
      POST
    • Chat(多模态图片识别)
      POST
    • Chat(流式回复)
      POST
    • Chat(视频识别分析)
      POST
    • Chat(结构化输出)
      POST
    • OpenAI 格式(Responses)
      POST
    • OpenAI Deep-research
      POST
    • Anthropic 对话格式(Messages)
      POST
    • Anthropic 图片识别(Messages)
      POST
    • Anthropic 工具调用(Messages)
      POST
    • Anthropic 流式回复(Messages)
      POST
    • Deepseek reasoning 对话格式(Reasoning Content)
      POST
  • 自动补全接口(Completions)
    • API完成响应对象
    • 内容补全接口
      POST
  • 图像接口(Images)
    • DALL·E 3
      POST
    • Stable-Diffusion
      POST
  • 向量生成接口(Embeddings)
    • 嵌入对象
    • 创建嵌入
      POST
  • 音频接口(Audio)
    • 创建转录
    • 创建翻译
    • TTS文本转语音
  • Midjourney
    • 提交Imagine任务(文生图、文图生图)
    • 上传图片至discord
    • 绘图变化(UPSCALE; VARIATION; REROLL)
    • 执行动作(所有的关联按钮动作UPSCALE; VARIATION; REROLL; ZOOM等)
    • 提交Blend任务(图生图)
    • 提交Describe任务(图生文)
    • 提交Modal(提交局部重绘、ZOOM)
    • 提交Shorten任务(prompt分析)
    • 提交swap_face任务
    • 根据ID获取图片
    • 根据ID列表查询任务
    • 指定ID获取任务
    • 获取任务图片的seed
  • 帮助中心
    • 常见问题及解决办法
  1. 💬 聊天接口(支持多种格式)

Chat(结构化输出)

POST
/v1/chat/completions
所有对话模型,都可使用此接口, 修改 model 属性为模型名
给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。
为提供的提示和参数创建完成

请求参数

Header 参数

Body 参数application/json

示例
{
  "model": "gpt-4o-2024-08-06",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful math tutor. Guide the user through the solution step by step."
    },
    {
      "role": "user",
      "content": "9.11和9.8谁大"
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "math_reasoning",
      "schema": {
        "type": "object",
        "properties": {
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "explanation": {
                  "type": "string"
                },
                "output": {
                  "type": "string"
                }
              },
              "required": [
                "explanation",
                "output"
              ],
              "additionalProperties": false
            }
          },
          "final_answer": {
            "type": "string"
          }
        },
        "required": [
          "steps",
          "final_answer"
        ],
        "additionalProperties": false
      },
      "strict": true
    }
  }
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.pro365.top/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "gpt-4o-2024-08-06",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful math tutor. Guide the user through the solution step by step."
    },
    {
      "role": "user",
      "content": "9.11和9.8谁大"
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "math_reasoning",
      "schema": {
        "type": "object",
        "properties": {
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "explanation": {
                  "type": "string"
                },
                "output": {
                  "type": "string"
                }
              },
              "required": [
                "explanation",
                "output"
              ],
              "additionalProperties": false
            }
          },
          "final_answer": {
            "type": "string"
          }
        },
        "required": [
          "steps",
          "final_answer"
        ],
        "additionalProperties": false
      },
      "strict": true
    }
  }
}'

返回响应

🟢200OK
application/json
Body

示例
{
    "id": "chatcmpl-CRvyy29POfyOEE4ptJNWr9XnmNlvH",
    "object": "chat.completion",
    "created": 1760773776,
    "model": "gpt-4o-2024-08-06",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "{\"final_answer\":\"9.8\",\"steps\":[{\"explanation\":\"首先,我们比较两个数的整数部分。两个数的整数部分是相同的,都是9。\",\"output\":\"整数部分比较:9.11的整数部分是9,9.8的整数部分是9,二者相同,比较小数部分。\"},{\"explanation\":\"当整数部分相同时,我们比较小数部分的大小。小数部分其实就是去掉整数部分后的小数。\",\"output\":\"9.11的小数部分是0.11,9.8的小数部分是0.8。\"},{\"explanation\":\"为了更容易比较,我们把9.8的假设为分数形式,0.8实际上是0.80。\",\"output\":\"比较小数部分:0.11与0.80 (因为0.8可以写成0.80,不改变数值)。\"},{\"explanation\":\"比较0.11和0.80。我们发现0.80大于0.11。\",\"output\":\"0.80 > 0.11\"},{\"explanation\":\"所以比较得出9.8大于9.11。\",\"output\":\"结论:9.8大于9.11。\"}]}",
                "refusal": null,
                "annotations": []
            },
            "logprobs": null,
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 97,
        "completion_tokens": 257,
        "total_tokens": 354,
        "prompt_tokens_details": {
            "cached_tokens": 0,
            "audio_tokens": 0
        },
        "completion_tokens_details": {
            "reasoning_tokens": 0,
            "audio_tokens": 0,
            "accepted_prediction_tokens": 0,
            "rejected_prediction_tokens": 0
        }
    },
    "system_fingerprint": "fp_4a331a0222"
}
修改于 2025-10-18 07:51:23
上一页
Chat(视频识别分析)
下一页
OpenAI 格式(Responses)
Built with