Flux Kontext Max API
強化されたマルチ画像コンテキスト理解を備えたFlux Kontext Maxの完全なAPIリファレンスです。
モデル概要
クイック比較
サポートされているアスペクト比
両モードとも9種類のアスペクト比に対応:
1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 21:9, 9:21
コスト {#}
Flux Kontext Max(テキストから画像)
エンドポイント
POST /api/v1/image/task
認証
Authorization: Bearer YOUR_API_KEY
リクエストパラメータ
必須
注意: width:heightの比率は次のいずれかである必要があります:「1:1」、「16:9」、「9:16」、「3:2」、「2:3」、「4:3」、「3:4」、「21:9」、「9:21」
リクエスト例
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'flux-kontext-max',
prompt: 'A futuristic cityscape at night with neon lights',
width: 16,
height: 9
})
});
const { data } = await response.json();
const taskId = data.task_id;
const pollResponse = await fetch(
`https://api.flaq.ai/api/v1/image/${taskId}`,
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
const result = await pollResponse.json();
console.log(result.data.task_result.images[0].url);
Flux Kontext Max(画像から画像)
エンドポイント
POST /api/v1/image/task
リクエストパラメータ
必須
注意: width:heightの比率は次のいずれかである必要があります:「1:1」、「16:9」、「9:16」、「3:2」、「2:3」、「4:3」、「3:4」、「21:9」、「9:21」
単一画像編集の例
{
model_name: 'flux-kontext-max',
prompt: 'Enhance this portrait with cinematic lighting',
width: 3,
height: 4,
image_url_list: ['https://example.com/portrait.jpg']
}
マルチ画像合成の例
{
model_name: 'flux-kontext-max',
prompt: 'Merge these architectural photos into a unified panorama',
width: 21,
height: 9,
image_url_list: ['https://example.com/arch1.jpg', 'https://example.com/arch2.jpg', 'https://example.com/arch3.jpg']
}
レスポンス形式
初期レスポンス
両モードともポーリング用のtask_idを返します:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "submitted",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}"
},
"message": "success"
}
ポーリングレスポンス
/api/v1/image/{taskId}をポーリングしてステータスを確認:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_result": {
"credit": 0.08,
"images": [
{
"url": "https://example.com/generated-image.jpeg"
}
]
}
},
"message": "success"
}
ステータス値
submitted: タスクが受け付けられました
processing: 生成処理中
succeed: 生成が正常に完了しました
failed: 生成に失敗しました
エラーハンドリング
一般的なエラー
無効なアスペクト比
{
"code": 400,
"message": "Ratio must be one of: 1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 21:9, 9:21"
}
画像URLの欠落(画像から画像モード)
{
"code": 400,
"message": "image_url_list is required for flux-kontext-max"
}
画像数の超過
{
"code": 400,
"message": "Maximum 5 images allowed"
}
ベストプラクティス
テキストから画像のヒント
- 詳細なプロンプト: 最良の結果を得るために明確で詳細な説明を提供
- アスペクト比: 用途に適したアスペクト比を選択
- 複雑なシーン: Flux Kontext Maxは複雑で詳細なシーンに優れています
- 効率的なポーリング: 2〜3秒ごとにステータスを確認
画像から画像のヒント
- コンテキスト認識: マルチ画像入力を活用してコンテキストに富んだ生成を実現
- 高品質な入力: 最良の結果を得るために高解像度のソース画像を使用
- 明確な変換目標: 希望する結果を正確に説明
- マルチ画像の相乗効果: 複雑な合成のために最大5枚の画像を組み合わせ
使用例
高品質な商品写真
{
model_name: 'flux-kontext-max',
prompt: 'Ultra-realistic product shot of diamond jewelry on black velvet',
width: 4,
height: 3
}
建築ビジュアライゼーション
{
model_name: 'flux-kontext-max',
prompt: 'Modern minimalist interior with natural lighting',
width: 16,
height: 9
}
マルチ画像パノラマ
{
model_name: 'flux-kontext-max',
image_url_list: ['view1.jpg', 'view2.jpg', 'view3.jpg', 'view4.jpg'],
prompt: 'Seamless 360-degree panorama of mountain landscape',
width: 21,
height: 9
}
高度なスタイル転送
{
model_name: 'flux-kontext-max',
image_url_list: ['photo.jpg'],
prompt: 'Transform into oil painting with Van Gogh style brushwork',
width: 1,
height: 1
}