Appearance
Curl 调用示例
这页主要给已经有 API Key 的用户一个最直接的调用方式:
你既可以先在页面里手动填 Key 测一下,也可以直接复制下面的 cURL、Python、JavaScript 示例。
在线测试
先输入你的 API Key、模型和提示词,然后直接发送测试请求:
cURL 预览
curl https://www.open1.codes/v1/responses \
-H "Authorization: Bearer {在这里填写_API_Key}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Reply with OK only."
}
]
}
]
}'部署提醒
如果你把文档站部署在 doc.open1.codes 这类独立域名下,在线测试必须把:
text
/open1-api/*反向代理到:
text
https://www.open1.codes/*否则浏览器会因为跨域限制拦截请求。
可用测试模型
当前这页固定使用下面这组模型,默认是 gpt-5.4:
| 模型名 | 模型 ID | 输入价格 | 输出价格 | 状态 |
|---|---|---|---|---|
| GPT-5.4 | gpt-5.4 | $2.50 | $15.00 | 可用 |
| GPT-5.3 Codex | gpt-5.3-codex | $1.75 | $14.00 | 可用 |
| GPT-5.3 Codex Spark | gpt-5.3-codex-spark | - | - | 未匹配 |
| GPT-5.2 | gpt-5.2 | $1.75 | $14.00 | 可用 |
| GPT-5.2 Codex | gpt-5.2-codex | $1.75 | $14.00 | 可用 |
| GPT-5.1 Codex Max | gpt-5.1-codex-max | $1.25 | $10.00 | 可用 |
| GPT-5.1 Codex | gpt-5.1-codex | $1.25 | $10.00 | 可用 |
| GPT-5.1 | gpt-5.1 | $1.25 | $10.00 | 可用 |
| GPT-5.1 Codex Mini | gpt-5.1-codex-mini | $0.2500 | $2.00 | 可用 |
| GPT-5 | gpt-5 | $1.25 | $10.00 | 可用 |
示例代码
下面 3 种写法都只走 responses 接口。
其中 JavaScript 示例更适合在 Node.js 18+ 环境里跑。
bash
curl https://www.open1.codes/v1/responses \
-H "Authorization: Bearer {在这里填写_API_Key}" \
-H "Accept: application/json" \
-H "User-Agent: curl/8.0" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Reply with OK only."
}
]
}
]
}'参数说明
BASE_URL:默认是https://www.open1.codesAPI_KEY:换成你自己的 KeyMODEL:建议先用gpt-5.4PROMPT:你要发送的内容
常见问题
1. 返回 401
通常是 API Key 不对,或者复制时多了空格。
2. 返回 403 / 权限相关错误
先检查下面几项:
- 当前 Key 的分组、订阅和用途有没有选错
- 请求里是否缺少
User-Agent - 如果你是自己写脚本或服务端请求,建议显式补上:
text
User-Agent: curl/8.0提醒
如果你不是直接用命令行 curl,而是自己写 Python / JavaScript 请求,出现 403 时优先检查是否缺少这个请求头。
3. 浏览器里直接跑 JavaScript 不通
如果你把 JavaScript 示例直接放在浏览器控制台里跑,常见问题是:
- 跨域限制
- 不能像服务端那样自由控制请求头
所以这份 JavaScript 示例更推荐放在 Node.js 18+ 环境里运行。
4. 返回 429
可能是并发限制、额度不足,或者当前分组不能继续使用。
5. 模型不存在
先到 渠道与模型 页面确认当前模型名。