Introduction
OneChatAPI is a unified REST and WebSocket API that gives you access to 12+ AI model providers — OpenAI, Anthropic, Google Gemini, Mistral, Cohere, Replicate, Perplexity, X.AI, Qwen, ElevenLabs, and Gemini Live — through a single consistent interface.
The API handles streaming chat via Server-Sent Events, real-time bidirectional chat over WebSocket, real-time voice conversations via audio WebSocket, conversation management, user profiles, team organizations, subscriptions, and file attachments.
Authentication
Authenticate by obtaining a JWT token via the sign-in endpoint and including it in every request as a Bearer token. Tokens do not expire by default.
JWT Bearer Token
Pass your token in the Authorization header on every protected request:
Sign In
Exchange email and password for a JWT token. The token is used in all subsequent requests.
Response
Guest Access
Publicly shared conversations can be read without a JWT token. Pass the guest token in the Authorization-Guest header instead:
Streaming Chat (SSE)
The primary chat endpoint streams the model response as Server-Sent Events in an OpenAI-compatible chunk format. Each data: line contains a JSON object with a choices[].delta.content field. The stream ends with data: [DONE].
Send Message
Response Format
Each event is a JSON object following the OpenAI streaming chunk format. The final chunk before [DONE] includes a usage object with token counts and cost.
Parameters
Request body fields:
| Field | Type | Required | Description |
|---|---|---|---|
| message | string | yes | User message content |
| model | string | yes | Model ID from /api/chat/models |
| conversationID | string | no | Existing conversation ID; empty string creates a new conversation |
| context | string | no | System-level context override |
| profileID | string | no | Reusable system prompt profile ID |
| instructions | string | no | One-off system instruction appended to context |
| image | string | no | Image URL for vision models |
| attachments | []string | no | Array of file attachment IDs (from /api/files) |
| parentId | string | no | Parent message ID for branched conversations |
| hiddenFromBot | bool | no | Store message in history but do not send to model |
| code | bool | no | Hint that response should be code-focused |
WebSocket Chat
For bidirectional real-time communication, connect to the WebSocket endpoint. The server sends the same streaming chunk format as SSE. Authentication uses the JWT token as a query parameter because browser WebSocket APIs do not support custom headers.
Connect
Pass the JWT via the ?token= query parameter. Use an empty GUID or new as the conversation ID to create a new conversation on first message.
Send & Receive
After connecting, send a JSON object with the message and model. The server streams back chunks in the same format as the SSE endpoint.
Realtime Audio
Connect to the audio WebSocket to stream microphone input and receive synthesized speech in real time. Raw PCM16 audio bytes are sent as binary WebSocket frames; the server responds with transcript events and base64-encoded audio chunks.
Connect
Pass all configuration as query parameters. Authentication uses token= (same as WebSocket chat).
Parameters
Query parameters for the audio WebSocket:
| Param | Required | Values | Description |
|---|---|---|---|
| model | yes | gpt-4o-realtime-preview | Audio model ID |
| provider | yes | openai, google, elevenlabs | Audio provider |
| voice | no | alloy, echo, shimmer, nova, onyx, fable | TTS voice to use |
| format | no | pcm16, opus, g711_ulaw | Audio encoding format (default: pcm16) |
| token | yes | JWT | Auth token passed as query string for WS auth |
Events
The server sends JSON events over the WebSocket. The type field indicates the event kind:
| type | Description |
|---|---|
| transcript | Text transcription of the user's spoken input |
| audio | Base64-encoded audio response chunk (PCM16 by default) |
| done | Session or response turn has ended |
| error | Error message in the message field |
Example events:
Voices & Providers
Fetch the list of available voices and audio providers for the authenticated user:
Sessions
Audio sessions are automatically recorded. Retrieve past sessions or check for active ones:
Response
Models
Retrieve the models available to the authenticated user or the complete catalog with full metadata including context window size, capabilities, and pricing.
List Available
Returns only the models the authenticated user can access based on their subscription tier.
Full Catalog
Returns all models with complete metadata. Model object schema:
Response
Providers
Capabilities by provider:
| Provider | streaming | vision | audio | embeddings |
|---|---|---|---|---|
| OpenAI | ✓ | ✓ | ✓ | ✓ |
| Anthropic | ✓ | ✓ | — | ✓ |
| Google Gemini | ✓ | ✓ | ✓ | ✓ |
| Mistral | ✓ | — | — | ✓ |
| Cohere | ✓ | — | — | ✓ |
| Replicate (Llama) | ✓ | — | — | — |
| Perplexity | ✓ | — | — | — |
| X.AI (Grok) | ✓ | — | — | — |
| Qwen | ✓ | — | — | — |
| ElevenLabs | — | — | ✓ | — |
| Gemini Live | — | — | ✓ | — |
Conversations
Conversations are automatically created when you send a message with an empty conversationID. They persist all messages and can be updated, archived, shared publicly, or searched.
List
Returns all conversations for the authenticated user, ordered by last activity.
Get with Messages
Returns the conversation metadata and its full message history.
Update
Update the title, model, or other metadata of a conversation.
Delete
Permanently delete a conversation and all its messages.
Archive
Archive a conversation to hide it from the default list without deleting it.
Share Publicly
Make a conversation publicly readable. Anyone with the conversation ID can then read it using a guest token.
Search
Full-text search across all conversation titles and messages.
Profiles
Profiles are reusable sets of system instructions and model parameter overrides (temperature, top_p, etc.). They let you define a persona or task-specific assistant once and reuse it across many conversations.
Using Profiles
Include the profileID field in any chat request to apply that profile's system prompt and parameter overrides to the conversation:
Search
Search profiles by name or description.
User & Usage
Retrieve the authenticated user's account information, token usage statistics, and manage their default model.
Get Current User
Usage Statistics
Returns message count, total tokens consumed, total cost in USD, and a per-model breakdown.
Response
Set Default Model
Set the model that is pre-selected for new conversations in the web app.
Teams
Organize users into organizations with role-based access. Roles are member and admin. Admins can invite members and change roles.
Create Organization
Invite Member
Send an invitation email to a new team member.
Update Role
Change a team member's role. Only admins can perform this action.
Subscriptions
Plans: free · starter · pro · max · team. Models have a min_subscription_level field — higher-tier models require a paid plan.
Current Plan
Returns the authenticated user's active subscription details.
List Plans
Returns all available subscription plans and their features.
Checkout
Create a Stripe checkout session. Redirect the user to the returned URL to complete payment.
Response
File Uploads
Upload images or documents to attach to chat messages. Pass the returned file id in the attachments array of a chat request. Files are scoped to a profile.
Response
Errors & Rate Limits
All errors return a JSON body with a human-readable message and a machine-readable error code:
HTTP Status Codes
| Status | Meaning |
|---|---|
| 200 | Success |
| 400 | Invalid request body or missing required fields |
| 401 | Missing or invalid JWT token |
| 403 | Insufficient subscription tier for the requested model |
| 404 | Resource not found |
| 429 | Rate limit exceeded — back off and retry |
| 500 | Internal server error |
Rate Limits
Default rate limit is 30 requests per minute per IP address on all routes. When exceeded, the API returns a 429 response:
Implement exponential backoff when retrying after a 429. The Retry-After header indicates the number of seconds to wait before the next attempt.