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

# Midjourney Submit Imagine

> Use DeerAPI to call the Midjourney Submit Imagine endpoint with request details, response details, examples, and an OpenAPI playground.

## Overview

Use this endpoint to call the Midjourney Submit Imagine workflow through DeerAPI. The API reference on this page shows the request schema, response schema, authentication requirements, and runnable examples for the configured endpoint.

## Before you start

Use the DeerAPI base URL and pass your API Key in the `Authorization` header:

```text theme={null}
https://api.deerapi.com
```

```text theme={null}
Authorization: Bearer $DEERAPI_KEY
```

## Model selection

Choose a current model ID from the [live pricing page](https://api.deerapi.com/pricing). Model availability changes over time, so avoid copying a model ID from an old project without checking the live list first.

## Implementation notes

* Use the OpenAPI playground for the exact request fields accepted by this endpoint.
* Keep API Keys on the server side when you build production applications.
* Log the request ID from failed calls so support can investigate the request.
* Retry `429`, `500`, and `503` responses with exponential backoff.


## OpenAPI

````yaml /api/openapi/image/midjourney/post-submit-imagine.openapi.json POST /mj/submit/imagine
openapi: 3.1.0
info:
  title: Imagine API
  version: 1.0.0
  description: >-
    Create a Midjourney imagine task through DeerAPI and receive a task id for
    later polling.
servers:
  - url: https://api.deerapi.com
security:
  - bearerAuth: []
paths:
  /mj/submit/imagine:
    post:
      summary: Create a Midjourney imagine task
      description: >-
        Submit the primary Midjourney generation request. Poll the returned task
        id with the fetch endpoint until the task reaches a terminal state.
      operationId: imagine
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - prompt
              properties:
                botType:
                  type: string
                  description: >-
                    Bot type to use. `MID_JOURNEY` for Midjourney (default),
                    `NIJI_JOURNEY` for Niji.
                  default: MID_JOURNEY
                  enum:
                    - MID_JOURNEY
                    - NIJI_JOURNEY
                prompt:
                  type: string
                  description: >-
                    Text prompt for the generation. Supports standard Midjourney
                    parameters such as `--v`, `--ar`, `--stylize`, etc.
                  example: a paper boat floating on calm water at sunrise --v 6.1
                accountFilter:
                  type: object
                  description: >-
                    Filter which Midjourney account modes may be used for this
                    task.
                  properties:
                    modes:
                      type: array
                      description: Allowed speed modes, e.g. `FAST`, `RELAX`, or `TURBO`.
                      items:
                        type: string
                base64Array:
                  type: array
                  description: >-
                    Base64-encoded reference images. Each item should be a data
                    URI such as `data:image/png;base64,xxx`.
                  items:
                    type: string
                state:
                  type: string
                  description: >-
                    Custom state string. Returned as-is in the task result and
                    webhook callback for your own tracking.
              default:
                botType: MID_JOURNEY
                prompt: a paper boat floating on calm water at sunrise --v 6.1
                accountFilter:
                  modes:
                    - FAST
            example:
              botType: MID_JOURNEY
              prompt: a paper boat floating on calm water at sunrise --v 6.1
              accountFilter:
                modes:
                  - FAST
            examples:
              Default:
                summary: Default request
                value:
                  botType: MID_JOURNEY
                  prompt: a paper boat floating on calm water at sunrise --v 6.1
                  accountFilter:
                    modes:
                      - FAST
      responses:
        '200':
          description: Task accepted.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - description
                  - result
                properties:
                  code:
                    type: integer
                  description:
                    type: string
                  properties:
                    type: object
                    properties:
                      discordChannelId:
                        type: string
                      discordInstanceId:
                        type: string
                  result:
                    type: string
                    description: Task id returned after submission.
                example:
                  code: 1
                  description: Use this field according to the endpoint schema.
                  result: '1773314942177684'
                  properties:
                    discordChannelId: 5e6ca8e1f40e4de6
                    discordInstanceId: 5e6ca8e1f40e4de6
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |
            curl https://api.deerapi.com/mj/submit/imagine \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $DEERAPI_KEY" \
              -d '{
                "botType": "MID_JOURNEY",
                "prompt": "a paper boat floating on calm water at sunrise --v 6.1",
                "accountFilter": {
                  "modes": [
                    "FAST"
                  ]
                }
              }'
        - lang: Python
          label: requests
          source: |
            import os
            import requests

            url = "https://api.deerapi.com/mj/submit/imagine"
            headers = {
                "Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
                "Content-Type": "application/json",
            }
            payload = {
              "botType": "MID_JOURNEY",
              "prompt": "a paper boat floating on calm water at sunrise --v 6.1",
              "accountFilter": {
                "modes": [
                  "FAST"
                ]
              }
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())
        - lang: JavaScript
          label: fetch
          source: >
            const response = await
            fetch("https://api.deerapi.com/mj/submit/imagine", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "botType": "MID_JOURNEY",
                "prompt": "a paper boat floating on calm water at sunrise --v 6.1",
                "accountFilter": {
                  "modes": [
                    "FAST"
                  ]
                }
              }),
            });


            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use a DeerAPI API Key as a Bearer token.

````