gemini-2.5-flash-image,同時支援 OpenAI 相容端點。
核心能力
- 文字生成圖片 - 根據文字生成圖片
- Gemini 原生 API - 使用 generateContent
- 圖片輸出 - 在 responseModalities 中請求 IMAGE
- 內容片段 - 使用 Gemini 多模態輸入結構
輸出規格
| 屬性 | 取值 |
|---|---|
| 端點 | /v1/models/gemini-2.5-flash-image:generateContent |
| 輸出模態 | IMAGE |
| 回應 | Gemini content parts 中的圖片資料 |
快速範例
Gemini 原生 API
- cURL
- Python
curl "https://api.mixroute.ai/v1/models/gemini-2.5-flash-image:generateContent" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"parts": [
{
"text": "A minimal red circle centered on a white background"
}
]
}
],
"generationConfig": {
"responseModalities": [
"TEXT",
"IMAGE"
]
}
}'
import requests
response = requests.post(
"https://api.mixroute.ai/v1/models/gemini-2.5-flash-image:generateContent",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={'contents': [{'parts': [{'text': 'A minimal red circle centered on a white '
'background'}]}],
'generationConfig': {'responseModalities': ['TEXT', 'IMAGE']}},
)
print(response.json())
OpenAI 相容 API
- cURL
- Python
- Streaming
curl "https://api.mixroute.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"messages": [
{
"role": "user",
"content": "Explain quantum entanglement in simple terms."
}
],
"max_tokens": 256
}'
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.mixroute.ai/v1")
response = client.chat.completions.create(
model="gemini-2.5-flash-image",
messages=[{"role": "user", "content": "Explain quantum entanglement in simple terms."}],
max_tokens=256,
)
print(response.choices[0].message.content)
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="https://api.mixroute.ai/v1")
stream = client.chat.completions.create(
model="gemini-2.5-flash-image",
messages=[{"role": "user", "content": "Write a short poem about the sea."}],
max_tokens=256,
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
contents | array | 是 | 提示詞與可選多模態內容片段。 |
generationConfig.responseModalities | array | 是 | 包含 IMAGE 以請求圖片輸出。 |
generationConfig | object | 否 | 其他生成參數。 |