# talk

> Start a live voice call between a user and your agent.

Start a live voice call between one of your users and Bash. Create a session (a short-lived link for that user), open its url, and the page joins the call. Everything said in the call is saved to the same conversation as text.

## TypeScript

```ts
// Ask something first. The call below joins this conversation.
const traveller = vestra.user('traveller-42');
const run = traveller.ask('Find me a flight to Goa on Friday.');
await run.text();

// Call in an existing conversation. Open call.url, and the page joins the call.
const call = await traveller.talk({ conversation: run.conversation! });
console.log(call.url);

// Start a new conversation by voice.
const fresh = await traveller.talk();
await fresh.end();
```

## Python

```python
# Ask something first. The call below joins this conversation.
traveller = vestra.user("traveller-42")
run = traveller.ask("Find me a flight to Goa on Friday.")
run.text()

# Call in an existing conversation. Open call.url, and the page joins the call.
call = traveller.talk(conversation=run.conversation)
print(call.url)

# Start a new conversation by voice.
fresh = traveller.talk()
fresh.end()
```

## CLI

```bash
# Call in an existing conversation. You get a link, and what is said is saved to that conversation.
vestra talk --user traveller-42 --conversation conv_8f2k
```

## HTTP

```bash
# Call in an existing conversation. Open the session's url, and the page joins the call.
curl "$VESTRA_BASE_URL/v1/sessions" \
  -H "Authorization: Bearer $VESTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "user_id": "traveller-42", "conversation_id": "conv_8f2k", "voice": true }'

# Connect your own voice client. The session's page does this for you: it sends the browser's WebRTC offer
# with the session's own token, and gets the answer back. Call it yourself only if you build your own client.
curl "$VESTRA_BASE_URL/v1/sessions/ses_8h2/voice" \
  -H "Authorization: Bearer $SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "sdp": "the WebRTC offer from the browser" }'
```

## MCP

```json
{
  "method": "tools/call",
  "params": {
    "name": "talk",
    "arguments": { "user": "traveller-42", "conversation": "conv_8f2k" }
  }
}
```

## Good to know

### When the call ends

The `session.ended` event carries the call's length in `seconds`, and its `transcript`.

### Which setup answers the call

Bash answers with the conversation's deployment, which is your agent's setup. If the conversation has none, it uses the user's default deployment, and then your company's.

### Building your own voice client

The session's page sends the browser's WebRTC offer to `POST /v1/sessions/{id}/voice` with the session's token. Call this route yourself only if you build your own voice client. Vestra accepts calls only from its own page and from your allowed origins.

## The routes behind talk

- `POST` [/v1/sessions/{session_id}/voice](https://vestra.ai/developers/reference/api/sessions/post-v1-sessions-session-id-voice.md): Called from the user's browser with the session's token and its WebRTC offer; answers the model's answer. Audio then flows straight to the voice model, and everything said lands in the session's conversation. For a session opened with voice.

Next: [`events`](https://vestra.ai/developers/events.md)
