wenwen
  1. 对话(openai, gemini, claude, deepseek...)
wenwen
  • (必读)使用说明
  • Base URL地址
  • 列出模型
    • Models(列出模型)
      GET
  • OpenAI 格式(支持各大原厂模型)
    • OpenAI SDK使用指南
    • Responses API 接口使用指南
    • 对话(openai, gemini, claude, deepseek...)
      • 聊天(chat)
        POST
      • 流式返回(chat)
        POST
      • 思考模式(chat)
        POST
      • 结构化输出(chat)
        POST
      • 工具调用(chat)
        POST
      • MCP调用(chat)
        POST
      • web search(chat)
        POST
      • 聊天(responses)
        POST
      • 流式返回(responses)
        POST
      • 思考模式(responses)
        POST
      • web search(responses)
        POST
    • 图像(gpt, dalle, banana, jimeng)
      • 生成图片(chat)
      • 分析图片(chat)
      • 修改图片(chat)
      • 生成图片(images)
      • 修改图片(images)
    • 视频(sora, veo, 可灵)
      • VEO, SORA 接口参数信息汇总
      • 文生视频-同步 (sora, veo)
      • 图生视频-同步 (sora, veo)
      • 首尾帧视频-同步 (veo)
      • 文生视频-异步 (sora, veo)
      • 图生视频-异步 (sora, veo)
      • 查询视频状态 (sora, veo)
      • 获取视频内容 (sora, veo)
      • 文生视频-异步 (可灵)
      • 图生视频-异步 (可灵)
    • 语音
      • 语音回复(chat)
      • 语音识别(audio)
      • 语音合成(audio)
    • 向量化
      • 文本向量化
  • Anthropic 格式
    • Anthropic SDK使用指南
    • 聊天
      POST
    • 聊天(prompt cache)
      POST
    • 流式返回
      POST
    • 聊天(深度思考)
      POST
    • 工具调用(function call)
      POST
    • 工具调用(MCP)-目前不支持
      POST
    • 分析图片
      POST
  • Gemini 格式
    • Gemini SDK使用指南
    • 聊天
    • 生成图片(nano banana)
    • 编辑图片(nano banana)
  • Midjourney 格式
    • 任务查询接口
    • 获取种子(Seed)
    • 文生图(Imagine)
    • 图片融合(Blend)
    • 图生文(Describe)
    • 换脸(FaceSwap)
    • 上传(upload)
    • 任务批量查询接口
    • 按钮点击(Action)
    • 窗口执行(Modal)
    • 刷新链接(Refresh)
    • 编辑图片(Edit)
  • 数据模型
    • 示例数据模型
      • Pet
      • Category
      • Tag
  1. 对话(openai, gemini, claude, deepseek...)

结构化输出(chat)

POST
/v1/chat/completions
输出json格式结构数据
所有对话模型,都可使用此接口, 修改 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.wenwen-ai.com/v1/chat/completions' \
--header 'Authorization: Bearer {YOUR_API_KEY}' \
--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
              }
           }
         }'

返回响应

🟢200成功
application/json
Body

示例
{
    "id": "chatcmpl-Bg48iwIDEzYI4TrkuI8W7zvE0iPsn",
    "model": "gpt-4o-2024-08-06",
    "object": "chat.completion",
    "created": 1749365388,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "{\"final_answer\":\"9.8\",\"steps\":[{\"explanation\":\"比较两个数时,可以首先比较整数部分,然后比较小数部分。这里,我们首先看整数部分。\",\"output\":\"9.11和9.8的整数部分分别是9和9。\"},{\"explanation\":\"由于整数部分相同,我们需要比较小数部分。我们来看小数部分的第一位数字,也就是十分位。\",\"output\":\"9.11的十分位是1,9.8的十分位是8。\"},{\"explanation\":\"因为8比1大,所以9.8的小数部分大于9.11的小数部分。\",\"output\":\"因此,9.8比9.11大。\"}]}"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 97,
        "completion_tokens": 148,
        "total_tokens": 245,
        "prompt_tokens_details": {
            "cached_tokens": 0,
            "text_tokens": 0,
            "audio_tokens": 0,
            "image_tokens": 0
        },
        "completion_tokens_details": {
            "text_tokens": 0,
            "audio_tokens": 0,
            "reasoning_tokens": 0
        },
        "input_tokens": 0,
        "output_tokens": 0,
        "input_tokens_details": null
    }
}
修改于 2025-10-25 15:01:13
上一页
思考模式(chat)
下一页
工具调用(chat)
Built with