Zum Hauptinhalt springen

Textgenerierung

Diese Anleitung fuehrt Sie durch die Generierung von Textinhalten mit der neuroflash API -- von der Modellauswahl ueber das Streaming von Antworten bis hin zur Anwendung einer Brand Voice.

Was Sie erstellen werden

Am Ende dieser Anleitung werden Sie:

  • Sich bei der neuroflash API authentifizieren
  • Ihren Workspace abrufen
  • Verfuegbare KI-Modelle auflisten
  • Einen Chat Completion Request senden
  • Eine Antwort in Echtzeit streamen
  • Multi-Turn-Nachrichten fuer Kontext nutzen
  • Eine Brand Voice fuer einen konsistenten Tonfall anwenden

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: Workspace abrufen

Rufen Sie Ihre verfuegbaren Workspaces ab und waehlen Sie den ersten aus. Die Workspace-ID wird fuer die meisten API-Aufrufe benoetigt:

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

Schritt 3: Verfuegbare Modelle auflisten

Sehen Sie, welche KI-Modelle fuer Ihren Tarif verfuegbar sind:

curl "https://app.neuroflash.com/api/ds-prototypes/model_selection/models" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "x-workspace-id: YOUR_WORKSPACE_ID"

Antwort:

[
{
"id": "gpt-4.1-mini",
"name": "GPT-4.1 Mini",
"provider": "openai",
"description": "Fast and cost-effective model for most tasks",
"context_window": 128000,
"available": true,
"reasoning_model": false
},
{
"id": "claude-sonnet-4",
"name": "Claude Sonnet 4",
"provider": "anthropic",
"description": "Excellent for nuanced writing and analysis",
"context_window": 200000,
"available": true,
"reasoning_model": false
},
{
"id": "gpt-5",
"name": "GPT-5",
"provider": "openai",
"description": "Most capable OpenAI model with reasoning",
"context_window": 128000,
"available": true,
"reasoning_model": true
}
]

Modellverfuegbarkeit nach Tarif:

TarifModelle
Freegpt-4.1-mini, mistral-7b-instruct, mistral-medium-3.1, claude-sonnet-4, gemini-2.5-flash
ProAlle Free-Modelle + gpt-5, gpt-4.1, gemini-2.5-pro
BusinessAlle Pro-Modelle + claude-opus-4.1

Schritt 4: Chat Completion senden

Senden Sie eine Nachricht und erhalten Sie eine Antwort ueber den Content-Generation-Endpoint:

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/content_generation/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "x-workspace-id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1-mini",
"messages": [
{
"role": "user",
"content": "Write an outline for a blog post about how small businesses can adopt sustainable technology practices."
}
],
"temperature": 0.7
}'

Antwort:

{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "gpt-4.1-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "# Blog Post Outline: Sustainable Tech for Small Businesses\n\n## 1. Introduction\n- The growing importance of sustainability...\n\n## 2. Start with Energy Efficiency\n..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 245,
"total_tokens": 273,
"words_used": 364
}
}

Schritt 5: Antwort streamen

Fuer laengere Antworten verwenden Sie Streaming, um Chunks in Echtzeit ueber Server-Sent Events (SSE) zu empfangen:

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/content_generation/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "x-workspace-id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1-mini",
"messages": [
{
"role": "user",
"content": "Write a short paragraph about renewable energy benefits."
}
],
"stream": true
}'

SSE-Stream-Format:

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"In"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" today's"},"finish_reason":null}]}

...

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":15,"completion_tokens":150,"total_tokens":165}}

data: [DONE]

Schritt 6: Multi-Turn-Nachrichten

Geben Sie vorherige Nachrichten als Kontext in Folgeanfragen mit. Uebergeben Sie den vollstaendigen Nachrichtenverlauf in jeder Anfrage:

curl -X POST "https://app.neuroflash.com/api/ds-prototypes/content_generation/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "x-workspace-id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1-mini",
"messages": [
{"role": "user", "content": "Write an outline for a blog post about sustainable technology."},
{"role": "assistant", "content": "# Sustainable Technology Blog Post\n\n1. Introduction..."},
{"role": "user", "content": "Make it more conversational and add a real-world example."}
]
}'

Schritt 7: Brand Voice anwenden

Rufen Sie eine Brand Voice aus Ihrem Workspace ab und verwenden Sie deren Beschreibung als System-Nachricht fuer einen konsistenten Tonfall:

# Brand Voices auflisten
curl "https://app.neuroflash.com/api/brand-voice-service/v1/workspaces/{workspace_id}/brand-voices?page=1&size=10" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "x-workspace-id: YOUR_WORKSPACE_ID"

# Brand-Voice-Beschreibung als System-Nachricht verwenden
curl -X POST "https://app.neuroflash.com/api/ds-prototypes/content_generation/chat/completions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "x-workspace-id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1-mini",
"messages": [
{"role": "system", "content": "Follow this brand voice: YOUR_BRAND_VOICE_DESCRIPTION"},
{"role": "user", "content": "Write a product announcement for our new eco-friendly packaging."}
]
}'

Naechste Schritte