SAGEA LogoDocs & API
CookbooksMYLO Cookbooks

Run Your First MYLO Agent Session

Create a real-time MYLO voice session with the nova voice and hear it speak in seconds.

  • Create a session with agent_id, model, voice, and language
  • Stream 16kHz PCM audio over WebSocket with ~200ms first byte
  • End the session and fetch the speaker timestamped transcript Time to complete: ~10 minutes

Prerequisites

  • SAGEA_API_KEY exported in your shell as Bearer auth
  • Python 3.10+ with requests and websocket-client installed
  • Basic familiarity with REST APIs and WebSockets
  • Complete Send your first API request
  • Read the MYLO overview import from '@/components/Tabs';

Step 1: Create a session

Create a session with support_np, sage-2-5-celer, nova, and ne-NP.

curl -X POST https://api.sagea.space/mylo/sessions \
  -H "Authorization: Bearer $SAGEA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agent_id":"support_np","model":"sage-2-5-celer","voice":"nova","language":"ne-NP","system_prompt":"You are a friendly Nepali support agent. Greet briefly."}'

Save session_id and websocket_url. Sessions expire in 3600 seconds.

Step 2: Connect and speak your first line

Connect to websocket_url, stream 16kHz PCM in, and receive speech out.

# Replace WS_URL with websocket_url from Step 1
wscat -c "$WS_URL" -H "Authorization: Bearer $SAGEA_API_KEY"
# Binary frames in: 16kHz PCM. Audio out streams back with ~200ms first byte.

Speak once, then keep the socket open until the agent reply finishes.

Step 3: Read the transcript and end the session

Fetch turns with speaker, text, and timestamps, then delete the session.

SESSION_ID="mylo_ses_REPLACE_ME"
curl https://api.sagea.space/mylo/sessions/$SESSION_ID/transcript \
  -H "Authorization: Bearer $SAGEA_API_KEY"
curl -X DELETE https://api.sagea.space/mylo/sessions/$SESSION_ID \
  -H "Authorization: Bearer $SAGEA_API_KEY"

Always fetch the transcript before delete so you keep the record.

Verify

ErrorCauseFix
401 UnauthorizedMissing or invalid API keyExport valid SAGEA_API_KEY and retry
404 session_not_foundWrong or expired session_idCreate a new session, check spelling
429 rate_limit_exceededToo many session createsBack off and retry with jitter
422 voice_not_foundUnknown voice nameUse nova or atlas, check spelling

What's next

On this page