Skip to content

Pipelines

Execute full voice pipelines combining STT, LLM, and TTS in a single request.

Endpoint

POST /v1/audio/pipelines

Authentication

Authorization: Bearer gw_prod_...

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer token with API key
Content-TypeYesmultipart/form-data or application/json

Body Parameters

ParameterTypeRequiredDescription
audiofile/stringYesAudio file or base64-encoded audio
templatestringYesPipeline template ID
contextstringNoSystem prompt for LLM
streambooleanNoEnable streaming response
overridesobjectNoOverride template settings

Pipeline Templates

TemplateUse CaseComponents
voice-agent-fastReal-time assistantVoxtral → GPT-5-mini → ElevenLabs Turbo
voice-agent-premiumHigh-quality assistantWhisper → GPT-5.2 → ElevenLabs v2
ambient-scribeMedical transcriptionWhisper → GPT-5.2 + PII detection
legal-dictationLegal documentsWhisper → 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 TypeDescriptionData
transcription.partialPartial transcript{text}
transcription.finalFinal transcript{text}
llm.tokenLLM token{token}
llm.doneLLM complete{text}
audio.chunkTTS audio chunk{data} (base64)
donePipeline complete{usage, latency}
errorError 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

CodeDescription
400Invalid audio format or parameters
401Invalid API key
404Template not found
413Audio file too large
429Rate limit exceeded
500Pipeline execution error

See Also

Built with reliability in mind.