Claude / OpenAI 兼容中转:本地客户端接 Yuan API + Yuan Image 分步

[复制链接]
查看79 | 回复0 | 4 天前 | 显示全部楼层 |阅读模式
悬赏1资源点 未解决
最近在本地客户端里同时跑 Claude 对话和文生图,踩了几次 base_url / 模型名的坑,记一版可复现步骤。


## 1. 准备
- 中转文档:https://doc.apixhm.com
- 对话 API:https://api.apixhm.com
- 生图 API:https://image.apixhm.com

## 2. 对话(Claude,OpenAI 兼容)
Base URL 填 https://api.apixhm.com/v1 (有的客户端不要末尾 /v1);模型名以文档列表为准;API Key 填本地密钥。

from openai import OpenAI
client = OpenAI(base_url="https://api.apixhm.com/v1", api_key="YOUR_KEY")
r = client.chat.completions.create(
    model="claude-sonnet-4-5",
    messages=[{"role": "user", "content": "用三句话说明 OpenAI 兼容中转是什么"}],
)
print(r.choices[0].message.content)

## 3. 生图(Yuan Image)
文生图走 https://image.apixhm.com ;对话与生图域名不同,别混用。细节见 https://doc.apixhm.com 。

## 4. 常见问题
401:Key 或 Base URL 多/少了 /v1;模型不存在:换成文档当前可用名。

欢迎补充你们客户端的实际字段名。

回复

使用道具 举报

3

主题

0

回帖

13

积分

初出茅庐

积分
13