Speko Docs

Mint a session on your backend

Create the voice session on your server and hand the mobile app only short-lived transport credentials.

Add one endpoint to your backend that creates a Speko session and returns three fields to the app. The mobile SDKs need nothing else.

// Server-side. SPEKO_API_KEY never leaves this process.
app.post('/api/voice-session', async (req, res) => {
  const session = await fetch('https://api.speko.dev/v1/sessions', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.SPEKO_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ mode: 'cascade', agentId: process.env.SPEKO_AGENT_ID }),
  }).then((r) => r.json());

  res.json({
    transport: session.transport,
    transportToken: session.transportToken,
    transportUrl: session.transportUrl,
  });
});

Always forward transport

Agents that run on Pipecat return transport: 'daily', and the SDK picks the media stack from this field. Without it, the SDK assumes LiveKit and the connection fails.

Authenticate the request

Protect the endpoint with your own app login. Anyone who can call it can start a billed session on your account. Rate-limit it per user.

Per-session values

Set per-caller values on this same request: variables, toolSecrets, webhookTags and preCallWebhook. The app cannot read or change them. The field table is in Per-session variables, and the full request is in the sessions API reference.

Token lifetime

The transport token is short-lived and works for one session. Mint a new session for every call. Don't cache tokens on the device or reuse them after a call ends.

Next step

Connect from the app: Swift, Kotlin, React Native or Flutter.

On this page