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

# Responses API - Agentic Workflows erstellen

> Erstellen Sie agentenbasierte KI-Anwendungen mit der Infercom Responses API. Strukturierte Ausgaben, Function Calling, Reasoning und Streaming für Coding-Agenten und werkzeugfähige Integrationen.

Die Responses API (`POST /v1/responses`) ist für agentenbasierte Workflows und werkzeugfähige Integrationen konzipiert. Sie strukturiert die Modellausgabe als typisierte Elemente—Nachrichten, Funktionsaufrufe und Reasoning—anstatt als einzelnes Textfeld, was ausgefeilte mehrstufige Agenten-Interaktionen ermöglicht.

<Info>
  Die Responses API ergänzt die [Chat Completions API](/de/features/text-generation) und ersetzt sie nicht. Verwenden Sie die Responses API für agentenbasierte Workflows und Tool-Aufrufe; verwenden Sie Chat Completions für einfachere Konversationsanwendungen.
</Info>

## Unterstützte Modelle

| Modell         | Reasoning | Function Calling | Hinweise                                                     |
| -------------- | --------- | ---------------- | ------------------------------------------------------------ |
| `MiniMax-M2.5` | Ja        | Ja               | Empfohlen für Agentic Coding                                 |
| `gpt-oss-120b` | Ja        | Ja               | Setzen Sie `reasoning.effort: "high"` für beste Tool-Aufrufe |

<Note>
  Nicht alle Modelle unterstützen die Responses API. Modelle wie `DeepSeek-V3.1` und `Meta-Llama-3.3-70B-Instruct` sind nur über Chat Completions verfügbar.
</Note>

## Hauptmerkmale

* **Strukturierte Ausgabe-Elemente**: Antworten enthalten typisierte Elemente (`message`, `function_call`, `reasoning`) statt eines einzelnen Textfeldes
* **Zustandslos**: Infercom speichert keinen Konversationszustand—liefern Sie den vollständigen Verlauf über `input[]` bei jeder Anfrage
* **Client-ausgeführte Tools**: Wenn ein Tool benötigt wird, gibt das Modell ein `function_call`-Element zurück; Ihre Anwendung führt die Funktion aus und gibt das Ergebnis zurück
* **Streaming**: Server-Sent Events mit typisierter Ereignishierarchie für Echtzeit-Ausgabe

## Einfache Generierung

Die einfachste Verwendung übergibt eine Zeichenkette als Eingabe und erhält eine strukturierte Antwort.

<CodeGroup>
  ```python Python (OpenAI SDK) theme={null}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.infercom.ai/v1",
      api_key="ihr-infercom-api-schluessel"
  )

  response = client.responses.create(
      model="MiniMax-M2.5",
      input="Erkläre den Unterschied zwischen überwachtem und unüberwachtem Lernen."
  )

  # Textausgabe abrufen
  print(response.output_text)
  ```

  ```python Python (SambaNova SDK) theme={null}
  from sambanova import SambaNova

  client = SambaNova(
      base_url="https://api.infercom.ai/v1",
      api_key="ihr-infercom-api-schluessel"
  )

  response = client.responses.create(
      model="MiniMax-M2.5",
      input="Erkläre den Unterschied zwischen überwachtem und unüberwachtem Lernen."
  )

  # Text aus Ausgabe-Elementen abrufen
  print(response.output[0].content[0].text)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": "Erkläre den Unterschied zwischen überwachtem und unüberwachtem Lernen."
    }'
  ```
</CodeGroup>

### Antwortstruktur

Die Antwort enthält ein `output`-Array mit typisierten Elementen:

```json theme={null}
{
  "id": "resp_abc123",
  "object": "response",
  "status": "completed",
  "model": "MiniMax-M2.5",
  "output": [
    {
      "type": "reasoning",
      "id": "rs_xyz",
      "status": "completed",
      "content": [
        {
          "type": "reasoning_text",
          "text": "Der Benutzer fragt nach ML-Konzepten..."
        }
      ]
    },
    {
      "type": "message",
      "id": "msg_xyz",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Überwachtes Lernen verwendet gelabelte Daten..."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 45,
    "output_tokens": 120,
    "total_tokens": 165,
    "output_tokens_details": {
      "reasoning_tokens": 35
    }
  }
}
```

## Systemanweisungen

Verwenden Sie den `instructions`-Parameter für Anweisungen auf Systemebene:

<CodeGroup>
  ```python Python theme={null}
  response = client.responses.create(
      model="MiniMax-M2.5",
      instructions="Du bist ein hilfreicher Assistent, der wie ein Pirat spricht.",
      input="Wie geht es dir heute?"
  )
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "instructions": "Du bist ein hilfreicher Assistent, der wie ein Pirat spricht.",
      "input": "Wie geht es dir heute?"
    }'
  ```
</CodeGroup>

## Mehrstufige Konversationen

Da die API zustandslos ist, fügen Sie den vollständigen Konversationsverlauf im `input`-Array ein:

<CodeGroup>
  ```python Python theme={null}
  # Runde 1
  response_1 = client.responses.create(
      model="MiniMax-M2.5",
      input=[{"role": "user", "content": "Mein Name ist Thomas."}]
  )

  # Runde 2 - vorherige Nachrichten einbeziehen
  response_2 = client.responses.create(
      model="MiniMax-M2.5",
      input=[
          {"role": "user", "content": "Mein Name ist Thomas."},
          response_1.output[0],  # Antwort des Assistenten einbeziehen
          {"role": "user", "content": "Wie ist mein Name?"}
      ]
  )

  print(response_2.output_text)  # "Dein Name ist Thomas..."
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": [
        {"role": "user", "content": "Mein Name ist Thomas."},
        {"role": "assistant", "content": "Hallo Thomas!"},
        {"role": "user", "content": "Wie ist mein Name?"}
      ]
    }'
  ```
</CodeGroup>

## Function Calling

Die Responses API unterstützt Function Tools für agentenbasierte Workflows. Nur `type: "function"` Tools werden unterstützt.

### Schritt 1: Tools definieren und erste Anfrage stellen

<CodeGroup>
  ```python Python theme={null}
  import json

  tools = [{
      "type": "function",
      "name": "get_weather",
      "description": "Aktuelles Wetter für eine Stadt abrufen.",
      "parameters": {
          "type": "object",
          "properties": {
              "city": {"type": "string", "description": "Stadtname"}
          },
          "required": ["city"]
      }
  }]

  response = client.responses.create(
      model="MiniMax-M2.5",
      input=[{"role": "user", "content": "Wie ist das Wetter in Berlin?"}],
      tools=tools
  )

  # Prüfen, ob das Modell eine Funktion aufrufen möchte
  for item in response.output:
      if item.type == "function_call":
          print(f"Funktion: {item.name}")
          print(f"Argumente: {item.arguments}")
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": [{"role": "user", "content": "Wie ist das Wetter in Berlin?"}],
      "tools": [{
        "type": "function",
        "name": "get_weather",
        "description": "Aktuelles Wetter für eine Stadt abrufen",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {"type": "string", "description": "Stadtname"}
          },
          "required": ["city"]
        }
      }]
    }'
  ```
</CodeGroup>

### Schritt 2: Funktion ausführen und Ergebnis zurückgeben

<CodeGroup>
  ```python Python theme={null}
  # Funktion lokal ausführen
  def get_weather(city: str) -> dict:
      # Ihr tatsächlicher Wetter-API-Aufruf hier
      return {"city": city, "temperature": "18°C", "condition": "Bewölkt"}

  # Funktionsaufruf in der Antwort finden
  tool_call = next(item for item in response.output if item.type == "function_call")
  args = json.loads(tool_call.arguments)
  result = get_weather(args["city"])

  # Ergebnis an das Modell zurücksenden
  follow_up = client.responses.create(
      model="MiniMax-M2.5",
      input=[
          {"role": "user", "content": "Wie ist das Wetter in Berlin?"},
          tool_call,  # Funktionsaufruf einbeziehen
          {
              "type": "function_call_output",
              "call_id": tool_call.call_id,
              "output": json.dumps(result)
          }
      ],
      tools=tools
  )

  print(follow_up.output_text)  # "Das Wetter in Berlin ist 18°C und bewölkt."
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": [
        {"role": "user", "content": "Wie ist das Wetter in Berlin?"},
        {
          "type": "function_call",
          "id": "fc_123",
          "call_id": "call_123",
          "name": "get_weather",
          "arguments": "{\"city\": \"Berlin\"}",
          "status": "completed"
        },
        {
          "type": "function_call_output",
          "call_id": "call_123",
          "output": "{\"temperature\": \"18°C\", \"condition\": \"Bewölkt\"}"
        }
      ],
      "tools": [{
        "type": "function",
        "name": "get_weather",
        "description": "Aktuelles Wetter für eine Stadt abrufen",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }]
    }'
  ```
</CodeGroup>

### Tool-Auswahl

Steuern Sie, wann das Modell Tools verwendet, mit `tool_choice`:

| Wert                                  | Verhalten                                                       |
| ------------------------------------- | --------------------------------------------------------------- |
| `"auto"`                              | Modell entscheidet, ob eine Funktion aufgerufen wird (Standard) |
| `"none"`                              | Modell ruft keine Funktionen auf                                |
| `"required"`                          | Modell muss mindestens eine Funktion aufrufen                   |
| `{"type": "function", "name": "..."}` | Bestimmte Funktion erzwingen                                    |

## Strukturierte Ausgabe (JSON-Modus)

Fordern Sie strukturierte JSON-Ausgabe mit dem `text.format`-Parameter an.

### JSON-Objekt-Modus

<CodeGroup>
  ```python Python theme={null}
  response = client.responses.create(
      model="MiniMax-M2.5",
      input="Liste 3 europäische Hauptstädte auf",
      text={"format": {"type": "json_object"}}
  )

  import json
  data = json.loads(response.output_text)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": "Liste 3 europäische Hauptstädte als JSON auf",
      "text": {"format": {"type": "json_object"}}
    }'
  ```
</CodeGroup>

### JSON-Schema-Modus

Für garantierte Struktur geben Sie ein JSON-Schema an:

<CodeGroup>
  ```python Python theme={null}
  response = client.responses.create(
      model="MiniMax-M2.5",
      input="Extrahiere Veranstaltungsdetails: SambaNova Launch am 1. Mai 2026 um 10 Uhr in San Francisco.",
      text={
          "format": {
              "type": "json_schema",
              "name": "event_extraction",
              "schema": {
                  "type": "object",
                  "properties": {
                      "title": {"type": "string"},
                      "date": {"type": "string"},
                      "time": {"type": "string"},
                      "location": {"type": "string"}
                  },
                  "required": ["title", "date", "time", "location"]
              }
          }
      }
  )

  import json
  event = json.loads(response.output_text)
  print(event)
  # {"title": "SambaNova Launch", "date": "1. Mai 2026", "time": "10 Uhr", "location": "San Francisco"}
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": "Liste 3 Farben auf",
      "text": {
        "format": {
          "type": "json_schema",
          "name": "colors",
          "schema": {
            "type": "object",
            "properties": {
              "colors": {"type": "array", "items": {"type": "string"}}
            },
            "required": ["colors"]
          }
        }
      }
    }'
  ```
</CodeGroup>

## Reasoning

Reasoning-fähige Modelle zeigen ihren Denkprozess über `reasoning`-Ausgabe-Elemente. Steuern Sie die Reasoning-Tiefe mit `reasoning.effort`:

| Effort     | Verhalten                               |
| ---------- | --------------------------------------- |
| `"low"`    | Schneller, weniger Tiefe                |
| `"medium"` | Ausgewogen (Standard)                   |
| `"high"`   | Tieferes Reasoning, höhere Token-Kosten |

<CodeGroup>
  ```python Python theme={null}
  response = client.responses.create(
      model="MiniMax-M2.5",
      input="Was ist 15 * 23?",
      reasoning={"effort": "high"}
  )

  # Reasoning getrennt von der Antwort abrufen
  for item in response.output:
      if item.type == "reasoning":
          print("Reasoning:", item.content[0].text)
      elif item.type == "message":
          print("Antwort:", item.content[0].text)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": "Was ist 15 * 23?",
      "reasoning": {"effort": "high"}
    }'
  ```
</CodeGroup>

<Tip>
  Wenn Sie `gpt-oss-120b` für Function Calling verwenden, setzen Sie `reasoning.effort` auf `"high"` für beste Ergebnisse.
</Tip>

## Streaming

Aktivieren Sie Streaming für Echtzeit-Ausgabe mit `stream: true`. Die API sendet Server-Sent Events:

<CodeGroup>
  ```python Python theme={null}
  stream = client.responses.create(
      model="MiniMax-M2.5",
      input="Schreibe ein kurzes Gedicht über Geschwindigkeit.",
      stream=True
  )

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

  ```bash cURL theme={null}
  curl -X POST https://api.infercom.ai/v1/responses \
    -H "Authorization: Bearer $INFERCOM_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "MiniMax-M2.5",
      "input": "Zähle von 1 bis 5",
      "stream": true
    }'
  ```
</CodeGroup>

### Streaming-Ereignistypen

| Ereignis                                 | Beschreibung                             |
| ---------------------------------------- | ---------------------------------------- |
| `response.created`                       | Antwort initialisiert                    |
| `response.in_progress`                   | Generierung gestartet                    |
| `response.output_item.added`             | Neues Ausgabe-Element erstellt           |
| `response.content_part.added`            | Neuer Inhaltsteil hinzugefügt            |
| `response.reasoning_text.delta`          | Inkrementeller Reasoning-Abschnitt       |
| `response.reasoning_text.done`           | Reasoning abgeschlossen                  |
| `response.output_text.delta`             | Inkrementeller Ausgabetext               |
| `response.output_text.done`              | Ausgabetext abgeschlossen                |
| `response.function_call_arguments.delta` | Inkrementelle Funktionsargumente         |
| `response.function_call_arguments.done`  | Funktionsargumente abgeschlossen         |
| `response.content_part.done`             | Inhaltsteil beendet                      |
| `response.output_item.done`              | Ausgabe-Element abgeschlossen            |
| `response.completed`                     | Letztes Ereignis mit Nutzungsstatistiken |

## Anfrageparameter

| Parameter             | Typ              | Erforderlich | Beschreibung                                        |
| --------------------- | ---------------- | ------------ | --------------------------------------------------- |
| `model`               | string           | Ja           | Modell-ID (`MiniMax-M2.5`, `gpt-oss-120b`)          |
| `input`               | string \| array  | Ja           | Texteingabe oder Konversations-Array                |
| `instructions`        | string           | Nein         | Systemnachricht vor der Eingabe                     |
| `stream`              | boolean          | Nein         | SSE-Streaming aktivieren (Standard: false)          |
| `max_output_tokens`   | integer          | Nein         | Maximale zu generierende Tokens                     |
| `temperature`         | number           | Nein         | Zufälligkeit 0-2 (Standard: 0.7)                    |
| `top_p`               | number           | Nein         | Nucleus Sampling 0-1 (Standard: 1)                  |
| `top_k`               | integer          | Nein         | Top-K Sampling 1-100                                |
| `tools`               | array            | Nein         | Function Tool-Definitionen (max. 128)               |
| `tool_choice`         | string \| object | Nein         | Tool-Aufrufsteuerung                                |
| `parallel_tool_calls` | boolean          | Nein         | Parallele Tool-Aufrufe erlauben (Standard: true)    |
| `text.format`         | object           | Nein         | Ausgabeformat: `text`, `json_object`, `json_schema` |
| `reasoning.effort`    | string           | Nein         | Reasoning-Tiefe: `low`, `medium`, `high`            |

## Antwortfelder

| Feld     | Typ    | Beschreibung                                                |
| -------- | ------ | ----------------------------------------------------------- |
| `id`     | string | Eindeutige Antwort-ID                                       |
| `object` | string | Immer `"response"`                                          |
| `status` | string | `completed`, `failed`, `in_progress`, `incomplete`          |
| `model`  | string | Verwendete Modell-ID                                        |
| `output` | array  | Ausgabe-Elemente (Nachrichten, Reasoning, Funktionsaufrufe) |
| `usage`  | object | Token-Nutzungsstatistiken                                   |
| `error`  | object | Fehlerdetails wenn `status: "failed"`                       |

### Nutzungsstatistiken

Das `usage`-Objekt enthält Performance-Metriken:

```json theme={null}
{
  "input_tokens": 45,
  "output_tokens": 120,
  "total_tokens": 165,
  "input_tokens_details": {"cached_tokens": 0},
  "output_tokens_details": {"reasoning_tokens": 35},
  "time_to_first_token": 0.084,
  "total_latency": 0.459,
  "output_tokens_per_sec": 261.4
}
```

## Responses API vs Chat Completions

| Merkmal                | Responses API                                            | Chat Completions              |
| ---------------------- | -------------------------------------------------------- | ----------------------------- |
| Ausgabestruktur        | Typisierte Elemente (message, reasoning, function\_call) | Einzelne Nachricht mit Inhalt |
| Reasoning-Sichtbarkeit | Separate `reasoning`-Elemente                            | Inline im Inhalt              |
| Tool-Ergebnisse        | Strukturierte `function_call_output`                     | `tool`-Rollen-Nachrichten     |
| Am besten für          | Agentenbasierte Workflows, Coding-Agenten                | Konversationsanwendungen      |

## Einschränkungen

* **Zustandslos**: `previous_response_id` wird nicht unterstützt—liefern Sie den vollständigen Konversationsverlauf in `input[]`
* **Nur Function Tools**: Eingebaute Tools (web\_search, code\_interpreter) werden nicht unterstützt
* **Nicht implementiert**: `frequency_penalty`, `presence_penalty`, `max_tool_calls`, `strict`-Modus

## Agentic Coding Integrationen

Die Responses API betreibt Agentic-Coding-Tools. Siehe Integrationsanleitungen:

* [OpenCode](/de/agentic-coding/opencode) - Terminal-basierter Coding-Assistent
* [Cline](/de/agentic-coding/cline) - VS Code Erweiterung
* [Aider](/de/agentic-coding/aider) - Terminal Pair Programming

## Nächste Schritte

* [Function Calling](/de/features/function-calling) - Detaillierte Function-Calling-Anleitung für Chat Completions
* [Textgenerierung](/de/features/text-generation) - Chat Completions API Anleitung
* [API-Referenz](/de/api-reference/overview) - Vollständige Endpunkt-Dokumentation
