curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flux-kontext-pro",
"prompt": "Cyberpunk city at night, neon lights flickering",
"size": "16:9",
"metadata": {
"response_format": "png"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flux-kontext-max",
"prompt": "Transform this photo into watercolor style",
"size": "match_input_image",
"image_urls": ["https://example.com/photo.jpg"],
"metadata": {
"response_format": "jpg"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "flux-kontext-pro",
"prompt": "Cyberpunk city at night, neon lights flickering",
"size": "16:9",
"metadata": {
"response_format": "png"
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "flux-kontext-max",
"prompt": "Transform this photo into watercolor style",
"size": "match_input_image",
"image_urls": ["https://example.com/photo.jpg"],
"metadata": {
"response_format": "jpg"
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'flux-kontext-pro',
prompt: 'Cyberpunk city at night, neon lights flickering',
size: '16:9',
metadata: {
response_format: 'png'
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'flux-kontext-max',
prompt: 'Transform this photo into watercolor style',
size: 'match_input_image',
image_urls: ['https://example.com/photo.jpg'],
metadata: {
response_format: 'jpg'
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "flux-kontext-pro",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
Flux Kontext
Flux Kontext 画像生成
Generate and edit images using Flux Kontext model, supporting text-to-image and image editing
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flux-kontext-pro",
"prompt": "Cyberpunk city at night, neon lights flickering",
"size": "16:9",
"metadata": {
"response_format": "png"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flux-kontext-max",
"prompt": "Transform this photo into watercolor style",
"size": "match_input_image",
"image_urls": ["https://example.com/photo.jpg"],
"metadata": {
"response_format": "jpg"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "flux-kontext-pro",
"prompt": "Cyberpunk city at night, neon lights flickering",
"size": "16:9",
"metadata": {
"response_format": "png"
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "flux-kontext-max",
"prompt": "Transform this photo into watercolor style",
"size": "match_input_image",
"image_urls": ["https://example.com/photo.jpg"],
"metadata": {
"response_format": "jpg"
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'flux-kontext-pro',
prompt: 'Cyberpunk city at night, neon lights flickering',
size: '16:9',
metadata: {
response_format: 'png'
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'flux-kontext-max',
prompt: 'Transform this photo into watercolor style',
size: 'match_input_image',
image_urls: ['https://example.com/photo.jpg'],
metadata: {
response_format: 'jpg'
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "flux-kontext-pro",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}
中国本土のユーザー向け: 中国本土のユーザーは
https://toapis.cn を API エンドポイント(Base URL)としてご利用ください。本ドキュメント内の例では https://toapis.com を https://toapis.cn に置き換えてください。- Flux Kontext image generation and editing model
- Choose
flux-kontext-pro(Pro) orflux-kontext-max(Max, higher quality) via the model parameter - Supports text-to-image and image editing modes
- With reference image = image editing; without = text-to-image
- Fixed billing per request
- Async task mode, returns
task_idfor querying results
Important Change: For better performance and cost control, we no longer support passing base64 image data directly in
image_urls. Please use the Upload 画像API first to upload images and get URLs, then call this endpoint.Authorization
string
必須
All endpoints require Bearer Token authenticationGet your API Key: Visit the API Key Management Page to get your API KeyAdd to request header:
Authorization: Bearer YOUR_API_KEY
リクエストパラメータ
string
必須
Image generation model nameOptions:
flux-kontext-pro- Pro versionflux-kontext-max- Max version, higher quality
string
必須
Text description for image generation
string
Image aspect ratioDefault:
- With reference image:
match_input_image(match input image) - Without reference image:
16:9
| Value | 説明 |
|---|---|
match_input_image | Match input image ratio (image editing only) |
1:1 | Square |
4:3 / 3:4 | Traditional display ratio |
16:9 / 9:16 | Widescreen/portrait |
3:2 / 2:3 | Standard photo |
21:9 / 9:21 | Ultrawide/ultra-narrow |
string[]
Reference image URL array for image editing⚠️ URL format only (base64 not supported)
- Publicly accessible image URL (http:// or https://)
- Use the Upload 画像API to upload local images and get URLs
- Maximum 1 image
- With image = image editing mode; without = text-to-image mode
object
Metadata parameters for additional configuration options
レスポンス
string
Unique task identifier for querying task status
string
Object type, fixed as
generation.taskstring
モデル name used for generation
string
Task status
queued- Waiting to be processedin_progress- Processingcompleted- Successfully completedfailed- Failed
integer
Task progress percentage (0-100)
integer
Task creation timestamp (Unix timestamp)
object
Task metadata
Use Cases
Case 1: Text-to-Image
{
"model": "flux-kontext-pro",
"prompt": "Cyberpunk city at night, neon lights flickering",
"size": "16:9",
"metadata": {
"response_format": "png",
"safety_tolerance": 2
}
}
Case 2: Image Editing
{
"model": "flux-kontext-max",
"prompt": "Transform this photo into watercolor style",
"size": "match_input_image",
"image_urls": ["https://example.com/photo.jpg"],
"metadata": {
"response_format": "jpg",
"prompt_upsampling": true
}
}
Case 3: High-Quality Text-to-Image (Max モデル)
{
"model": "flux-kontext-max",
"prompt": "A cute orange cat sunbathing on a windowsill, photorealistic style",
"size": "1:1",
"metadata": {
"response_format": "png",
"safety_tolerance": 3
}
}
Query Task ResultsImage generation is an async task. After submission, a task ID is returned. Use the Get Image Task ステータス endpoint to query generation progress and results.
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flux-kontext-pro",
"prompt": "Cyberpunk city at night, neon lights flickering",
"size": "16:9",
"metadata": {
"response_format": "png"
}
}'
curl --request POST \
--url https://toapis.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flux-kontext-max",
"prompt": "Transform this photo into watercolor style",
"size": "match_input_image",
"image_urls": ["https://example.com/photo.jpg"],
"metadata": {
"response_format": "jpg"
}
}'
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "flux-kontext-pro",
"prompt": "Cyberpunk city at night, neon lights flickering",
"size": "16:9",
"metadata": {
"response_format": "png"
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
import requests
response = requests.post(
"https://toapis.com/v1/images/generations",
headers={
"Authorization": "Bearer your-ToAPIs-key",
"Content-Type": "application/json"
},
json={
"model": "flux-kontext-max",
"prompt": "Transform this photo into watercolor style",
"size": "match_input_image",
"image_urls": ["https://example.com/photo.jpg"],
"metadata": {
"response_format": "jpg"
}
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'flux-kontext-pro',
prompt: 'Cyberpunk city at night, neon lights flickering',
size: '16:9',
metadata: {
response_format: 'png'
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
const response = await fetch('https://toapis.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-ToAPIs-key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'flux-kontext-max',
prompt: 'Transform this photo into watercolor style',
size: 'match_input_image',
image_urls: ['https://example.com/photo.jpg'],
metadata: {
response_format: 'jpg'
}
})
});
const task = await response.json();
console.log(`Task ID: ${task.id}`);
console.log(`Status: ${task.status}`);
{
"id": "task_img_abc123def456",
"object": "generation.task",
"model": "flux-kontext-pro",
"status": "queued",
"progress": 0,
"created_at": 1703884800,
"metadata": {}
}