Funktionen
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.
Unterstützte Modelle
Abschnitt betitelt „Unterstützte Modelle“| Modell | Reasoning | Function Calling | Hinweise |
|---|---|---|---|
MiniMax-M2.7 |
Ja | Ja | Empfohlen für Agentic Coding (192k Kontext) |
gemma-4-31B-it |
Nein | Ja | Schnell, 128k Kontext |
gpt-oss-120b |
Ja | Ja | Setzen Sie reasoning.effort: "high" für beste Tool-Aufrufe |
Hauptmerkmale
Abschnitt betitelt „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
Abschnitt betitelt „Einfache Generierung“Die einfachste Verwendung übergibt eine Zeichenkette als Eingabe und erhält eine strukturierte Antwort.
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.7", input="Erkläre den Unterschied zwischen überwachtem und unüberwachtem Lernen.")
# Textausgabe abrufenprint(response.output_text)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.7", input="Erkläre den Unterschied zwischen überwachtem und unüberwachtem Lernen.")
# Text aus Ausgabe-Elementen abrufenprint(response.output[0].content[0].text)curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "input": "Erkläre den Unterschied zwischen überwachtem und unüberwachtem Lernen." }'Antwortstruktur
Abschnitt betitelt „Antwortstruktur“Die Antwort enthält ein output-Array mit typisierten Elementen:
{ "id": "resp_abc123", "object": "response", "status": "completed", "model": "MiniMax-M2.7", "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
Abschnitt betitelt „Systemanweisungen“Verwenden Sie den instructions-Parameter für Anweisungen auf Systemebene:
response = client.responses.create( model="MiniMax-M2.7", instructions="Du bist ein hilfreicher Assistent, der wie ein Pirat spricht.", input="Wie geht es dir heute?")curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "instructions": "Du bist ein hilfreicher Assistent, der wie ein Pirat spricht.", "input": "Wie geht es dir heute?" }'Mehrstufige Konversationen
Abschnitt betitelt „Mehrstufige Konversationen“Da die API zustandslos ist, fügen Sie den vollständigen Konversationsverlauf im input-Array ein:
# Runde 1response_1 = client.responses.create( model="MiniMax-M2.7", input=[{"role": "user", "content": "Mein Name ist Thomas."}])
# Runde 2 - vorherige Nachrichten einbeziehenresponse_2 = client.responses.create( model="MiniMax-M2.7", 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..."curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "input": [ {"role": "user", "content": "Mein Name ist Thomas."}, {"role": "assistant", "content": "Hallo Thomas!"}, {"role": "user", "content": "Wie ist mein Name?"} ] }'Function Calling
Abschnitt betitelt „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
Abschnitt betitelt „Schritt 1: Tools definieren und erste Anfrage stellen“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.7", input=[{"role": "user", "content": "Wie ist das Wetter in Berlin?"}], tools=tools)
# Prüfen, ob das Modell eine Funktion aufrufen möchtefor item in response.output: if item.type == "function_call": print(f"Funktion: {item.name}") print(f"Argumente: {item.arguments}")curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "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"] } }] }'Schritt 2: Funktion ausführen und Ergebnis zurückgeben
Abschnitt betitelt „Schritt 2: Funktion ausführen und Ergebnis zurückgeben“# Funktion lokal ausführendef 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 findentool_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ücksendenfollow_up = client.responses.create( model="MiniMax-M2.7", 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."curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "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"] } }] }'Tool-Auswahl
Abschnitt betitelt „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)
Abschnitt betitelt „Strukturierte Ausgabe (JSON-Modus)“Fordern Sie strukturierte JSON-Ausgabe mit dem text.format-Parameter an.
JSON-Objekt-Modus
Abschnitt betitelt „JSON-Objekt-Modus“response = client.responses.create( model="MiniMax-M2.7", input="Liste 3 europäische Hauptstädte auf", text={"format": {"type": "json_object"}})
import jsondata = json.loads(response.output_text)curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "input": "Liste 3 europäische Hauptstädte als JSON auf", "text": {"format": {"type": "json_object"}} }'JSON-Schema-Modus
Abschnitt betitelt „JSON-Schema-Modus“Für garantierte Struktur geben Sie ein JSON-Schema an:
response = client.responses.create( model="MiniMax-M2.7", 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 jsonevent = json.loads(response.output_text)print(event)# {"title": "SambaNova Launch", "date": "1. Mai 2026", "time": "10 Uhr", "location": "San Francisco"}curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "input": "Liste 3 Farben auf", "text": { "format": { "type": "json_schema", "name": "colors", "schema": { "type": "object", "properties": { "colors": {"type": "array", "items": {"type": "string"}} }, "required": ["colors"] } } } }'Reasoning
Abschnitt betitelt „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 |
response = client.responses.create( model="MiniMax-M2.7", input="Was ist 15 * 23?", reasoning={"effort": "high"})
# Reasoning getrennt von der Antwort abrufenfor item in response.output: if item.type == "reasoning": print("Reasoning:", item.content[0].text) elif item.type == "message": print("Antwort:", item.content[0].text)curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "input": "Was ist 15 * 23?", "reasoning": {"effort": "high"} }'Streaming
Abschnitt betitelt „Streaming“Aktivieren Sie Streaming für Echtzeit-Ausgabe mit stream: true. Die API sendet Server-Sent Events:
stream = client.responses.create( model="MiniMax-M2.7", 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)curl -X POST https://api.infercom.ai/v1/responses \ -H "Authorization: Bearer $INFERCOM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "MiniMax-M2.7", "input": "Zähle von 1 bis 5", "stream": true }'Streaming-Ereignistypen
Abschnitt betitelt „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
Abschnitt betitelt „Anfrageparameter“| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
model |
string | Ja | Modell-ID (MiniMax-M2.7, gemma-4-31B-it, 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. Kein Standardwert - ohne Angabe dekodieren die meisten Modelle greedy. |
top_p |
number | Nein | Nucleus Sampling 0-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
Abschnitt betitelt „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
Abschnitt betitelt „Nutzungsstatistiken“Das usage-Objekt enthält Performance-Metriken:
{ "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
Abschnitt betitelt „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
Abschnitt betitelt „Einschränkungen“- Zustandslos:
previous_response_idwird nicht unterstützt—liefern Sie den vollständigen Konversationsverlauf ininput[] - Nur Function Tools: Eingebaute Tools (web_search, code_interpreter) werden nicht unterstützt
- Nicht implementiert:
frequency_penalty,presence_penalty,repetition_penalty,max_tool_calls,strict-Modus. Die Antwort gibtfrequency_penaltyundpresence_penaltyzurück, angewendet wurden sie trotzdem nicht. Senden Sie die drei Penalty-Parameter nicht an diesen Endpunkt: Ein kommendes Plattform-Release gibt dafür einen Fehler zurück. Für Wiederholungskontrolle verwenden Sierepetition_penaltyauf/v1/chat/completions
Agentic Coding Integrationen
Abschnitt betitelt „Agentic Coding Integrationen“Die Responses API betreibt Agentic-Coding-Tools. Siehe Integrationsanleitungen:
- OpenCode - Terminal-basierter Coding-Assistent
- Cline - VS Code Erweiterung
- Aider - Terminal Pair Programming
Nächste Schritte
Abschnitt betitelt „Nächste Schritte“- Function Calling - Detaillierte Function-Calling-Anleitung für Chat Completions
- Textgenerierung - Chat Completions API Anleitung
- API-Referenz - Vollständige Endpunkt-Dokumentation