> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Flux 2 Flex

> Flux 2 Flex from Black Forest Labs gives you control over the quality-speed trade-off when generating images. Unlike typical text-to-image models that make these decisions for you, Flex lets you adjust how many steps to run and how strongly the model should follow your prompt.

## Query Task Status

After submitting a task, use the unified query endpoint to check progress and retrieve results:

<Card title="Get Task Info" icon="magnifying-glass" href="/models/common/get-task-info">
  Learn how to query task status and retrieve generation results
</Card>

<Tip>
  For production use, we recommend using the `callback_url` parameter to receive automatic notifications when generation completes, rather than polling the status endpoint.
</Tip>

## Related Resources

<CardGroup cols={2}>
  <Card title="Models Overview" icon="store" href="/models/quickstart">
    Explore all available models
  </Card>

  <Card title="Common API" icon="gear" href="/common-api/get-account-credits">
    Check credits and account usage
  </Card>
</CardGroup>


## OpenAPI

````yaml models/flux/flux-2-flex.json post /api/v1/client/job/CreateTask
openapi: 3.0.0
info:
  title: Crun Flux 2 Flex API
  description: crun.ai Flux 2 Flex API Documentation
  version: 1.0.0
  contact:
    name: Technical Support
    email: support@crun.ai
servers:
  - url: https://api.crun.ai
    description: API Server
security:
  - ApiKeyAuth: []
paths:
  /api/v1/client/job/CreateTask:
    post:
      summary: flux 2 flex image generation or editing.
      operationId: flux-2-flex
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  enum:
                    - flux-2-flex
                  description: |-
                    The model name to use for generation. Required field.

                    - Must be `flux-2-flex` for this endpoint
                callback_url:
                  type: string
                  format: uri
                  description: >-
                    Optional. Callback URL for receiving task completion
                    notifications.


                    - System will POST task status and results to this URL when
                    generation completes

                    - Callback payloads structure is consistent with the `data`
                    object returned by the task status query

                    - Your callback endpoint should accept POST requests with
                    JSON payload containing results

                    - It returns an HTTP 200 status code upon successful receipt
                  example: https://your-domain.com/api/callback
                input:
                  type: object
                  description: >-
                    Input parameters for the Flux 2 Flex model, offering
                    granular control over inference steps, guidance, and
                    multi-image referencing.
                  properties:
                    prompt:
                      type: string
                      description: Text prompt for image generation.
                      minLength: 1
                      maxLength: 5000
                      example: >-
                        A surreal painting of a clock melting over a futuristic
                        city skyline, vibrant sunset colors.
                    img_urls:
                      type: array
                      description: >-
                        List of input image URLs for image-to-image generation.
                        Supports up to 10 images (overriding the standard 8).
                      items:
                        type: string
                        format: uri
                      maxItems: 10
                      example:
                        - https://example.com/ref-1.jpg
                        - https://example.com/ref-2.jpg
                    prompt_upsampling:
                      type: boolean
                      description: >-
                        If true, the model will automatically refine and expand
                        your prompt for more creative results.
                      default: false
                      example: true
                    steps:
                      type: integer
                      description: >-
                        Number of inference steps. Higher values can improve
                        detail but take longer.
                      minimum: 1
                      maximum: 50
                      default: 30
                      example: 40
                    guidance:
                      type: number
                      description: >-
                        Guidance scale. Controls how strictly the model follows
                        the prompt vs. its own creativity.
                      minimum: 1.5
                      maximum: 10
                      default: 4.5
                      example: 7.5
                    aspect_ratio:
                      type: string
                      description: Aspect ratio of the generated image.
                      enum:
                        - '1:1'
                        - '2:3'
                        - '3:2'
                        - '3:4'
                        - '4:3'
                        - '4:5'
                        - '5:4'
                        - '9:16'
                        - '16:9'
                        - match_input_image
                      default: match_input_image
                      example: '16:9'
                    resolution:
                      type: string
                      description: >-
                        Resolution in megapixels. Up to 4 MP is possible, but 2
                        MP or below is recommended. The maximum image size is
                        2048x2048, which means that high-resolution images may
                        not respect the resolution if aspect ratio is not 1:1.
                      enum:
                        - 1K
                        - 2K
                        - 4K
                      default: 1K
                    safety_tolerance:
                      type: integer
                      description: Safety filter sensitivity (1-5).
                      minimum: 1
                      maximum: 5
                      default: 2
                    seed:
                      type: integer
                      description: Random seed for generation.
                    output_format:
                      type: string
                      enum:
                        - png
                        - jpg
                        - webp
                      default: webp
                    output_quality:
                      type: integer
                      description: >-
                        Quality when saving the output images, from 0 to 100.
                        100 is best quality, 0 is lowest quality. Not relevant
                        for `png` outputs
                      minimum: 0
                      maximum: 100
                      default: 80
                  required:
                    - prompt
            example:
              model: replicate/flux-2-flex
              callback_url: https://your-domain.com/api/callback
              input:
                prompt: >-
                  An ethereal forest with glowing flora, captured in a macro
                  photography style.
                img_urls:
                  - https://example.com/macro_reference.png
                prompt_upsampling: true
                steps: 40
                guidance: 6
                aspect_ratio: '4:3'
                resolution: 2K
                output_format: png
      responses:
        '200':
          description: Request successful
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          task_id:
                            type: string
                            description: >-
                              Task ID, can be used with Get Task Details
                              endpoint to query task status
                            example: task_12345678
              example:
                code: 200
                message: success
                data:
                  task_id: task_12345678
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      errors:
                        type: array
                        description: Detailed validation error messages
                        items:
                          type: string
                        example:
                          - specific error field message
              example:
                code: 422
                message: Missing Params or Type Error
                errors:
                  - specific error field message
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 200
            - 401
            - 402
            - 404
            - 422
            - 429
            - 455
            - 500
            - 501
            - 505
          description: >-
            Response status code


            - **200**: Success - Request has been processed successfully

            - **401**: Unauthorized - Authentication credentials are missing or
            invalid

            - **402**: Insufficient Credits - Account does not have enough
            credits to perform the operation

            - **404**: Not Found - The requested resource or endpoint does not
            exist

            - **422**: Validation Error - The request parameters failed
            validation checks

            - **429**: Rate Limited - Request limit has been exceeded for this
            resource

            - **455**: Service Unavailable - System is currently undergoing
            maintenance

            - **500**: Server Error - An unexpected error occurred while
            processing the request

            - **501**: Generation Failed - Content generation task failed

            - **505**: Feature Disabled - The requested feature is currently
            disabled
        message:
          type: string
          description: Response message, error description when failed
          example: success
  responses:
    Error:
      description: Server Error
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        All APIs require authentication via API Key.


        Get API Key:

        1. Visit [API Key Management Page](https://crun.ai/user-api-key) to get
        your API Key


        Usage:

        Add to request header:


        x-api-key: YOUR_API_KEY


        Note:

        - Keep your API Key secure and do not share it with others

        - If you suspect your API Key has been compromised, reset it immediately
        in the management page

````