1. GPT接口
Code0.ai
  • 引言
    • 引言
    • 添加客服
  • 快速开始(小白篇)
    • 5分钟快速开始
    • 新用户:怎么拿到 Key?
    • 发出请求
    • 计费说明
    • 如何查询用量日志
  • 平台能力概览(入门篇)
    • 平台定位
    • 中转站基本介绍
      • 分组的特殊性及价格差异
      • 代理接口调用地址
      • 聊天完成对象
    • 关于我们的模型
      • 模型总览一览表
      • 不知道选哪个模型?
      • 我们的模型系列
        • OpenAI — 共 9 个模型
        • Anthropic Claude — 共 8 个模型
        • Google Gemini — 共 11 个模型
        • 阿里巴巴(通义千问)— 共 4 个模型
        • 智谱(GLM)— 共 4 个模型
        • 豆包 Doubao(字节跳动)— 共 3 个模型
      • 模型能力对比
        • 文本对话能力
        • 代码生成能力
        • 图像能力
  • API Key 管理(进阶篇)
    • 创建与管理 Key
    • 密钥安全与批量操作
  • FAQ常见问题(小白篇)
    • 故障自查
      • 错误码速查表
        • API报错了?!
      • Token 消耗异常排查
        • Cherry Studio 联网搜索导致 Token 爆炸
        • Claude Code autoCompact 无限重试
        • 客户端超时后自动重试
    • 常见问题Top 20
      • 后台显示的 "$" 是美元吗?
      • 充 10 块为什么实际付了 15?
      • 分组倍率 6x 是什么意思?
      • 模型名写 4.6 还是 4-6?
      • 创建令牌时可以不选分组吗?
      • 怎么开启 1M 上下文?
      • 开了梯子后调用 API 报 401 怎么办?
      • code0.ai / hk.code0.ai / jp.code0.ai 用哪个?
      • 你们会存储我传的图片/对话数据吗?
  • 🔥 核心 API (进阶篇)
    • 对话生成(Chat Completions)
      • Anthropic Claude 接口
        • 聊天完成对象
        • 聊天完成块对象
        • 创建聊天补全
        • 创建函数调用 (流式)
        • 创建格式化输出
        • 创建思考聊天
        • 联网搜索
        • PDF支持
      • ChatGPT聊天(Chat)
        • ChatGPT接口
          • 测试对话接口
          • 函数调用
        • 创建聊天识图 (流式)
        • 创建聊天补全 (非流)
        • 创建聊天补全 (流式)
        • 创建聊天识图 (流式) best64
        • 创建聊天识图 (非流)
        • 创建聊天创作图 (非流)
        • 官方Function calling调用
        • 官方N测试
        • 列出模型
        • 创建聊天函数调用
        • 创建结构化输出
        • 控制推理模型努力程度
      • Gemini接口
        • 标准接口
          • 文本生成
          • 文本生成-流
          • 文本生成+思考-流
          • 图片理解
          • 格式化输出
          • 函数调用
          • 文档理解
          • 视频理解
          • 音频理解
          • 文本生成 gemini-3-pro-preview:generateContent
        • 兼容接口
          • Gemini 图片创作接口 [Chat 兼容格式]
          • 聊天接口 [Chat 兼容格式]
          • 聊天接口-思考1 [Chat 兼容格式]
          • 聊天接口-思考2 [Chat 兼容格式]
          • 识图接口 [Chat 兼容格式]
          • 聊天+读取文件接口 [Chat 兼容格式]
    • 对话生成 (Responses API)
      • Gemini接口
        • URL context [原生格式]
        • URL context
        • google search
        • 代码执行
      • GPT接口
        • 创建函数调用 Copy
          POST
    • 图片生成/绘画模型(Images)
      • 默认模块
      • Gemini接口
        • 图片生成
        • 图片生成 gemini-2.5-flash-image
        • 图片生成 gemini-2.5-flash-image 控制宽高比
        • 图片生成 gemini-3-pro-image-preview 控制宽高比 +清晰度
        • 图片编辑
        • Imagen 生成图片
      • 豆包doubao接口
        • doubao-seedream-4-5-251128 文生图(纯文本输入单图输出)
        • doubao-seedream-4-5-251128 图文生图(单图输入单图输出)
        • doubao-seedream-4-5-251128 多图融合(多图输入单图输出)
        • doubao-seedream-4-5-251128 组图输出(多图输出)
        • doubao-seedream-4-5-251128 单张图生组图
        • doubao-seedream-4-5-251128 多参考图生组图
    • 语音(Audio)
      • 语音转文字(STT / Whisper)
      • 文字转语音(TTS)
      • 实时语音对话
    • 向量嵌入(Embeddings)
      • Gemini接口
        • Embeddings
        • 文本嵌入
    • 文件管理(Files)
      • 上传文件
      • 文件列表
      • 获取文件信息
      • 删除文件
    • 模型管理(Models)
      • 获取模型列表
    • 审核/安全(Moderations)
      • 内容审核
  • SDK 与接入教程(进阶篇)
    • PHP 配置方式
      • PHP 使用图片编辑 Demo
    • NodeJS 配置方式
      • NodeJS 基础对话
    • Python配置方式
      • Python连续对话
    • Java / Go / C#
    • ChatBox 配置
    • Cursor 配置
      • 通过插件实现Cursor配置(免费)
      • Cursor 配置 API 中转站(需要付费)
    • 沉浸式翻译配置
    • 其他第三方工具 │
  • 软件 / 插件配置教程(进阶篇)
    • Cherry Studio 接入
    • opencode接入
    • Roo Code接入(VScode插件)
    • OpenClaw接入
      • OpenClaw Claude 系列模型接入 code0.ai 中转 API 配置指南
    • 接入各类插件教程
    • GPT相关接入
      • OpenAI Codex CLI 接入 code0 API
    • Gemini相关接入
    • Claude相关接入
  1. GPT接口

创建函数调用 Copy

POST
/v1/responses
https://platform.openai.com/docs/api-reference/responses/create
部分OpenAI模型仅支持Response格式,例如o3-pro,codex-mini-latest

请求参数

Authorization
or
Header 参数

Body 参数application/json

示例
{
    "input": [
        {
            "role": "user",
            "content": "请同时帮我做以下几件事:\n1. 获取当前系统时间\n2. 查看系统信息(操作系统、内存等)\n3. 帮我计算 123.5 + 456.7 的结果\n4. 生成3个1-100之间的随机数\n\n这是一个并行工具调用测试,请同时执行这些任务。"
        }
    ],
    "metadata": {
        "model_id": "32"
    },
    "model": "gpt-4.1",
    "tool_choice": "auto",
    "tools": [
        {
            "type": "function",
            "name": "random_generator",
            "description": "生成指定范围内的随机数,支持批量生成",
            "parameters": {
                "type": "object",
                "properties": {
                    "min": {
                        "description": "最小值(默认1)",
                        "type": "integer"
                    },
                    "max": {
                        "description": "最大值(默认100)",
                        "type": "integer"
                    },
                    "count": {
                        "description": "生成数量(默认1,最大10)",
                        "type": "integer"
                    }
                }
            }
        },
        {
            "type": "function",
            "name": "system_info",
            "description": "获取当前系统的基本信息,包括操作系统、Java版本、内存使用情况等",
            "parameters": {
                "type": "object",
                "properties": {}
            }
        },
        {
            "type": "function",
            "name": "math_calculator",
            "description": "执行基本数学运算,支持加减乘除和幂运算",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "description": "第一个数字",
                        "type": "number"
                    },
                    "b": {
                        "description": "第二个数字",
                        "type": "number"
                    },
                    "operation": {
                        "description": "运算类型: add, subtract, multiply, divide, power",
                        "type": "string"
                    }
                },
                "required": [
                    "operation",
                    "a",
                    "b"
                ]
            }
        },
        {
            "type": "function",
            "name": "current_time",
            "description": "获取当前系统时间",
            "parameters": {
                "type": "object",
                "properties": {}
            }
        }
    ]
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST '/v1/responses' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "input": [
        {
            "role": "user",
            "content": "请同时帮我做以下几件事:\n1. 获取当前系统时间\n2. 查看系统信息(操作系统、内存等)\n3. 帮我计算 123.5 + 456.7 的结果\n4. 生成3个1-100之间的随机数\n\n这是一个并行工具调用测试,请同时执行这些任务。"
        }
    ],
    "metadata": {
        "model_id": "32"
    },
    "model": "gpt-4.1",
    "tool_choice": "auto",
    "tools": [
        {
            "type": "function",
            "name": "random_generator",
            "description": "生成指定范围内的随机数,支持批量生成",
            "parameters": {
                "type": "object",
                "properties": {
                    "min": {
                        "description": "最小值(默认1)",
                        "type": "integer"
                    },
                    "max": {
                        "description": "最大值(默认100)",
                        "type": "integer"
                    },
                    "count": {
                        "description": "生成数量(默认1,最大10)",
                        "type": "integer"
                    }
                }
            }
        },
        {
            "type": "function",
            "name": "system_info",
            "description": "获取当前系统的基本信息,包括操作系统、Java版本、内存使用情况等",
            "parameters": {
                "type": "object",
                "properties": {}
            }
        },
        {
            "type": "function",
            "name": "math_calculator",
            "description": "执行基本数学运算,支持加减乘除和幂运算",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "description": "第一个数字",
                        "type": "number"
                    },
                    "b": {
                        "description": "第二个数字",
                        "type": "number"
                    },
                    "operation": {
                        "description": "运算类型: add, subtract, multiply, divide, power",
                        "type": "string"
                    }
                },
                "required": [
                    "operation",
                    "a",
                    "b"
                ]
            }
        },
        {
            "type": "function",
            "name": "current_time",
            "description": "获取当前系统时间",
            "parameters": {
                "type": "object",
                "properties": {}
            }
        }
    ]
}'

返回响应

🟢200
application/json
Body

示例
{
    "id": "resp_68ac1558e9488190bcc2cbb94c7d7a140b8064b15a091a77",
    "object": "response",
    "created_at": 1756108120,
    "status": "completed",
    "background": false,
    "content_filters": null,
    "error": null,
    "incomplete_details": null,
    "instructions": null,
    "max_output_tokens": null,
    "max_tool_calls": null,
    "model": "gpt-4.1-data",
    "output": [
        {
            "id": "fc_68ac15594be88190a58217f75a6a54cc0b8064b15a091a77",
            "type": "function_call",
            "status": "completed",
            "arguments": "{\"sign\":\"Aquarius\"}",
            "call_id": "call_6kbB2GTk62PPUNdGuBJPx9KQ",
            "name": "get_horoscope"
        }
    ],
    "parallel_tool_calls": true,
    "previous_response_id": null,
    "prompt_cache_key": null,
    "reasoning": {
        "effort": null,
        "summary": null
    },
    "safety_identifier": null,
    "service_tier": "default",
    "store": true,
    "temperature": 1,
    "text": {
        "format": {
            "type": "text"
        }
    },
    "tool_choice": "auto",
    "tools": [
        {
            "type": "function",
            "description": "Get today's horoscope for an astrological sign.",
            "name": "get_horoscope",
            "parameters": {
                "properties": {
                    "sign": {
                        "description": "An astrological sign like Taurus or Aquarius",
                        "type": "string"
                    }
                },
                "required": [
                    "sign"
                ],
                "type": "object"
            },
            "strict": true
        }
    ],
    "top_p": 1,
    "truncation": "disabled",
    "usage": {
        "input_tokens": 62,
        "input_tokens_details": {
            "cached_tokens": 0
        },
        "output_tokens": 18,
        "output_tokens_details": {
            "reasoning_tokens": 0
        },
        "total_tokens": 80
    },
    "user": null,
    "metadata": {}
}
上一页
代码执行
下一页
默认模块
Built with