> For the complete documentation index, see [llms.txt](https://docs.fastrouter.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastrouter.ai/api-reference/realtime.md).

# Realtime

## Create Realtime Session (WebSocket)

> Establishes a WebSocket connection for real-time audio and text conversations using OpenAI's Realtime API models.\
> \
> \*\*Connection URL:\*\*\
> \`\`\`\
> wss\://api.fastrouter.ai/v1/realtime?model=MODEL\_ID\
> \`\`\`\
> \
> \*\*Authentication:\*\* Pass your FastRouter API key via \`Authorization: Bearer\` header during the WebSocket handshake.\
> \
> \*\*Required header:\*\* \`OpenAI-Beta: realtime=v1\`\
> \
> \*\*Supported models:\*\* \`openai/gpt-4o-realtime-preview-2024-12-17\` and other OpenAI realtime models.

````json
{"openapi":"3.1.0","info":{"title":"FastRouter API Reference","version":"1.0.0"},"tags":[{"name":"Realtime","description":"WebSocket-based real-time audio and text conversations using OpenAI's Realtime API models."}],"servers":[{"url":"https://api.fastrouter.ai","description":"Production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"FastRouter API Key. Get yours at https://fastrouter.ai\n\nFormat: `Authorization: Bearer YOUR_API_KEY`"}},"responses":{"BadRequestError":{"description":"Bad Request - The request is malformed. This could be due to missing parameters, invalid formats, or routing errors.\n\n**Note:** the 400 body shape is not uniform. Validation errors return the structured object below, but routing/model errors may instead return a plain string: `{ \"error\": \"<message>\" }`. A few endpoints (e.g. some file operations) may return a plain-text body rather than JSON.","content":{"application/json":{"schema":{"oneOf":[{"type":"object","description":"Structured validation error.","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"}}}}},{"type":"object","description":"Plain-string routing/model error.","properties":{"error":{"type":"string"}}}]}}}},"UnauthorizedError":{"description":"Invalid Credentials - Your API key is invalid, missing, or disabled. Check your credentials.\n\nNote: the 401 error body uses `code`, `message`, `param`, and `type` (there is no `status` field), and `type` is `invalid_request_error`.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"param":{"type":"string","nullable":true},"code":{"type":"string"}}}}}}}}}},"paths":{"/v1/realtime":{"get":{"operationId":"connectRealtime","tags":["Realtime"],"summary":"Create Realtime Session (WebSocket)","description":"Establishes a WebSocket connection for real-time audio and text conversations using OpenAI's Realtime API models.\n\n**Connection URL:**\n```\nwss://api.fastrouter.ai/v1/realtime?model=MODEL_ID\n```\n\n**Authentication:** Pass your FastRouter API key via `Authorization: Bearer` header during the WebSocket handshake.\n\n**Required header:** `OpenAI-Beta: realtime=v1`\n\n**Supported models:** `openai/gpt-4o-realtime-preview-2024-12-17` and other OpenAI realtime models.","parameters":[{"name":"model","in":"query","required":false,"schema":{"type":"string","default":"gpt-4o-realtime-preview-2024-12-17"},"description":"The realtime model to use."}],"responses":{"200":{"description":"WebSocket connection established. Communicate using OpenAI Realtime API event format."},"400":{"$ref":"#/components/responses/BadRequestError"},"401":{"$ref":"#/components/responses/UnauthorizedError"}}}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fastrouter.ai/api-reference/realtime.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
