图像生成
通过 chat completions 端点使用 AI 模型生成图像。
Requesty 路由器现已支持图像生成模型,可通过标准的 chat completions 端点在文本响应的同时返回生成的图像。
工作原理
图像生成模型使用与文本模型相同的 /v1/chat/completions 端点,但会在响应中返回一个额外的 images 数组,其中包含生成的图像。
请求格式
使用标准的 chat completions 格式发送请求:
curl https://gw.1route.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ONEROUTE_API_KEY" \
-d '{
"model": "vertex/google/gemini-2.5-flash-image-preview",
"messages": [
{
"role": "user",
"content": "Generate an image of a sunset over mountains"
}
]
}'
响应格式
{
"model": "vertex/google/gemini-2.5-flash-image-preview",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I've generated an image of a sunset over mountains as requested.",
"images": [
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,your_base64_image"
}
}
]
}
}
]
}
支持的模型
- Vertex AI Gemini:
vertex/google/gemini-2.5-flash-image-preview
该模型通过 Google 的 Vertex AI 平台提供快速、高质量的图像生成。
图像生成模型的定价可能与文本模型不同。请查看模型详情以获取具体的定价信息。
限制
- 生成的图像以 base64 编码数据的形式返回
- 图像大小和分辨率取决于具体模型的能力
- 某些模型可能具有内容过滤或安全限制
- 响应大小限制适用于组合的文本和图像数据