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

# Create generation

> Submits a media generation for a selected model.



## OpenAPI

````yaml /hub/openapi/hub.json post /api/v1/hub/generations
openapi: 3.0.1
info:
  title: Fanify Hub API
  description: Generate media and text with Fanify credits. All prices use EUR.
  version: v1
servers:
  - url: https://fanifyai.com
security: []
paths:
  /api/v1/hub/generations:
    post:
      tags:
        - Generations
      summary: Create generation
      description: Submits a media generation for a selected model.
      parameters:
        - name: Idempotency-Key
          in: header
          description: Idempotency key. Required for FanifyServer clients.
          schema:
            type: string
      requestBody:
        description: Generation request
        content:
          application/json:
            schema:
              required:
                - model
                - input
              type: object
              properties:
                model:
                  type: string
                input:
                  type: object
              additionalProperties: false
            example:
              model: nano-banana-2
              input:
                prompt: a cat
                resolution: 2K
                aspect_ratio: '16:9'
        required: true
      responses:
        '200':
          description: Completed idempotent replay.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubGenerationDto'
              example:
                id: 0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11
                model: nano-banana-2
                is_llm: false
                status: succeeded
                input:
                  prompt: a cat
                  aspect_ratio: '16:9'
                  resolution: 2K
                  image_input:
                    - https://host/cdn/a.png
                estimated_cost: 0.04
                billed_cost: 0.04
                currency: EUR
                outputs:
                  - index: 0
                    media_type: image/png
                    url: >-
                      https://fanifyai.com/api/v1/hub/files/8Jd2kQ7pR1sT4uV6wX9yZ0aB2cD4eF6gH8iJ0kL2mN4
                    size: 812345
                    expires_at: '2026-09-14T10:00:31Z'
                error: null
                missing: []
                created_at: '2026-09-07T10:00:00Z'
                started_at: '2026-09-07T10:00:01Z'
                completed_at: '2026-09-07T10:00:31Z'
        '201':
          description: Generation accepted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubGenerationDto'
              example:
                id: 0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11
                model: nano-banana-2
                is_llm: false
                status: queued
                input:
                  prompt: a cat
                  aspect_ratio: '16:9'
                  resolution: 2K
                estimated_cost: 0.04
                billed_cost: null
                currency: EUR
                outputs: []
                error: null
                missing: []
                created_at: '2026-09-07T10:00:00Z'
                started_at: null
                completed_at: null
        '400':
          description: Invalid input
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - invalid_input
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#invalid_input
                title: Invalid input
                status: 400
                code: invalid_input
        '401':
          description: Unauthorized
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - unauthorized
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#unauthorized
                title: Unauthorized
                status: 401
                code: unauthorized
        '402':
          description: Insufficient credits
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - insufficient_credits
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#insufficient_credits
                title: Insufficient credits
                status: 402
                code: insufficient_credits
                detail: Your available balance does not cover this generation.
                instance: /api/v1/hub/generations
        '404':
          description: Model not found
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - model_not_found
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#model_not_found
                title: Model not found
                status: 404
                code: model_not_found
        '422':
          description: No route available
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - no_route_available
                      - idempotency_conflict
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#no_route_available
                title: No route available
                status: 422
                code: no_route_available
        '429':
          description: Rate limit reached
          headers:
            Retry-After:
              description: Seconds before retrying.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - rate_limited
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#rate_limited
                title: Rate limit reached
                status: 429
                code: rate_limited
        '503':
          description: Generation in progress
          headers:
            Retry-After:
              description: Always 5 seconds for an in-progress replay.
              schema:
                type: string
          content:
            application/problem+json:
              schema:
                required:
                  - type
                  - title
                  - status
                  - code
                type: object
                properties:
                  type:
                    type: string
                    format: uri
                  title:
                    type: string
                  status:
                    type: integer
                    format: int32
                  detail:
                    type: string
                    nullable: true
                  instance:
                    type: string
                  code:
                    enum:
                      - generation_in_progress
                    type: string
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                  unrepresentable:
                    type: array
                    items:
                      type: string
              example:
                type: https://fanifyai.com/docs/hub/errors#generation_in_progress
                title: Generation in progress
                status: 503
                code: generation_in_progress
      security:
        - Bearer: []
components:
  schemas:
    HubGenerationDto:
      required:
        - billed_cost
        - completed_at
        - created_at
        - currency
        - error
        - estimated_cost
        - id
        - input
        - is_llm
        - missing
        - model
        - outputs
        - started_at
        - status
      type: object
      properties:
        id:
          type: string
          format: uuid
        model:
          type: string
        is_llm:
          type: boolean
        status:
          enum:
            - queued
            - running
            - succeeded
            - failed
            - canceled
            - awaiting_supply
          type: string
        input:
          type: object
          nullable: true
        estimated_cost:
          type: number
          format: double
        billed_cost:
          type: number
          format: double
          nullable: true
        currency:
          enum:
            - EUR
          type: string
        outputs:
          type: array
          items:
            $ref: '#/components/schemas/HubOutputDto'
        error:
          allOf:
            - $ref: '#/components/schemas/HubErrorDto'
          nullable: true
        missing:
          type: array
          items:
            type: string
        created_at:
          type: string
          format: date-time
        started_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
      additionalProperties: false
    HubOutputDto:
      required:
        - index
      type: object
      properties:
        index:
          type: integer
          format: int32
        media_type:
          type: string
          nullable: true
        url:
          type: string
          nullable: true
        size:
          type: integer
          format: int64
          nullable: true
        expires_at:
          type: string
          format: date-time
          nullable: true
        data:
          type: object
          nullable: true
      additionalProperties: false
    HubErrorDto:
      required:
        - code
        - message
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      additionalProperties: false
  securitySchemes:
    Bearer:
      type: http
      description: Fanify API key.
      scheme: bearer
      bearerFormat: fanify_sk_...

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.