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

# Qwen

> Qwen on Magnific API v2: what it takes and how to call it.

```bash cURL theme={null}
curl --request POST \
  --url https://api.magnific.com/v2/images/generate/qwen \
  --header 'Content-Type: application/json' \
  --header 'x-magnific-api-key: <api-key>' \
  --data '
{
  "prompt": "A product shot of a red sneaker on white marble",
  "aspect_ratio": "16:9",
  "webhook_url": "https://www.example.com/webhook"
}
'
```

```python Python theme={null}
import requests

response = requests.post(
    "https://api.magnific.com/v2/images/generate/qwen",
    headers={"x-magnific-api-key": "<api-key>"},
    json={
        "prompt": "A product shot of a red sneaker on white marble",
        "aspect_ratio": "16:9",
        "webhook_url": "https://www.example.com/webhook"
    },
)
print(response.json())
```

```javascript JavaScript theme={null}
const response = await fetch("https://api.magnific.com/v2/images/generate/qwen", {
  method: "POST",
  headers: { "Content-Type": "application/json", "x-magnific-api-key": "<api-key>" },
  body: JSON.stringify({
    "prompt": "A product shot of a red sneaker on white marble",
    "aspect_ratio": "16:9",
    "webhook_url": "https://www.example.com/webhook"
  }),
});
console.log(await response.json());
```

```json 202 Queued theme={null}
{
  "data": [
    {
      "creation_id": "ab12CdE",
      "status": "queued"
    }
  ],
  "meta": {}
}
```

```json 422 Validation failed theme={null}
{
  "code": "validation_failed",
  "message": "The selected resolution is invalid.",
  "details": {
    "errors": {
      "resolution": [
        "The selected resolution is invalid."
      ]
    }
  },
  "request_id": "ak-0123abcd"
}
```


## OpenAPI

````yaml openapi/magnific-api-v2-projects-openapi.yaml POST /v2/images/generate/qwen
openapi: 3.1.0
info:
  title: Magnific API v2 — Projects, uploads, generation, generations and library
  version: 2.0.0
  description: >-
    Projects and folders, uploads, image, video and audio generation,
    generations and the library of the Magnific API v2.
servers:
  - url: https://api.magnific.com
    description: Production V2
security:
  - magnificApiKey: []
  - bearerAuth: []
tags:
  - name: Projects
    description: >-
      Your projects and the folders inside them: list, create, rename, archive
      and delete them, and manage who has access.
  - name: Library
    description: >-
      Reusable characters, styles, products and locations to reference when you
      generate.
  - name: Videos
    description: >-
      Generate and edit videos. Add `?dry_run=true` to get the price of a
      request first.
  - name: Images
    description: Generate images and edit your image creations.
  - name: Creations
    description: >-
      What your generations, edits and uploads produced: read, list, rename,
      move, trash and download them.
  - name: Tags
    description: A project's review statuses and labels, and their assignment to creations.
  - name: Uploads
    description: >-
      Your own files as creations: upload them, import them from a URL, or save
      a stock item.
  - name: Flows
    description: >-
      Multi-step workflows saved from a Space: list them, read their inputs and
      run them.
  - name: Audio
    description: 'Generate and edit audio: voiceovers, music and sound effects.'
  - name: Brandkits
    description: >-
      Your brand kits: colours, fonts, logos, rules, documents and templates,
      and the creations made with them.
  - name: Search
    description: Search your creations across your workspace.
  - name: Account
    description: >-
      The account a request is paid with: its plan, available credits, profile
      and permissions.
paths:
  /v2/images/generate/qwen:
    post:
      tags:
        - Images
      summary: Qwen
      description: >-
        Generates images from a prompt, or reworks the images you pass in
        `references`. Name the model by

        its `slug`, its API v1 name, or `auto`. Returns before rendering: follow
        each image with

        `GET /v2/creations/{creation_id}` or a `webhook_url`.


        A personal token needs `api:write`.
      operationId: public-api.images.generate.qwen
      parameters:
        - name: dry_run
          in: query
          description: >-
            `true` returns the price of the request instead of running it.
            Nothing is charged or created.
          schema:
            type: boolean
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateImages_qwen'
            example:
              prompt: A product shot of a red sneaker on white marble
              aspect_ratio: '16:9'
      responses:
        '200':
          description: >-
            With `dry_run=true`: what the request would cost. Nothing is charged
            or created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      credits:
                        type: number
                        description: >-
                          Credits the call would cost. Absent when it cannot be
                          priced: `reason` says why.
                      certainty:
                        type: string
                        description: '`exact`, `estimate` or `unsupported`.'
                      can_afford:
                        type: boolean
                        description: Whether the credits available cover it.
                      credits_available:
                        type: number
                        description: Credits available where the call would run.
                      reason:
                        type: string
                        description: >-
                          Why the price is what it is, or why it cannot be
                          given.
                      details:
                        type: object
                        description: >-
                          What the price is based on: model, resolution,
                          duration, who pays...
                    required:
                      - details
                required:
                  - data
        '202':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: >-
                      One per image, in order. Follow each with `GET
                      /v2/creations/{creation_id}`.
                    items:
                      type: object
                      properties:
                        creation_id:
                          type: string
                          examples:
                            - ab12CdE
                        status:
                          type: string
                          description: Where the creation stands.
                          enum:
                            - queued
                            - processing
                            - completed
                            - failed
                        kind:
                          type: string
                          description: '`video` for a video; absent otherwise.'
                          enum:
                            - video
                        url:
                          type: string
                          description: >-
                            The result, once completed. For a video it may be a
                            preview: `GET /v2/creations/{creation_id}/download`
                            returns the original file.
                        thumbnail_url:
                          type: string
                        preview_url:
                          type: string
                        created_at:
                          type: string
                          format: date-time
                        title:
                          type: string
                          description: The creation's name.
                        folder_reference:
                          type: string
                          description: The `reference` of the project or folder it is in.
                        tags:
                          type: array
                          description: >-
                            The names of its tags in its project. Only in `GET
                            /v2/creations/{creation_id}`.
                          items:
                            type: string
                        review_status:
                          type: string
                          description: >-
                            Its review status in its project (`Approved`, `In
                            review`… or a custom one). Only in `GET
                            /v2/creations/{creation_id}`.
                        comments_count:
                          type: integer
                          description: >-
                            How many comments it has. Only in `GET
                            /v2/creations/{creation_id}`, for a creation in a
                            project.
                        tiles:
                          type: array
                          description: >-
                            For a Magnific One draft grid (`mode: draft`): the
                            `creation_id` of each tile, in reading order. Only
                            in `GET /v2/creations/{creation_id}`.
                          items:
                            type: string
                      required:
                        - creation_id
                        - status
                  meta:
                    type: object
                    properties:
                      adjustments:
                        type: array
                        description: Values changed to fit the model.
                        items:
                          type: object
                          properties:
                            field:
                              type: string
                              examples:
                                - aspectRatio
                            from:
                              type: string
                            to:
                              type: string
                            reason:
                              type: string
                          required:
                            - field
                            - from
                            - to
                            - reason
                      partial_failure:
                        type: object
                        description: Present when fewer images than `count` were queued.
                        properties:
                          failed_at:
                            type: integer
                            description: >-
                              Zero-based position of the first image that was
                              not queued.
                          code:
                            type: string
                            description: '`insufficient_credits` or `generation_failed`.'
                          message:
                            type: string
                          required_credits:
                            type: integer
                          available_credits:
                            type: integer
                        required:
                          - failed_at
                          - code
                          - message
                required:
                  - data
                  - meta
        '401':
          description: >-
            `unauthenticated`: the token or API key is missing, expired or
            invalid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '402':
          description: >-
            `insufficient_credits`: not enough credits. `details` has
            `required_credits` and `available_credits`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                      required_credits:
                        type: number
                        description: 'For `insufficient_credits`: what the request costs.'
                      available_credits:
                        type: number
                        description: 'For `insufficient_credits`: what you can spend now.'
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '403':
          description: >-
            `forbidden`, or a more specific code such as `insufficient_scope`:
            your token, role, plan or organization does not allow it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                      required_scope:
                        type: string
                        description: 'For `insufficient_scope`: the scope the token needs.'
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '404':
          description: '`not_found`: it does not exist, or you cannot see it.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '422':
          description: >-
            `validation_failed`: `details.errors` lists the problems by field.
            `unsupported_by_model`: `details.violations` lists the values the
            model does not accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '428':
          description: >-
            `tool_not_available`: your organization's admin switched this tool
            or model off. `details` has `tool` and `mode`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    properties:
                      tool:
                        type: string
                      mode:
                        type: string
                        description: The model.
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '429':
          description: >-
            `rate_limited`, or the limit reached, such as
            `upload_quota_exceeded`. Retry after the `Retry-After` header, in
            seconds.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '451':
          description: >-
            Moderation blocked the prompt and nothing was generated. `details`
            flags the categories.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: The moderation categories that flagged the prompt.
                    additionalProperties: true
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '457':
          description: >-
            `user_banned`: your account is banned from generating. `details` has
            `ban_type` and `reason`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserBannedError'
        '500':
          description: >-
            `server_error`: an unexpected error. Share `request_id` with
            support.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
        '503':
          description: >-
            `service_unavailable`: temporarily unavailable. Retry after the
            `Retry-After` header, in seconds.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: >-
                      A stable error code, such as `validation_failed`,
                      `insufficient_credits`, `not_found` or `rate_limited`.
                    examples:
                      - validation_failed
                  message:
                    type: string
                    description: A human-readable message.
                  details:
                    type: object
                    description: More detail about the error, when there is any.
                    properties:
                      errors:
                        type: object
                        description: >-
                          Validation messages by field, such as `resolution`;
                          under `request` for the request as a whole.
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      violations:
                        type: array
                        description: >-
                          Each value the model does not accept, with the values
                          it accepts.
                        items:
                          type: object
                          properties:
                            model:
                              type: string
                              description: The model slug.
                            field:
                              type: string
                              description: >-
                                The field: `resolution`, `aspect_ratio`,
                                `duration`, `multi_prompt`, `references`...
                            message:
                              type: string
                            allowed:
                              type: array
                              description: The values the model takes, when it lists them.
                              items:
                                type: string
                            max:
                              type: number
                              description: The highest value the model takes, for a limit.
                          required:
                            - model
                            - field
                            - message
                  request_id:
                    type: string
                    description: The request id, to share with support.
                required:
                  - code
                  - message
      security:
        - magnificApiKey: []
        - bearerAuth: []
components:
  schemas:
    GenerateImages_qwen:
      type: object
      title: GenerateImagesApiRequest
      properties:
        prompt:
          type: string
          description: What to generate. With image references, also how to change them.
          maxLength: 10000
        aspect_ratio:
          type: string
          description: >-
            Default: `auto`, picked from the prompt and the references. A ratio
            the model lacks is snapped to its nearest.
          enum:
            - auto
            - '1:1'
            - '16:9'
            - '9:16'
            - '4:3'
            - '3:4'
            - '3:2'
            - '2:3'
            - '1:2'
            - '2:1'
            - '4:5'
        count:
          type: integer
          description: How many images. Each one is charged.
          minimum: 1
          maximum: 8
        seed:
          type: integer
          description: >-
            Replays a result. Each image of a batch takes the next seed. `-1`: a
            random one.
          minimum: -1
          maximum: 4294967295
        references:
          type: array
          description: >-
            Images to rework or follow, up to 12. The reference types and how
            many of each depend on the model.
          items:
            type: object
            properties:
              type:
                type: string
                description: >-
                  `image` (a `creation_id`, `url` or `base64`), `character`,
                  `product`, `locations` (a library `id`), or `style` (either a
                  `creation_id` or an `id`).
                enum:
                  - image
                  - style
                  - character
                  - product
                  - locations
              creation_id:
                type:
                  - string
                  - 'null'
                description: >-
                  One of your creations, by its `creation_id`: an `image` or a
                  `style` reference.
                maxLength: 128
              id:
                type:
                  - string
                  - 'null'
                description: >-
                  A library asset, by its numeric `id` from `GET /v2/library`: a
                  `character`, `product`, `locations` or `style` reference.
                maxLength: 128
              url:
                type:
                  - string
                  - 'null'
                description: >-
                  An `image` reference only: a public HTTPS URL, saved as one of
                  your creations. At most 6 `url` or `base64` images per
                  request.
                maxLength: 2048
              base64:
                type:
                  - string
                  - 'null'
                description: >-
                  An `image` reference only: JPEG, PNG or WebP as base64, bare
                  or as a `data:image/...;base64,` URI, up to 10 MB decoded.
                maxLength: 14500000
            required:
              - type
          maxItems: 12
        webhook_url:
          type: string
          format: uri
          description: >-
            A URL called once per creation when it completes or fails, signed
            with your API key's webhook secret. API keys only.
          maxLength: 512
        title:
          type:
            - string
            - 'null'
          description: 'The name of the creations. Default: a title made from the prompt.'
          maxLength: 120
        folder_reference:
          type: string
          description: >-
            The `reference` of the project or folder to save the result in.
            Default: your Personal project.
          maxLength: 64
      required:
        - prompt
    UserBannedError:
      type: object
      description: '`user_banned`: the account is banned from generating.'
      properties:
        code:
          type: string
          enum:
            - user_banned
        message:
          type: string
          description: A human-readable message.
        details:
          type: object
          properties:
            ban_type:
              type: string
              description: The ban, such as `full_generation`.
            reason:
              type: string
              description: Why the account was banned.
        request_id:
          type: string
          description: The request id, to share with support.
      required:
        - code
        - message
  securitySchemes:
    magnificApiKey:
      type: apiKey
      in: header
      name: x-magnific-api-key
      description: >-
        Your Magnific API key. [Learn how to obtain an API
        key](https://docs.magnific.com/quickstart)
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        A personal access token, sent as `Authorization: Bearer <token>`. [How
        to get one](/api-reference/v2/overview#get-a-personal-access-token)

````

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