> ## 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.

# Generate

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

## Overview

Use this endpoint to call the Generate 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/openai/post-images.openapi.json POST /v1/images/generations
openapi: 3.1.0
info:
  title: Images API
  version: 1.0.0
  description: >-
    Create images through the OpenAI-compatible DeerAPI image generation route.
    Request parameters vary by model. For the latest model-specific controls,
    refer to the OpenAI image generation guide:
    https://developers.openai.com/api/docs/guides/image-generation
servers:
  - url: https://api.deerapi.com
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      summary: Create images
      description: >-
        Generate images from a text prompt using OpenAI-compatible request
        shapes on DeerAPI. For the latest model-specific output controls and
        parameter support, refer to the OpenAI image generation guide:
        https://developers.openai.com/api/docs/guides/image-generation
      operationId: images
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  description: >-
                    The image generation model to use. Choose a current model
                    from the [Models page](https://api.deerapi.com/pricing).
                  default: dall-e-3
                prompt:
                  type: string
                  description: Text description of the image you want to generate.
                  example: A paper boat floating on calm water at sunrise.
                'n':
                  type: integer
                  description: >-
                    Number of images to generate. Keep this at 1 for the
                    broadest compatibility.
                  default: 1
                quality:
                  type: string
                  description: >-
                    Quality setting for models that support it. See the OpenAI
                    image generation guide for the latest model-specific values.
                size:
                  type: string
                  description: >-
                    Requested output size. Supported values depend on the
                    selected model. See the OpenAI image generation guide for
                    the latest model-specific ranges.
                  example: 1024x1024
                response_format:
                  type: string
                  description: >-
                    The response container for `dall-e-2` and `dall-e-3`. This
                    parameter is not supported for GPT image models, which
                    return base64-encoded image data.
                  enum:
                    - url
                    - b64_json
                output_format:
                  type: string
                  description: >-
                    The encoded image type for GPT image model results, such as
                    `png`, `jpeg`, or `webp`. See the OpenAI image generation
                    guide for current GPT image output controls.
                  example: jpeg
              default:
                model: dall-e-3
                prompt: A paper boat floating on calm water at sunrise.
                'n': 1
                size: 1024x1024
                response_format: url
            examples:
              GPT request:
                summary: GPT request
                value:
                  model: gpt-image-2
                  prompt: A paper boat floating on calm water at sunrise.
                  quality: low
                  size: 1024x1024
                  output_format: jpeg
              DALL request:
                summary: DALL request
                value:
                  model: dall-e-3
                  prompt: A paper boat floating on calm water at sunrise.
                  response_format: url
                  size: 1024x1024
            example:
              model: gpt-image-2
              prompt: A paper boat floating on calm water at sunrise.
              quality: low
              size: 1024x1024
              output_format: jpeg
      responses:
        '200':
          description: Image generation result.
          content:
            application/json:
              schema:
                type: object
                required:
                  - created
                  - data
                  - usage
                properties:
                  created:
                    type: integer
                    description: Unix timestamp for the completed generation.
                  background:
                    type: string
                    description: Background mode returned by models that expose it.
                  output_format:
                    type: string
                    description: Encoded image type returned by GPT image models.
                  quality:
                    type: string
                    description: Quality level returned by models that expose it.
                  size:
                    type: string
                    description: Output size returned by models that expose it.
                  usage:
                    type: object
                    properties:
                      input_tokens:
                        type: integer
                      output_tokens:
                        type: integer
                      total_tokens:
                        type: integer
                      input_tokens_details:
                        type: object
                        properties:
                          image_tokens:
                            type: integer
                          text_tokens:
                            type: integer
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                          description: >-
                            Temporary image URL when the selected model supports
                            URL output.
                        b64_json:
                          type: string
                          description: >-
                            Base64-encoded image payload for models that return
                            inline content.
                        revised_prompt:
                          type: string
                          description: Provider-rewritten prompt, when available.
                example:
                  created: 1776841943
                  background: opaque
                  output_format: jpeg
                  quality: low
                  size: 1024x1024
                  usage:
                    input_tokens: 16
                    input_tokens_details:
                      image_tokens: 0
                      text_tokens: 16
                    output_tokens: 208
                    total_tokens: 224
                  data:
                    - b64_json: <base64-image-data>
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |
            curl https://api.deerapi.com/v1/images/generations \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $DEERAPI_KEY" \
              -d '{
                "model": "gpt-image-2",
                "prompt": "A paper boat floating on calm water at sunrise.",
                "quality": "low",
                "size": "1024x1024",
                "output_format": "jpeg"
              }'
        - lang: Python
          label: requests
          source: |
            import os
            import requests

            url = "https://api.deerapi.com/v1/images/generations"
            headers = {
                "Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
                "Content-Type": "application/json",
            }
            payload = {
              "model": "gpt-image-2",
              "prompt": "A paper boat floating on calm water at sunrise.",
              "quality": "low",
              "size": "1024x1024",
              "output_format": "jpeg"
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())
        - lang: JavaScript
          label: fetch
          source: >
            const response = await
            fetch("https://api.deerapi.com/v1/images/generations", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "model": "gpt-image-2",
                "prompt": "A paper boat floating on calm water at sunrise.",
                "quality": "low",
                "size": "1024x1024",
                "output_format": "jpeg"
              }),
            });


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

````