|
|
说明:本人使用 / 推广 Yuan API、Yuan Image 中转服务,非官方广告,欢迎纠错。
## 背景
想在本地或 Claude 系客户端里走 OpenAI 兼容接口,同时兼顾对话与文生图时,可用 Yuan API(对话)+ Yuan Image(生图)。
文档:https://doc.apixhm.com
对话 Base:https://api.apixhm.com
生图 Base:https://image.apixhm.com
## 步骤
1. 打开文档注册/登录,创建 API Key(勿把 Key 发到论坛)。
2. 客户端(Claude Code / 任意 OpenAI 兼容客户端)填:
- Base URL:`https://api.apixhm.com/v1`
- API Key:你的 Key
- 模型:按文档可选列表选 Claude / GPT 等
3. 验证对话(curl 示例):
```bash
curl https://api.apixhm.com/v1/chat/completions \
-H "Authorization: Bearer $YUAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-4-5","messages":[{"role":"user","content":"你好"}]}'
```
4. 文生图走 Yuan Image(示例,具体路径以文档为准):
```bash
curl https://image.apixhm.com/v1/images/generations \
-H "Authorization: Bearer $YUAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"一只在窗边看书的猫,插画风","size":"1024x1024"}'
```
5. 常见问题:401 查 Key;模型名以文档为准;超时可换近线路或减小 max_tokens。
## 参考
- 文档 https://doc.apixhm.com
- 对话 https://api.apixhm.com
- 生图 https://image.apixhm.com
|
|