OpenAI 兼容接入
优芯中转站支持 OpenAI 兼容接口,适合 OpenAI SDK、聊天客户端、IDE 插件和自动化脚本。
基础配置
| 配置项 | 填写内容 |
|---|---|
| Base URL | https://api.yucpu.com/v1 |
| API Key | sk-your-api-key |
| Chat Completions | https://api.yucpu.com/v1/chat/completions |
| Responses | https://api.yucpu.com/v1/responses |
如果客户端要求填写不带 /v1 的基础域名,填:
text
https://api.yucpu.com如果客户端要求填写 OpenAI Base URL,通常填:
text
https://api.yucpu.com/v1OpenAI SDK 示例
ts
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-your-api-key",
baseURL: "https://api.yucpu.com/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "回复 pong" }],
});
console.log(response.choices[0]?.message?.content);Chat Completions 验证
bash
curl https://api.yucpu.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "content-type: application/json" \
-d '{
"model": "gpt-5",
"messages": [
{ "role": "user", "content": "回复 pong" }
]
}'Responses 验证
bash
curl https://api.yucpu.com/v1/responses \
-H "Authorization: Bearer sk-your-api-key" \
-H "content-type: application/json" \
-d '{
"model": "gpt-5",
"input": "回复 pong"
}'如何选择接口
| 客户端类型 | 推荐接口 |
|---|---|
| 传统 OpenAI SDK / 聊天客户端 | /v1/chat/completions |
| Codex 类工具 / Responses 客户端 | /v1/responses |
| Claude Code / Anthropic 兼容客户端 | /v1/messages |
如果你不确定客户端使用哪个接口,先看它的配置项名称。出现 OpenAI Base URL 时通常使用 /v1;出现 Anthropic Base URL 或 Claude Base URL 时通常使用 https://api.yucpu.com。