Chat Server
Proxy Chat Server designed to work with the VitePress Chat plugin.
Secure your API key while live-streaming responses to the client.
Works out of the box with zero configuration using Docker or Node.
💯 100% Free to use with Zen OpenCode or Gemini Free Tier!
Works with Claude, Gemini, OpenAI, or any OpenAI Compatible Provider.
To get started Setup and Configure the server.
⚡ Ask AI with the Chat button in the bottom right...
Features
- Works with Claude, OpenAI, Gemini and OpenAI Compatible Providers
- Live Stream Results to Client
- Automatic Input Token Caching
- Automatic Retry on API Failures
- Deploy with Docker or Node
- Supports Multiple Clients Simultaneously
- Plus all the Client Features
Built with the AI SDK.
💡 If you need help getting started, support is available.
Setup
✅ The server works out-of-the box with NO environment variables.
With Docker.
docker run -p 3000:3000 cssnr/chat-server:latestWith Docker Compose.
services:
chat:
image: cssnr/chat-server:latest
environment:
MODEL: 'gemini-2.5-flash'
GOOGLE_GENERATIVE_AI_API_KEY: 'xxx'
ports:
- '3000:3000'With Node.
npm i
npm startNote: you will need to export your environment variables or set them in the settings.env file.
For a Docker Swarm + Traefik + Basic Auth example see the docker-compose-swarm.yaml.
For a Portainer Deploy workflow see the .github/workflows/deploy.yaml.
Configure
💡 All variables are optional. The default big-pickle model works with NO API Key.
Environment Variables.
| Variable | Default | Description |
|---|---|---|
MODEL | big-pickle | Model to Use |
BASE_URL | https://opencode.ai/zen/v1 | OpenAI Compatible Provider Base URL |
| PROVIDER_OPTIONS | - | Provider Options JSON String |
MAX_TOKENS | - | Max Output Tokens |
INSTRUCTIONS | - | Fallback System Instructions |
AI_SDK_LOG_WARNINGS | - | Disable SDK Warnings |
CORS_ORIGINS | - | Allowed CORS Origins (supports *) |
PORT | 3000 | Server Port |
You must also set the API key for the MODEL you select.
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | Claude Models |
GOOGLE_GENERATIVE_AI_API_KEY | Gemini Models |
OPENAI_API_KEY | OpenAI Models |
PROVIDER_API_KEY | OpenAI Compatible Provider |
The PROVIDER_API_KEY is optional for free-tier models like big-pickle.
PROVIDER_OPTIONS
Provider Options: https://vercel.com/docs/ai-gateway/models-and-providers/provider-options
For example, to disable "Reasoning" on big-pickle model.
{ "zen": { "thinking": { "type": "disabled" } } }You may need to wrap the variable in single quotes.
PROVIDER_OPTIONS='{"openai":{"serviceTier":"flex","reasoningEffort":"low"}}'You are responsible for providing valid options for the chosen model. The SDK supports providing provider options for multiple provider simultaneously. The value is only checked for valid JSON at startup and will fail at runtime if it contains invalid options.
Client
To send System Instructions from the client, add them to the body.
const chat = new Chat({
transport: new DefaultChatTransport({
api: 'https://chat-server.cssnr.com/',
headers: { Authorization: 'Basic Abc123=' },
body: { system: 'You are a helpful assistant.' },
}),
})Development
This works with no configuration using the big-pickle model.
You can set your environment variables in the settings.env file.
If using big-pickle for testing it is much faster to disable reasoning.
PROVIDER_OPTIONS='{"zen":{"thinking":{"type":"disabled"}}}'In all cases you can set the PORT environment variable.
With Node run.
npm run devPoint your client to: http://localhost:3000/
With Docker compose (you may need to touch settings.env).
docker compose -f docker-compose-dev.yaml up --watch --build --remove-orphansPoint your client to: http://localhost/
Building
To build and test the docker image run.
bash build.sh
docker compose up
Source Code: https://github.com/cssnr/chat-server