wenwen
  1. 聊天对话-OpenAI格式(/chat/completions)
wenwen
  • 聊天对话-OpenAI格式(/chat/completions)
    • 聊天
      POST
    • 流式返回
      POST
    • 结构化输出
      POST
    • 工具调用(function call)
      POST
    • 分析图片
      POST
    • 修改图片
      POST
    • 生成图片
      POST
    • 语音回复
      POST
  • 聊天对话-OpenAI格式(/responses)
    • Responses API与Chat API对比
    • 创建对话
      POST
    • 流式返回
      POST
    • 调用联网
      POST
  • 聊天对话-Anthropic格式(/messages)
    • 聊天
      POST
    • 流式返回
      POST
    • 分析图片
      POST
    • 工具使用
      POST
  • 绘图模型-OpenAI格式(/images)
    • 文生图(dall-e-3)
      POST
    • 文生图(gpt-image-1)
      POST
    • 图像编辑(dall-e-2)
      POST
    • 图像编辑(gpt-image-1)
      POST
  • 绘图模型-Midjourney(/mj)
    • 文生图(Imagine)
      POST
    • 图片融合(Blend)
      POST
    • 任务查询接口
      GET
    • 任务批量查询接口
      POST
    • 获取种子(Seed)
      GET
    • 按钮点击(Action)-选择图片
      POST
  • 向量化(/embeddings)
    • 文本向量化
  • 语音识别
    • 语音识别(whisper-1)
  1. 聊天对话-OpenAI格式(/chat/completions)

流式返回

POST
/v1/chat/completions
文本对话,结果流式返回。
所有对话模型,都可使用此接口, 修改 model 属性为模型名
模型列表请参考问问平台:https://api.wenwen-ai.com/pricing
BASE_URL: https://api.wenwen-ai.com/v1

请求参数

Header 参数

Body 参数application/json

示例
{
           "model": "gpt-3.5-turbo",
           "stream": true,
           "messages": [
              {
                 "role": "system",
                 "content": "You are a helpful assistant."
              },
              {
                 "role": "user",
                 "content": "Hello!"
              }
           ]
         }

请求示例代码

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-3.5-turbo",
           "stream": true,
           "messages": [
              {
                 "role": "system",
                 "content": "You are a helpful assistant."
              },
              {
                 "role": "user",
                 "content": "Hello!"
              }
           ]
         }'

返回响应

🟢200成功
application/json
Body

示例
data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "role": "assistant",
                "content": ""
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": "Hello"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": "!"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": " How"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": " can"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": " I"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": " assist"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": " you"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": " today"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {
                "content": "?"
            },
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {},
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "model": "gpt-3.5-turbo",
    "created": 1752460970,
    "choices": [
        {
            "index": 0,
            "delta": {},
            "finish_reason": "stop"
        }
    ]
}

data: {
    "id": "chatcmpl-89CCzsNNdHMTOQBSZWBQeTDCSQGBN",
    "object": "chat.completion.chunk",
    "created": 1752460971,
    "model": "gpt-3.5-turbo",
    "choices": [
        {
            "index": 0,
            "delta": {}
        }
    ],
    "usage": {
        "prompt_tokens": 9,
        "completion_tokens": 9,
        "total_tokens": 18,
        "prompt_tokens_details": {},
        "completion_tokens_details": {},
        "input_tokens": 0,
        "output_tokens": 0,
        "input_tokens_details": null
    }
}

data: [DONE
]
修改于 2025-08-05 08:12:37
上一页
聊天
下一页
结构化输出
Built with