OpenAI 兼容接口
Base URL
Section titled “Base URL”https://zhangsan.yun/v1curl 示例
Section titled “curl 示例”curl https://zhangsan.yun/v1/chat/completions \ -H "Authorization: Bearer sk-你的 API 密钥" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5", "messages": [ {"role": "user", "content": "你好,简单介绍一下你自己"} ] }'OpenAI SDK 示例
Section titled “OpenAI SDK 示例”import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, baseURL: "https://zhangsan.yun/v1",});
const response = await client.chat.completions.create({ model: "gpt-5.5", messages: [{ role: "user", content: "写一个三句话的产品介绍" }],});
console.log(response.choices[0].message.content);baseURL需要包含/v1。- 令牌放在
Authorization: Bearer后面。 - 模型是否可用取决于你的分组和当前渠道状态。