Skip to main content

AI Models & Chat

OpenChat uses OpenRouter as a unified gateway to access 100+ AI models from providers like OpenAI, Anthropic, Google, Meta, and more.

Overview

OpenChat supports two modes for AI access:

Dual Provider System

OSSChat Cloud (Default)

The free tier uses the server’s OpenRouter API key with daily limits:
  • Daily limit: ~10¢ worth of usage
  • Resets: Daily at midnight UTC
  • Models: All OpenRouter models available

BYOK (Bring Your Own Key)

Users can connect their own OpenRouter account for unlimited access:
  • No limits: Uses your own OpenRouter credits
  • All models: Including premium models
  • Privacy: API key stored locally (encrypted if saved to Convex)

Connecting OpenRouter (BYOK)

1

Open Settings

Click your profile in the sidebar, then click Settings.
2

Go to Providers Tab

Select the Providers tab to see connection options.
3

Connect OpenRouter

Click Connect OpenRouter. You’ll be redirected to OpenRouter to authorize.
OpenChat uses OAuth PKCE for secure key exchange. Your key is never exposed in URLs.
4

Authorize

On OpenRouter, authorize the application. You’ll be redirected back to OpenChat.
5

Start Using

Your models are now available! The provider switches to “Personal OpenRouter” automatically.

Model Selection

Using the Model Selector

Click the model name in the chat input to open the model selector:
  • Search: Type to filter models
  • Favorites: Star models for quick access
  • Details: See context window, pricing, capabilities

Model Capabilities

Models vary in their capabilities:

Reasoning Mode

For supported models, enable reasoning mode to see the AI’s thinking process:
Reasoning appears in a collapsible “Chain of Thought” section above the response.

Chat API

Endpoint

Request Body

Response

Returns a Server-Sent Events stream compatible with AI SDK 5’s useChat hook:

Example

Streaming Architecture

OpenChat uses AI SDK 5 for streaming:

Cancellation Support

Users can cancel in-progress responses:
OpenChat can search the web for current information:
Web search uses the Valyu AI SDK and requires VALYU_API_KEY to be configured.

Token Usage & Cost Tracking

Usage Display

Token usage is tracked and displayed per message:

Cost Calculation

For OSSChat Cloud, costs are tracked against the daily limit:

File Attachments

Upload images and documents to include in messages:

Limits

Prompt Templates

Create custom slash commands for frequently used prompts:

Template Variables

Configuration

Environment Variables

Rate Limits

The chat API is rate-limited to prevent abuse:

Troubleshooting

Check:
  1. Model is available (some are intermittently down)
  2. API key is valid (try regenerating)
  3. You have credits (for BYOK) or daily budget (for OSSChat)
This can happen if:
  1. Network connection drops
  2. Model reaches max tokens
  3. Rate limit exceeded
Try sending a shorter message or switching models.
Verify:
  1. VALYU_API_KEY is set on the server
  2. enableWebSearch: true in request
  3. Model supports tool use
For OSSChat Cloud, the 10¢ daily limit resets at midnight UTC. Options:
  1. Wait for reset
  2. Connect your own OpenRouter key (BYOK)

Next Steps

Self-Hosting

Deploy with your own API keys

Contributing

Add new model integrations