# WebSocket audio

How call audio reaches your agent, and how your agent ends the call.

When the call connects, Vonyx opens a WebSocket to your `websocket_url` and streams the call audio both ways.

## Audio

| Setting | Values |
| --- | --- |
| Sample rate | `8000` or `16000` Hz, from `sample_rate` |
| Format | `audio/x-l16` (16-bit PCM, default) or `audio/x-mulaw` (8-bit μ-law) |

<Callout title="Message format">
  The full message reference (start, audio and stop messages) is coming soon.
</Callout>

## Ending the call

**The callee hangs up.** The call ends and Vonyx closes the WebSocket.

**Your agent hangs up.** Send this message, and the call ends at once:

```json
{ "event": "hangup", "hangupType": "agent_ended" }
```

`hangupType` is required. Its value is recorded as the reason the call ended.

<Callout type="warn" title="Don't just close the socket">
  An unexpected close is treated as a dropped connection. Vonyx reconnects to your `websocket_url` up to 3 times before ending the call. Send the hangup message first.
</Callout>

## ElevenLabs agents

With `"ws_protocol": "elevenlabs"`, Vonyx speaks the ElevenLabs protocol. End the conversation from your agent, for example with ElevenLabs' `end_call` tool. The call ends when the agent closes the connection. See [ElevenLabs](/docs/integrations/elevenlabs).
