1. OpenAi接口
AiXor文档
  • 操作指南
  • 常见问题
  • 当前订阅套餐模型倍率
  • OpenClaw接入教程
  • OpenClaw一键脚本接入教程
  • Claude Code 安装接入教程
  • Codex安装接入教程
  • VScode安装Claudecode教程
  • Chatbox接入教程
  • Cherry studio接入教程
  • gpt-image-2使用教程
  • OpenAi接口
    • 文本生成
      POST
    • 文本生成 - 上下文阅读
      POST
    • 图片理解
      POST
    • 图片生成(gpt-image-1/sora_image/flux-kontext-pro)
      POST
    • 图片编辑 - edits
      POST
    • 图片编辑 - 网页版
      POST
    • 函数调用 - tools
      POST
    • v1/Responses - 通用
      POST
    • 内容补全接口
      POST
    • 创建内容审核
      POST
    • PDF文件分析
      POST
    • 深度研究 - Deep-research
      POST
    • 联网搜索 - Web search
      POST
    • response_format
      POST
  • Authropic Claude接口
    • OpenAi兼容接口
      • 文本生成
      • 文本生成 - 强制返回思考 Copy
      • 函数调用
      • 图片理解
      • 联网搜索 - Web search
    • 文本生成
      POST
    • 图片理解
      POST
    • 文本生成 - 强制返回思考
      POST
    • 函数调用
      POST
    • 联网搜索 - Web search
      POST
    • 文本生成 - 思考配置
      POST
    • PDF传输
      POST
  • Google Gemini接口
  • 疑难问题
    • Codex
    • Claude Code
    • OpenClaw
    • API
  1. OpenAi接口

response_format

POST
/v1/chat/completions

请求参数

Header 参数

Body 参数application/json必填

示例
{
    "model": "gpt-4o-2024-08-06",
    "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 'https://aixor.org/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: sk-' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gpt-4o-2024-08-06",
    "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
            }
        }
    }
}'

返回响应

🟢200成功
application/json
Bodyapplication/json

示例
{
    "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
    }
}
修改于 2026-03-17 08:55:57
上一页
联网搜索 - Web search
下一页
文本生成
Built with