ToAPIsToAPIs
Flux 2.0

Flux 2.0 이미지 생성

Generate high-quality images using Flux 2.0 model, supporting text-to-image and image-to-image

POST
/v1/images/generations

중국 본토 사용자 안내: 중국 본토 사용자는 https://toapis.cn 를 API 엔드포인트(Base URL)로 사용해 주세요. 본 문서의 예시에서 https://toapis.com 을 https://toapis.cn 로 바꿔 주세요.

  • Flux 2.0 image generation model
  • Choose flux-2-flex (faster, for quick iteration) or flux-2-pro (higher quality, better details) via the model parameter
  • Supports text-to-image and image-to-image, up to 8 reference images
  • Billed by resolution (1K/2K)
  • Async task mode, returns task_id for 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

Authorizationstring헤더필수

All endpoints require Bearer Token authentication

Get your API Key: Visit the API Key Management Page to get your API Key

Add to request header:

Authorization: Bearer YOUR_API_KEY

요청 파라미터

modelstring본문필수

Image generation model name

Options:

  • flux-2-flex - Faster, suitable for quick iteration
  • flux-2-pro - Higher quality, better details
promptstring본문필수

Text description for image generation

sizestring본문기본값: 1:1

Image aspect ratio

Supported aspect ratios:

  • 1:1 - Square (default)
  • 4:3 / 3:4 - Traditional display ratio
  • 16:9 / 9:16 - Widescreen/portrait
  • 3:2 / 2:3 - Standard photo
image_urlsstring[]본문

Reference image URL array for image-to-image

⚠️ URL format only (base64 not supported)

  • Publicly accessible image URL (http:// or https://)
  • Use the Upload 이미지 API to upload local images and get URLs

Limits:

  • Maximum 8 reference images
metadataobject본문

Metadata parameters for additional configuration options

Supported metadata fields
resolutionstring본문기본값: 1K

Output image resolution

Options:

  • 1K - Standard resolution (default)
  • 2K - High resolution

Resolution vs. aspect ratio pixel dimensions:

Aspect Ratio1K Size2K Size
1:11024×10242048×2048
4:31365×10242730×2048
3:41024×13652048×2730
16:91820×10243640×2048
9:161024×18202048×3640
3:21536×10243072×2048
2:31024×15362048×3072

Note: Different resolutions have different billing; 2K costs more than 1K.

응답

idstring

Unique task identifier for querying task status

objectstring

Object type, fixed as generation.task

modelstring

모델 name used for generation

statusstring

Task status

  • queued - Waiting to be processed
  • in_progress - Processing
  • completed - Successfully completed
  • failed - Failed
progressinteger

Task progress percentage (0-100)

created_atinteger

Task creation timestamp (Unix timestamp)

metadataobject

Task metadata

Use Cases

Case 1: Text-to-Image (Quick Iteration)

{
  "model": "flux-2-flex",
  "prompt": "A cute orange cat sunbathing on a windowsill",
  "size": "1:1",
  "metadata": {
    "resolution": "1K"
  }
}

Case 2: Text-to-Image (High Quality Output)

{
  "model": "flux-2-pro",
  "prompt": "Future city skyline, neon lights, cyberpunk style, cinematic quality",
  "size": "16:9",
  "metadata": {
    "resolution": "2K"
  }
}

Case 3: Image-to-Image (Multiple Reference Images)

{
  "model": "flux-2-pro",
  "prompt": "Keep character style, generate a scene of running in the forest",
  "size": "1:1",
  "image_urls": [
    "https://example.com/ref1.jpg",
    "https://example.com/ref2.jpg"
  ],
  "metadata": {
    "resolution": "2K"
  }
}

Case 4: Portrait Poster

{
  "model": "flux-2-flex",
  "prompt": "Concert poster, minimalist style, dark background",
  "size": "9:16",
  "metadata": {
    "resolution": "1K"
  }
}

Query Task Results

Image 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-2-flex",
    "prompt": "A cute orange cat sunbathing on a windowsill",
    "size": "1:1",
    "metadata": {
      "resolution": "1K"
    }
  }'
curl --request POST \
  --url https://toapis.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flux-2-pro",
    "prompt": "Keep character style, generate a scene of running in the forest",
    "size": "1:1",
    "image_urls": ["https://example.com/ref1.jpg"],
    "metadata": {
      "resolution": "2K"
    }
  }'
import requests

response = requests.post(
    "https://toapis.com/v1/images/generations",
    headers={
        "Authorization": "Bearer your-ToAPIs-key",
        "Content-Type": "application/json"
    },
    json={
        "model": "flux-2-flex",
        "prompt": "A cute orange cat sunbathing on a windowsill",
        "size": "1:1",
        "metadata": {
            "resolution": "1K"
        }
    }
)

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-2-pro",
        "prompt": "Keep character style, generate a scene of running in the forest",
        "size": "1:1",
        "image_urls": ["https://example.com/ref1.jpg"],
        "metadata": {
            "resolution": "2K"
        }
    }
)

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-2-flex',
    prompt: 'A cute orange cat sunbathing on a windowsill',
    size: '1:1',
    metadata: {
      resolution: '1K'
    }
  })
});

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-2-pro',
    prompt: 'Keep character style, generate a scene of running in the forest',
    size: '1:1',
    image_urls: ['https://example.com/ref1.jpg'],
    metadata: {
      resolution: '2K'
    }
  })
});

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-2-flex",
  "status": "queued",
  "progress": 0,
  "created_at": 1703884800,
  "metadata": {}
}