DuckLLM
  1. 聊天接口(Chat)
DuckLLM
  • 发出请求
  • 模型接口
    • 完成对象
    • 模型(Models)
      • 列出模型
    • 聊天接口(Chat)
      • 聊天接口(通用)
        POST
      • 官方Function calling调用
        POST
      • 官方N测试
        POST
      • 官方最新response_format
        POST
      • gpt-4o(分析图片)
        POST
    • Anthropic Claude
      • 聊天接口
      • 识图接口
    • 谷歌Gemini
      • 聊天接口
      • 识图接口
    • GPTs 相关
      • GPTs对话
      • 搜索相关 GPTs
      • 批量查询 GPTs 详情
      • gpt-4-all(分析图片)
      • gpt-4-all(生成图片)
    • 文生音乐 Suno
      • 文生音乐(Chat格式)
    • 文生视频
      • 智谱清言GLM
      • 文生视频(luma)
      • 文生视频(runway)
    • Rerank API
      • Rerank API
    • 自动补全接口(Completions)
      • 内容补全接口
    • 文生图接口
      • DALL·E 3
      • ideogram
      • Stable-Diffusion
    • 向量生成接口(Embeddings)
      • 创建嵌入
    • 音频接口(Audio)
      • 创建转录
      • 创建翻译
      • TTS文本转语音
  • 帮助中心
    • 隐私条款
    • 服务条款
    • 关于我们
    • 常见问题及解决办法
    • 已弃用
      • 查询 GPTs 详情
      • 生成歌曲(API格式)
      • 生成歌词(API格式)
      • 查询单个任务(API格式)
      • Flux(OpenAI dall-e-3格式)
  1. 聊天接口(Chat)

官方最新response_format

正式环境
https://api.duckllm.com/v1
正式环境
https://api.duckllm.com/v1
POST
/chat/completions
官方结构化输出

请求参数

Header 参数

Body 参数application/json

示例
{
  "model": "gpt-4o-mini-2024-07-18",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful math tutor."
    },
    {
      "role": "user",
      "content": "solve 8x + 31 = 2"
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "math_response",
      "strict": true,
      "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
      }
    }
  }
}

请求示例代码

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.duckllm.com/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "gpt-4o-mini-2024-07-18",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful math tutor."
    },
    {
      "role": "user",
      "content": "solve 8x + 31 = 2"
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "math_response",
      "strict": true,
      "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
      }
    }
  }
}'

返回响应

🟢200OK
application/json
Body

示例
{
    "id": "chatcmpl-123",
    "object": "chat.completion",
    "created": 1677652288,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\n\nHello there, how may I assist you today?"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 9,
        "completion_tokens": 12,
        "total_tokens": 21
    }
}
修改于 2025-06-11 05:19:31
上一页
官方N测试
下一页
gpt-4o(分析图片)
Built with