Zum Hauptinhalt springen

Persistente Konversationen

Dieser Leitfaden zeigt, wie Sie mit der Conversations-API mehrstufige Chat-Sitzungen führen, ohne bei jeder Anfrage den gesamten Nachrichtenverlauf erneut zu senden.

Was Sie erstellen werden

Am Ende dieses Leitfadens können Sie:

  • Eine persistente Konversation erstellen
  • Mehrere Nachrichten senden, ohne den Verlauf erneut zu übertragen
  • Die Konversation und ihren vollständigen Nachrichtenverlauf abrufen
  • Die Konversation nach Gebrauch löschen

Voraussetzungen

  • Ein neuroflash-Konto mit API-Zugang
  • Ihre client_id und client_secret (siehe Authentifizierung)

Schritt 1: Authentifizieren

curl -X POST https://id.neuroflash.com/oauth/v2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "scope=openid"

Schritt 2: Arbeitsbereich abrufen

curl "https://app.neuroflash.com/api/workspace-service/v1/workspaces" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Schritt 3: Konversation erstellen

Hinweis: workspace_id gehört bei POST in den JSON-Body, nicht in einen Header.

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/conversations" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "workspace_id": "YOUR_WORKSPACE_ID" }'

Antwort:

{
"uuid": "ebb3fbeb-69ed-41e9-bcb5-1ec8a643566e",
"workspace_id": "b481b98b-a7ed-4d72-a1f2-8b2ae3a57854",
"created_at": "2026-04-08T15:44:47.383172"
}

Schritt 4: Nachricht senden

Der Conversation-Service speichert Ihren Nachrichtenverlauf — Sie müssen frühere Nachrichten nicht erneut senden. Jede Anfrage muss nur die neue Benutzernachricht enthalten.

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "messages": [{ "role": "user", "content": "What makes neuroflash unique?" }] }'

Antwort:

{
"id": "gen-1775000000-AbCdEfGh",
"object": "chat.completion",
"model": "openai/gpt-4.1-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Neuroflash is unique because it combines brand-aware AI content generation with European data privacy standards and multi-language support."
},
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 12, "completion_tokens": 28, "total_tokens": 40, "words_used": 22 }
}

Schritt 5: Folgefrage senden

Senden Sie eine weitere Nachricht an dieselbe Konversation — ohne den Verlauf erneut zu übertragen. Der Kontext aus Schritt 4 bleibt serverseitig erhalten.

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "messages": [{ "role": "user", "content": "Can you give me an example?" }] }'

Schritt 6: Konversation abrufen

workspace_id bei GET und DELETE erforderlich

Der Conversations-Service erzwingt workspace-gebundene Eigentümerschaft. Der Query-Parameter workspace_id ist bei allen GET- und DELETE-Anfragen erforderlich. Fehlt er oder wird der falsche Workspace verwendet, gibt die API 403 Forbidden zurück.

curl "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}?workspace_id=YOUR_WORKSPACE_ID" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Schritt 7: Nachrichtenverlauf abrufen

curl "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}/messages?workspace_id=YOUR_WORKSPACE_ID" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Antwort:

{
"messages": [
{ "role": "user", "content": "What makes neuroflash unique?" },
{ "role": "assistant", "content": "Neuroflash is unique due to..." }
],
"next_cursor": null
}

Schritt 8: Konversation löschen

curl -X DELETE "https://app.neuroflash.com/api/ds-prototypes/conversations/{uuid}?workspace_id=YOUR_WORKSPACE_ID" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Nächste Schritte