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

# OpenAI Image Generations

> Erzeuge ein Standardbild als Base64 mit einem Completion-API-Key.

Erzeuge mit `POST /openai/{region}/v1/images/generations` ein Standardbild. Sende einen Prompt und ein Bildmodell aus deinem Workspace. Die Antwort liefert das Bild als `b64_json`.

Die Anfrage nutzt denselben Completion-API-Scope wie [OpenAI Chat Completions](/de/developer/completion-api/openai) und [OpenAI Responses](/de/developer/completion-api/openai-responses). Chat-Tools, Workflow-Nodes und `imageGeneration` in der Agent API sind eigene Oberflächen.

## Bevor du startest

* **API-Key**: Erstelle einen [persönlichen API-Key](/de/using-langdock/account/personal-api-keys) oder frage deinen Workspace-Admin nach einem Workspace-API-Key mit dem Scope Completion API.

## Basis-URL

```
https://api.langdock.com/openai/{region}/v1/images/generations
```

<Warning>
  **Dedicated Deployments**

  Ersetze `api.langdock.com` durch `<your-deployment-url>/api/public` in allen Anfragen.
</Warning>

Der Pfadwert `{region}` muss `eu` oder `us` sein. Dieser Endpunkt akzeptiert kein `global`.

## Parameter

Der Request-Body ist ein striktes Objekt. Zusätzliche Felder führen zu `400`.

| Parameter | Beschreibung |
| - | - |
| `model` | Pflicht. Die Bildmodell-ID aus deinem Workspace. Sichtbare Bildmodelle in der Region der Anfrage mit einem API-Deployment werden akzeptiert. `GET /openai/{region}/v1/models` listet Chat-Modelle, keine Bildmodelle. Ein unbekanntes Modell liefert `400` mit den Bildmodell-IDs dieser Region. Gibt es in der Region keines, sagt das der `400`. |
| `prompt` | Pflicht. Die Bildbeschreibung. |
| `n` | Optional. Wenn du den Wert sendest, muss er `1` sein. |
| `size` | Optional. `auto` (Standard), `1024x1024`, `1536x1024` oder `1024x1536`. `auto` und `1024x1024` entsprechen quadratisch, `1536x1024` quer und `1024x1536` hochkant. |
| `quality` | Optional. `auto`, `low`, `medium` oder `high`. Langdock reicht den Wert an das Bildmodell weiter. Nicht jedes Bildmodell nutzt ihn. |
| `response_format` | Optional. Nur `b64_json`. |
| `user` | Optional. Wird für OpenAI-Kompatibilität akzeptiert. |

## Antwort

Eine erfolgreiche Antwort ist JSON mit `created` und `data`. `data` enthält ein Objekt mit `b64_json` und, wenn das Modell einen liefert, `revised_prompt`. Der HTTP-Body enthält kein `usage`-Objekt. Der Response-Header `ld-model-id` wiederholt die Modell-ID.

Die Generierung bricht nach 60 Sekunden ab. Ein Timeout liefert `504` mit `The model did not respond in time. Please retry.`

## Unterschiede zur OpenAI API

* Ein Bild pro Anfrage. Ein `n`-Wert ungleich `1` wird abgelehnt.
* `response_format` ist nur `b64_json`. URL-Ausgabe wird nicht unterstützt.
* HD- bzw. High-Resolution-Generierung wird nicht unterstützt.
* Es gibt keinen öffentlichen `/v1/images/edits`-Endpunkt.

## OpenAI-Python-Bibliothek verwenden

Lege Langdock als Basis-URL fest und verwende `images.generate`:

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://api.langdock.com/openai/eu/v1",
    api_key="<YOUR_LANGDOCK_API_KEY>",
)

image = client.images.generate(
    model="your-image-model-id",
    prompt="Ein Leuchtturm in der Dämmerung",
    size="1024x1024",
    response_format="b64_json",
)

print(image.data[0].b64_json)
```

## Rate Limits

Die Standardlimits sind **500 RPM** (Anfragen pro Minute) und **150.000 TPM** (Tokens pro Minute).

* RPM gilt pro Workspace, Modell und API-Key.
* TPM teilen sich alle API-Keys, die dasselbe Modell in einem Workspace nutzen.
* In Dedicated Deployments können Admins unter **Einstellungen > Workspace > Produkte > API** eigene Limits je Modell festlegen.

Bei einer Überschreitung erhältst du `429 Too Many Requests`. Erfolgreiche Antworten und Antworten mit Rate-Limit-Fehler enthalten die Response-Header `x-ratelimit-limit-requests`, `x-ratelimit-limit-tokens`, `x-ratelimit-remaining-requests` und `x-ratelimit-remaining-tokens`.

Die Nutzung persönlicher API-Keys zählt zusammen mit Chat- und Agenten-Nutzung zum effektiven persönlichen Budget des Mitglieds und zum Workspace-Ausgabenlimit. Die Nutzung von Workspace-API-Keys zählt zum API-Spend-Limit des Workspace. Bildgenerierungs-Aufrufe werden als Image-Generation-Nutzung abgerechnet. Siehe [Persönliche API-Keys](/de/using-langdock/account/personal-api-keys) und [Preise](/de/admin/billing/pricing#api).

<Info>
  Browser- und CORS-Integrationen werden nicht unterstützt. Bewahre API-Keys serverseitig auf und rufe den Endpunkt über einen Server, eine CLI oder ein lokales Entwicklungstool auf. Weitere Informationen findest du in den [Best Practices für API-Keys](/de/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices).
</Info>


## OpenAPI

````yaml POST /openai/{region}/v1/images/generations
openapi: 3.0.0
info:
  title: Langdock API
  version: 3.0.0
servers:
  - url: https://api.langdock.com
    description: Production
security:
  - bearerAuth: []
paths:
  /openai/{region}/v1/images/generations:
    post:
      tags:
        - Images
      summary: Generates one standard image as base64.
      description: >-
        Generates one standard-resolution image with a Completion API key.
        Returns b64_json only. Does not support n other than 1, URL output, HD,
        or image edits.
      operationId: createImage
      parameters:
        - name: region
          in: path
          required: true
          description: The region of the API to use. Must be eu or us.
          schema:
            type: string
            enum:
              - eu
              - us
            default: eu
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  minLength: 1
                  description: >-
                    Image generation model ID from your workspace. GET
                    /openai/{region}/v1/models lists chat models, not image
                    models.
                prompt:
                  type: string
                  minLength: 1
                  description: The image description.
                'n':
                  type: integer
                  enum:
                    - 1
                  description: Number of images. Only 1 is supported.
                size:
                  type: string
                  enum:
                    - auto
                    - 1024x1024
                    - 1536x1024
                    - 1024x1536
                  default: auto
                  description: >-
                    Output size. auto and 1024x1024 map to square, 1536x1024 to
                    landscape, and 1024x1536 to portrait.
                quality:
                  type: string
                  enum:
                    - auto
                    - low
                    - medium
                    - high
                  description: >-
                    Quality hint forwarded to the image model. Not every image
                    model uses it.
                response_format:
                  type: string
                  enum:
                    - b64_json
                  description: Response format. Only b64_json is supported.
                user:
                  type: string
                  description: >-
                    Optional end-user identifier. Accepted for OpenAI
                    compatibility.
            example:
              model: your-image-model-id
              prompt: A lighthouse at dusk
              'n': 1
              size: 1024x1024
              response_format: b64_json
      responses:
        '200':
          description: OK
          headers:
            ld-model-id:
              description: The image model ID used for the request.
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                required:
                  - created
                  - data
                properties:
                  created:
                    type: integer
                    description: Unix timestamp in seconds.
                  data:
                    type: array
                    minItems: 1
                    maxItems: 1
                    items:
                      type: object
                      required:
                        - b64_json
                      properties:
                        b64_json:
                          type: string
                          description: Base64-encoded image.
                        revised_prompt:
                          type: string
                          description: Revised prompt when the model returns one.
              example:
                created: 1721722200
                data:
                  - b64_json: >-
                      iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==
                    revised_prompt: A coastal lighthouse at dusk, warm lantern light.
        '400':
          description: >-
            Invalid fields, an unavailable image model, or no image models in
            the region.
        '401':
          description: Missing, invalid, or expired API key.
        '403':
          description: API key without the Completion API scope.
        '429':
          description: Usage or rate limit exceeded.
        '500':
          description: Internal server or upstream provider error.
        '504':
          description: The model did not respond in time. Please retry.
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````

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