0

GPT / ChatGPT 接 OpenAI 兼容中转:Yuan API 对话 + Yuan Image 生图

yuan_dev
20小时前 18

大家好,之前写过 Claude Code、Cherry Studio 和 Codex 的接入,这篇专门记一下 GPT / ChatGPT 客户端怎么接到 Yuan API。Yuan API 提供 OpenAI 兼容对话,也提供生图服务。官方入口如下:对话 API:https://api.apixhm.com生图:https://image.apixhm.com

文档:https://doc.apixhm.com


一、先拿到 API Key

打开文档 https://doc.apixhm.com ,按「从注册到上手」注册并在控制台创建 Key。模型 ID 以模型页面为准,下面示例用 gpt-4o-mini,你换成控制台里实际开通的 GPT 模型即可。


二、对话走 OpenAI 兼容地址

GPT 类客户端和官方 SDK 把 Base URL 指到 https://api.apixhm.com/v1(注意带 /v1;Claude Code 才用不带 /v1 的根地址)。


大多数客户端只需要填三项:API Key、Base URL、模型 ID。用 curl 可以先验证:


curl https://api.apixhm.com/v1/chat/completions \

  -H "Authorization: Bearer YOUR_KEY" \

  -H "Content-Type: application/json" \

  -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"用三句话说明如何把 OpenAI 兼容客户端的 Base URL 改成中转地址"}]}'


Key 用你自己的,不要写进仓库或截图。


三、同一套 Key 调用文生图

需要配图时,把提示词发给生图接口:


curl https://image.apixhm.com/v1/images/generations \

  -H "Authorization: Bearer YOUR_KEY" \

  -H "Content-Type: application/json" \

  -d '{"model":"dall-e-3","prompt":"a tidy desk with a laptop showing a chat window, soft daylight, documentary photo","size":"1024x1024"}'


返回里的图片地址拿来预览即可。提示词尽量写清主体、风格和光线,细节见文档 https://doc.apixhm.com。


欢迎一起交流模型选择和客户端配置。





最新回复 (0)

    暂无评论

请先登录后发表评论!

返回