Appearance
Pipelines
Execute full voice pipelines combining STT, LLM, and TTS in a single request.
Endpoint
POST /v1/audio/pipelinesAuthentication
Authorization: Bearer gw_prod_...Request
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer token with API key |
Content-Type | Yes | multipart/form-data or application/json |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
audio | file/string | Yes | Audio file or base64-encoded audio |
template | string | Yes | Pipeline template ID |
context | string | No | System prompt for LLM |
stream | boolean | No | Enable streaming response |
overrides | object | No | Override template settings |
Pipeline Templates
| Template | Use Case | Components |
|---|---|---|
voice-agent-fast | Real-time assistant | Voxtral → GPT-5-mini → ElevenLabs Turbo |
voice-agent-premium | High-quality assistant | Whisper → GPT-5.2 → ElevenLabs v2 |
ambient-scribe | Medical transcription | Whisper → GPT-5.2 + PII detection |
legal-dictation | Legal documents | Whisper → GPT-5.2 + formatting |
Examples
Basic Pipeline
bash
curl -X POST https://api.gateflow.ai/v1/audio/pipelines \
-H "Authorization: Bearer gw_prod_..." \
-F "audio=@question.mp3" \
-F "template=voice-agent-fast" \
-F "context=You are a helpful assistant."Python
python
import requests
import base64
# With file upload
with open("question.mp3", "rb") as f:
response = requests.post(
"https://api.gateflow.ai/v1/audio/pipelines",
headers={"Authorization": "Bearer gw_prod_..."},
files={"audio": f},
data={
"template": "voice-agent-fast",
"context": "You are a helpful assistant."
}
)
result = response.json()
print(f"Transcription: {result['transcription']}")
print(f"Response: {result['response']}")
# Save audio response
audio_bytes = base64.b64decode(result["audio"])
with open("response.mp3", "wb") as f:
f.write(audio_bytes)With Base64 Audio
python
import base64
with open("question.mp3", "rb") as f:
audio_b64 = base64.b64encode(f.read()).decode()
response = requests.post(
"https://api.gateflow.ai/v1/audio/pipelines",
headers={
"Authorization": "Bearer gw_prod_...",
"Content-Type": "application/json"
},
json={
"audio": audio_b64,
"template": "voice-agent-fast",
"context": "You are a helpful assistant."
}
)Streaming Pipeline
python
import httpx
import json
import base64
async def stream_pipeline(audio_file):
with open(audio_file, "rb") as f:
audio_b64 = base64.b64encode(f.read()).decode()
async with httpx.AsyncClient() as client:
async with client.stream(
"POST",
"https://api.gateflow.ai/v1/audio/pipelines",
headers={
"Authorization": "Bearer gw_prod_...",
"Content-Type": "application/json"
},
json={
"audio": audio_b64,
"template": "voice-agent-fast",
"stream": True
}
) as response:
async for line in response.aiter_lines():
event = json.loads(line)
if event["type"] == "transcription.partial":
print(f"Hearing: {event['text']}")
elif event["type"] == "transcription.final":
print(f"You said: {event['text']}")
elif event["type"] == "llm.token":
print(event["token"], end="", flush=True)
elif event["type"] == "audio.chunk":
audio = base64.b64decode(event["data"])
play_audio(audio)
elif event["type"] == "done":
print("\n--- Complete ---")Template Overrides
python
response = requests.post(
"https://api.gateflow.ai/v1/audio/pipelines",
headers={
"Authorization": "Bearer gw_prod_...",
"Content-Type": "application/json"
},
json={
"audio": audio_b64,
"template": "voice-agent-fast",
"overrides": {
"llm": {
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 300
},
"tts": {
"voice": "professional",
"speed": 1.1
}
}
}
)Medical Scribe
python
response = requests.post(
"https://api.gateflow.ai/v1/audio/pipelines",
headers={"Authorization": "Bearer gw_prod_..."},
files={"audio": open("patient_visit.mp3", "rb")},
data={"template": "ambient-scribe"}
)
result = response.json()
print(f"Transcription: {result['transcription']}")
print(f"Clinical Note: {result['structured_note']}")
print(f"PII Detected: {result['pii_detected']}")Response
Standard Response
json
{
"id": "pipeline_abc123",
"transcription": "What's the weather like today?",
"response": "I don't have access to real-time weather data, but I can help you find a weather service or app that can provide current conditions for your location.",
"audio": "base64_encoded_audio_data...",
"audio_format": "mp3",
"usage": {
"stt_seconds": 3.5,
"llm_tokens": {"prompt": 45, "completion": 52},
"tts_characters": 156
},
"latency": {
"stt_ms": 450,
"llm_ms": 380,
"tts_ms": 320,
"total_ms": 1150
},
"providers": {
"stt": "mistral",
"llm": "openai",
"tts": "elevenlabs"
}
}Ambient Scribe Response
json
{
"id": "pipeline_abc123",
"transcription": "Patient reports headache for three days, took ibuprofen with minimal relief...",
"structured_note": {
"chief_complaint": "Headache",
"duration": "3 days",
"symptoms": ["headache", "fatigue"],
"medications_mentioned": ["ibuprofen"],
"allergies_mentioned": [],
"vital_signs": null
},
"pii_detected": [
{"type": "patient_name", "value": "[REDACTED]", "confidence": 0.95}
],
"audit_id": "audit_xyz789",
"compliance": {
"hipaa": true,
"audit_logged": true
}
}Streaming Events
| Event Type | Description | Data |
|---|---|---|
transcription.partial | Partial transcript | {text} |
transcription.final | Final transcript | {text} |
llm.token | LLM token | {token} |
llm.done | LLM complete | {text} |
audio.chunk | TTS audio chunk | {data} (base64) |
done | Pipeline complete | {usage, latency} |
error | Error occurred | {message, recoverable} |
Custom Pipelines
Create Custom Template
bash
curl -X POST https://api.gateflow.ai/v1/management/pipeline-templates \
-H "Authorization: Bearer gw_prod_admin_key" \
-H "Content-Type: application/json" \
-d '{
"name": "my-custom-pipeline",
"stt": {
"model": "whisper-1",
"language": "en"
},
"llm": {
"model": "gpt-5.2",
"system_prompt": "You are a customer service agent.",
"max_tokens": 200,
"temperature": 0.7
},
"tts": {
"model": "eleven_turbo_v2_5",
"voice": "friendly"
}
}'List Templates
bash
curl https://api.gateflow.ai/v1/management/pipeline-templates \
-H "Authorization: Bearer gw_prod_..."Errors
| Code | Description |
|---|---|
| 400 | Invalid audio format or parameters |
| 401 | Invalid API key |
| 404 | Template not found |
| 413 | Audio file too large |
| 429 | Rate limit exceeded |
| 500 | Pipeline execution error |
See Also
- Pipeline Templates - Template configuration
- Streaming Speech - Streaming guide
- Transcriptions - STT API
- Speech Synthesis - TTS API