API 文档
完全兼容 OpenAI 接口规范。将 Base URL 指向本站即可。
接入信息
Base URL
https://cai.yy-fun.cc/v1
鉴权
Authorization: Bearer sk-fai-你的密钥
在控制台 → API 密钥 中创建。
支持端点
GET /v1/models
POST /v1/chat/completions
POST /v1/images/generations
POST /v1/images/edits
图片返回规则
所有生图与图生图成功结果都会自动下载并托管到本站,接口只返回本站图片 URL,不返回 Base64、Data URI 或上游临时地址。
{
"created": 1760000000,
"data": [
{
"url": "https://cai.yy-fun.cc/uploads/generated/2026/10/10/example.jpg"
}
]
}
即使请求传入 response_format=b64_json,本站也会忽略该输出格式并返回托管 URL。输入图片仍可使用 URL、Data URI 或 Base64。
Chat Completions(流式)
curl https://cai.yy-fun.cc/v1/chat/completions \
-H "Authorization: Bearer sk-fai-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.5",
"stream": true,
"messages": [{"role":"user","content":"你好"}]
}'
Images Generations
curl https://cai.yy-fun.cc/v1/images/generations \
-H "Authorization: Bearer sk-fai-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "dall-e-3",
"prompt": "a futuristic city at dusk",
"size": "1024x1024"
}'
返回 data[].url,图片地址固定为本站域名下的托管地址。
Images Edits / 图生图
JSON 请求统一使用 images 字符串数组:单图传一个元素,多图按顺序传多个元素。每个元素可以是 URL、Data URI 或 Base64。
curl https://cai.yy-fun.cc/v1/images/edits \
-H "Authorization: Bearer sk-fai-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5",
"prompt": "将背景替换为海边日落",
"images": ["https://example.com/input.png"],
"size": "1024x1024"
}'
多图请求使用相同字段,例如:
"images": ["https://example.com/first.png", "https://example.com/second.png"]
从本地文件上传时,仍可使用 multipart:
curl https://cai.yy-fun.cc/v1/images/edits \
-H "Authorization: Bearer sk-fai-xxx" \
-F "model=gpt-image-1" \
-F "prompt=将背景替换为海边日落" \
-F "image=@input.png" \
-F "size=1024x1024"
/v1/images/generations 同样接受 images 数组。旧版 JSON 字段 image 继续兼容;支持蒙版的模型可额外传入 mask。
成功结果同样只返回本站托管图片 URL。
Python 示例
from openai import OpenAI
client = OpenAI(
api_key="sk-fai-xxx",
base_url="https://cai.yy-fun.cc/v1"
)
stream = client.chat.completions.create(
model="grok-4.5",
messages=[{"role":"user","content":"写一句问候"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")