TA的每日心情 | 开心 2026-11-12 02:48 |
|---|
签到天数: 6 天 [LV.2]偶尔看看I
注册会员
- 积分
- 155
|
本地 SD / ComfyUI 之外,有时只想快速出一张参考图,不必开整套本地工作流。我这边把文生图接到 Yuan Image(OpenAI 兼容 images 接口),需要润色 SD 提示词时再走 Yuan API。
一、入口
- 生图:https://image.apixhm.com
- 对话 / 提示词润色:https://api.apixhm.com
- 文档(模型与参数):https://doc.apixhm.com
在控制台创建 Key,只放环境变量,下面用 YOUR_KEY 占位,不要填写真实密钥。
二、用 Yuan Image 出图
生图 base 用 https://image.apixhm.com/v1,不要和对话接口混用同一个路径。
```python
import os
import requests
resp = requests.post(
"https://image.apixhm.com/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_KEY",
"Content-Type": "application/json",
},
json={
"model": "按控制台生图模型列表填写",
"prompt": "a rainy neo-tokyo alley at night, neon signs, wet asphalt reflections, cinematic lighting, highly detailed",
"size": "1024x1024",
},
timeout=120,
)
print(resp.json())
```
模型 ID、尺寸和其他参数以 https://doc.apixhm.com 为准,不要写死过时名称。
三、可选:用 Yuan API 润色 SD 提示词
把对话客户端的 Base URL 指到 https://api.apixhm.com/v1,让模型先写出英文正向/负向提示词,再把定稿送进上一步的 prompt。
```python
import requests
resp = requests.post(
"https://api.apixhm.com/v1/chat/completions",
headers={"Authorization": "Bearer YOUR_KEY", "Content-Type": "application/json"},
json={
"model": "gpt-4o-mini",
"messages": [
{"role": "system", "content": "你是 Stable Diffusion 提示词助手,只输出英文 prompt 和 negative prompt。"},
{"role": "user", "content": "写一组赛博朋克雨夜小巷的 SD 提示词"}
],
},
timeout=60,
)
print(resp.json()["choices"][0]["message"]["content"])
```
四、小提示
1. 生图走 image.apixhm.com,对话走 api.apixhm.com,两个地址不要混。
2. 提示词尽量英文,主体、风格、镜头、光影写清楚。
3. 报错时先对一下 https://doc.apixhm.com 的模型列表和字段说明。
欢迎补充你们在 SD 工作流里接云端文生图 API 的经验。
利益披露:作者使用并推广 Yuan API / Yuan Image 中转服务。
|
|