> ## 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 Responses API

> Erstelle zustandslose Modellantworten für Codex, SDKs und andere OpenAI-kompatible Clients.

<Info>
  **Du nutzt die API in einem Dedicated Deployment?** Ersetze `api.langdock.com` durch die Base URL deines Deployments: **`<deployment-url>/api/public`**
</Info>

Erstelle mit `POST /openai/{region}/v1/responses` eine Modellantwort. Langdock unterstützt die OpenAI-Responses-Request- und Response-Form für die unten genannten Felder. Du kannst daher die OpenAI-SDK-Methode `responses.create` und andere Responses-kompatible Clients mit einem Langdock API-Key verwenden.

<Info>
  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. Persönliche Keys enthalten ausschließlich den Scope Completion API.
</Info>

Nutze diesen Endpunkt für Codex und andere Clients, die Responses-`input`-Elemente senden und Responses-`output`-Elemente lesen. Für Integrationen, die `messages` senden und `choices` auslesen, verwende [OpenAI Chat Completions](/de/developer/completion-api/openai).

## Unterstützte Felder

Übergebe einen String, Nachrichtenelemente oder Tool-Ergebnisse in `input`. Langdock leitet unterstützte Werte für `instructions`, `max_output_tokens`, `temperature`, `top_p`, `reasoning`, `text`, `metadata`, `include`, `truncation`, `service_tier`, `tools`, `tool_choice` und `parallel_tool_calls` weiter. Der Endpunkt unterstützt natives Streaming mit Server-Sent Events und Function Tools, einschließlich paralleler Function Calls. Welche Einstellungen greifen, hängt vom ausgewählten Modell ab.

Der Pfadwert `{region}` muss `eu`, `us` oder `global` sein und zur Region passen, in der dein Modell verfügbar ist. Rufe `GET /openai/{region}/v1/models` mit derselben Region auf, um die in deinem Workspace verfügbaren Modelle aufzulisten. Wenn dein Workspace [Bring your own key (BYOK)](/de/admin/byok/byok) verwendet, können andere Modelle verfügbar sein.

## Unterschiede zur OpenAI API

<Warning>
  Langdock speichert keinen Zustand für die Responses API. Sende den vollständigen Gesprächsverlauf mit jeder Anfrage.
</Warning>

* Lasse `store` weg oder setze den Wert auf `false`. `store=true` wird abgelehnt.
* `previous_response_id` wird nicht unterstützt und abgelehnt. Übergebe vorherige Nachrichten und Tool-Ergebnisse in `input`.
* Background Responses werden nicht unterstützt. Lasse `background` weg oder setze den Wert auf `false`.
* Gehostete Tools wie Web-Suche, File Search, Code Interpreter, Bildgenerierung, Computer Use und MCP werden nicht unterstützt.
* Function Tools werden unterstützt, einschließlich paralleler Function Calls.

## OpenAI-Python-Bibliothek verwenden

Lege Langdock als Basis-URL fest und verwende `responses.create`:

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

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

response = client.responses.create(
    model="gpt-5-mini",
    input="Schreibe ein kurzes Gedicht über Katzen.",
    store=False,
)

print(response.output_text)
```

### Response streamen

Setze `stream=True`, um native Events der Responses API zu erhalten:

```python theme={null}
stream = client.responses.create(
    model="gpt-5-mini",
    input="Schreibe ein kurzes Gedicht über Katzen.",
    store=False,
    stream=True,
)

for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="")
```

### Zustandslose Unterhaltung mit Tool-Aufruf fortsetzen

Füge die zurückgegebenen Output-Elemente und das passende `function_call_output` zur nächsten Anfrage hinzu:

```python theme={null}
import json

conversation = [
    {"role": "user", "content": "Wie ist das Wetter in Berlin?"}
]
tools = [{
    "type": "function",
    "name": "lookup_weather",
    "description": "Ruft das aktuelle Wetter für eine Stadt ab.",
    "parameters": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"],
        "additionalProperties": False,
    },
}]

response = client.responses.create(
    model="gpt-5-mini",
    input=conversation,
    tools=tools,
    store=False,
)

conversation.extend(response.output)
tool_call = next(item for item in response.output if item.type == "function_call")
conversation.append({
    "type": "function_call_output",
    "call_id": tool_call.call_id,
    "output": json.dumps({"temperature_c": 18, "condition": "sonnig"}),
})

final_response = client.responses.create(
    model="gpt-5-mini",
    input=conversation,
    tools=tools,
    store=False,
)

print(final_response.output_text)
```

## Codex verbinden

Erstelle einen persönlichen API-Key und öffne dann **Deine Tools verbinden > Codex** unter [Einstellungen > Account > API-Keys](https://app.langdock.com/settings/account/api-keys). Wähle ein verfügbares OpenAI-kompatibles Modell und folge den generierten Schritten für dein Betriebssystem. Die Einrichtung zeigt Codex auf den Responses-Endpunkt von Langdock (`wire_api = "responses"`) und dein ausgewähltes Modell.

## Rate Limits

Die Standard-Limits sind **500 RPM** (Anfragen pro Minute) und **60.000 TPM** (Tokens pro Minute).

* RPM wird je Workspace, Modell und API-Key begrenzt.
* TPM teilen sich alle API-Keys, die dasselbe Modell in einem Workspace verwenden.
* 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 Extra-Usage-Budget des Mitglieds. Die Nutzung von Workspace-API-Keys zählt zum API-Spend-Limit des Workspace. 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/responses
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/responses:
    post:
      tags:
        - Responses
      summary: Creates a stateless model response.
      description: >-
        Creates a stateless OpenAI-compatible response. Supports text
        generation, streaming, and function tools. Do not send store=true,
        previous_response_id, background=true, or hosted tools.
      operationId: createResponse
      parameters:
        - name: region
          in: path
          required: true
          description: The region of the API to use.
          schema:
            type: string
            enum:
              - eu
              - us
              - global
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: >-
                    The model ID. Use the models endpoint to list models
                    available in your workspace.
                input:
                  description: The input text or full conversation state to process.
                  oneOf:
                    - type: string
                    - type: array
                      items: {}
                    - type: object
                      additionalProperties: true
                instructions:
                  type: string
                  nullable: true
                  description: Instructions added to the model context.
                max_output_tokens:
                  type: integer
                  minimum: 1
                  nullable: true
                  description: The maximum number of output tokens.
                temperature:
                  type: number
                  nullable: true
                  description: Controls response randomness.
                top_p:
                  type: number
                  nullable: true
                  description: Controls nucleus sampling.
                stream:
                  type: boolean
                  nullable: true
                  default: false
                  description: Whether to return native Responses API server sent events.
                tools:
                  type: array
                  description: Function tool definitions. Hosted tools are not supported.
                  items:
                    type: object
                    required:
                      - type
                      - name
                    properties:
                      type:
                        type: string
                        enum:
                          - function
                      name:
                        type: string
                        minLength: 1
                      description:
                        type: string
                        nullable: true
                      parameters:
                        type: object
                        nullable: true
                        additionalProperties: true
                      strict:
                        type: boolean
                        nullable: true
                tool_choice:
                  description: Controls whether the model can call a function.
                  oneOf:
                    - type: string
                      enum:
                        - none
                        - auto
                        - required
                    - type: object
                      required:
                        - type
                        - name
                      properties:
                        type:
                          type: string
                          enum:
                            - function
                        name:
                          type: string
                          minLength: 1
                parallel_tool_calls:
                  type: boolean
                  nullable: true
                  description: Whether the model can return multiple function calls.
                reasoning:
                  type: object
                  description: OpenAI Responses reasoning configuration.
                  additionalProperties: true
                text:
                  type: object
                  description: OpenAI Responses text output configuration.
                  additionalProperties: true
                metadata:
                  type: object
                  nullable: true
                  description: String metadata attached to the request.
                  additionalProperties:
                    type: string
                store:
                  type: boolean
                  nullable: true
                  enum:
                    - false
                  description: >-
                    Responses are not persisted. Omit this field or set it to
                    false.
                background:
                  type: boolean
                  nullable: true
                  enum:
                    - false
                  description: Background responses are not supported.
                include:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: Additional response fields to include.
                truncation:
                  type: string
                  nullable: true
                  enum:
                    - auto
                    - disabled
                service_tier:
                  type: string
                  nullable: true
                  description: The OpenAI service tier forwarded to the model provider.
            example:
              model: gpt-5-mini
              input: Write a short poem about cats.
              store: false
      responses:
        '200':
          description: Successful response or event stream.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateResponseResponse'
              example:
                id: resp_09e99d1f7f163d10016a678387353481
                object: response
                created_at: 1785168775
                status: completed
                model: gpt-5-mini-2025-08-07
                output:
                  - id: rs_09e99d1f7f163d10016a678387f47881
                    type: reasoning
                    content: []
                    summary: []
                  - id: msg_09e99d1f7f163d10016a67838935a881
                    type: message
                    status: completed
                    role: assistant
                    content:
                      - type: output_text
                        annotations: []
                        logprobs: []
                        text: |-
                          Whiskers sketch moonlight on the sill,
                          paws treading silence, soft and still.
                          Eyes like lanterns, sly and bright,
                          turning midnight into light.
                          A velvet sigh, a sudden purr—
                          the world made small, the heart made her.
                usage:
                  input_tokens: 13
                  input_tokens_details:
                    cached_tokens: 0
                  output_tokens: 154
                  output_tokens_details:
                    reasoning_tokens: 64
                  total_tokens: 167
            text/event-stream:
              schema:
                type: string
                description: Native OpenAI Responses API server sent events.
        '400':
          description: Invalid fields, unsupported features, or an unavailable model.
        '401':
          description: Missing, invalid, or expired API key.
        '403':
          description: API key without the Completion API scope.
        '413':
          description: Request body exceeds 20 MB.
        '429':
          description: Usage or rate limit exceeded.
        '500':
          description: Internal server or upstream provider error.
        default:
          description: Error returned by the upstream model provider.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - message
                      - type
                    properties:
                      message:
                        type: string
                      type:
                        type: string
                      code:
                        type: string
                        nullable: true
                      param:
                        type: string
                        nullable: true
      security:
        - bearerAuth: []
components:
  schemas:
    CreateResponseResponse:
      type: object
      description: A response returned by the OpenAI-compatible Responses endpoint.
      required:
        - id
        - object
        - created_at
        - status
        - model
        - output
      properties:
        id:
          type: string
          description: Unique identifier for the response.
          example: resp_09e99d1f7f163d10016a678387353481
        object:
          type: string
          enum:
            - response
          description: The object type, which is always `response`.
        created_at:
          type: integer
          description: Unix timestamp in seconds when the response was created.
          example: 1785168775
        completed_at:
          type: integer
          nullable: true
          description: Unix timestamp in seconds when the response completed.
          example: 1785168778
        background:
          type: boolean
          enum:
            - false
          description: Langdock does not support background responses.
        status:
          type: string
          enum:
            - completed
            - failed
            - in_progress
            - cancelled
            - queued
            - incomplete
          description: Current response status.
          example: completed
        model:
          type: string
          description: Model used to generate the response.
          example: gpt-5-mini-2025-08-07
        output:
          type: array
          description: Output items generated by the model.
          items:
            oneOf:
              - $ref: '#/components/schemas/ResponseReasoningItem'
              - $ref: '#/components/schemas/ResponseOutputMessage'
              - $ref: '#/components/schemas/ResponseFunctionToolCall'
        output_text:
          type: string
          description: Aggregated text from all `output_text` items.
        error:
          type: object
          nullable: true
          description: Error information when the response failed.
          properties:
            code:
              type: string
              nullable: true
            message:
              type: string
        incomplete_details:
          type: object
          nullable: true
          description: Details explaining why the response is incomplete.
          properties:
            reason:
              type: string
              enum:
                - max_output_tokens
                - content_filter
        instructions:
          type: string
          nullable: true
          description: Instructions used for the response.
        max_output_tokens:
          type: integer
          nullable: true
          description: Maximum number of output tokens configured for the response.
        parallel_tool_calls:
          type: boolean
          description: Whether the model can return multiple function calls.
        reasoning:
          type: object
          nullable: true
          description: Reasoning configuration used for the response.
          additionalProperties: true
        store:
          type: boolean
          enum:
            - false
          description: Langdock Responses are never persisted.
        temperature:
          type: number
          nullable: true
          description: Sampling temperature used for the response.
        text:
          type: object
          nullable: true
          description: Text output configuration used for the response.
          additionalProperties: true
        service_tier:
          type: string
          nullable: true
          description: Service tier used to process the response.
        tool_choice:
          description: Tool choice used for the response.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
        tools:
          type: array
          description: Function tools available to the model.
          items:
            type: object
            additionalProperties: true
        top_p:
          type: number
          nullable: true
          description: Nucleus sampling value used for the response.
        truncation:
          type: string
          enum:
            - auto
            - disabled
          description: Truncation strategy used for the response.
        usage:
          $ref: '#/components/schemas/ResponseUsage'
        metadata:
          type: object
          nullable: true
          description: Metadata attached to the request.
          additionalProperties:
            type: string
      additionalProperties: true
    ResponseReasoningItem:
      type: object
      description: Reasoning information generated by a reasoning model.
      required:
        - id
        - type
        - summary
      properties:
        id:
          type: string
          example: rs_123
        type:
          type: string
          enum:
            - reasoning
        summary:
          type: array
          items:
            type: object
            additionalProperties: true
        content:
          type: array
          items:
            type: object
            additionalProperties: true
        encrypted_content:
          type: string
          nullable: true
          description: Encrypted reasoning content when requested.
        status:
          type: string
          nullable: true
          enum:
            - in_progress
            - completed
            - incomplete
      additionalProperties: true
    ResponseOutputMessage:
      type: object
      description: A message generated by the model.
      required:
        - id
        - type
        - status
        - role
        - content
      properties:
        id:
          type: string
          example: msg_09e99d1f7f163d10016a67838935a881
        type:
          type: string
          enum:
            - message
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
        role:
          type: string
          enum:
            - assistant
        content:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/ResponseOutputText'
              - $ref: '#/components/schemas/ResponseOutputRefusal'
      additionalProperties: true
    ResponseFunctionToolCall:
      type: object
      description: A function call requested by the model.
      required:
        - id
        - type
        - call_id
        - name
        - arguments
      properties:
        id:
          type: string
          example: fc_123
        type:
          type: string
          enum:
            - function_call
        status:
          type: string
          enum:
            - in_progress
            - completed
            - incomplete
        call_id:
          type: string
          example: call_123
        name:
          type: string
          example: lookup_weather
        arguments:
          type: string
          description: JSON-encoded arguments for the function.
          example: '{"city":"Berlin"}'
      additionalProperties: true
    ResponseUsage:
      type: object
      description: Token usage for the response.
      required:
        - input_tokens
        - output_tokens
        - total_tokens
      properties:
        input_tokens:
          type: integer
          example: 13
        input_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
              example: 0
          additionalProperties: true
        output_tokens:
          type: integer
          example: 154
        output_tokens_details:
          type: object
          properties:
            reasoning_tokens:
              type: integer
              example: 64
          additionalProperties: true
        total_tokens:
          type: integer
          example: 167
      additionalProperties: true
    ResponseOutputText:
      type: object
      description: Text generated by the model.
      required:
        - type
        - text
        - annotations
      properties:
        type:
          type: string
          enum:
            - output_text
        text:
          type: string
          example: |-
            Whiskers sketch moonlight on the sill,
            paws treading silence, soft and still.
        annotations:
          type: array
          items:
            type: object
            additionalProperties: true
        logprobs:
          type: array
          items:
            type: object
            additionalProperties: true
      additionalProperties: true
    ResponseOutputRefusal:
      type: object
      description: A refusal returned by the model.
      required:
        - type
        - refusal
      properties:
        type:
          type: string
          enum:
            - refusal
        refusal:
          type: string
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: API key as Bearer token. Format "Bearer YOUR_API_KEY"

````