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
- Plus all the Client Features
Built with the AI SDK.
Setup
With Docker.
docker run --rm -p 80:3000 ghcr.io/cssnr/chat-server:latestWith Docker Compose.
services:
chat:
image: ghcr.io/cssnr/chat-server:latest
environment:
MODEL: 'gemini-2.5-flash'
GOOGLE_GENERATIVE_AI_API_KEY: 'xxx'
ports:
- '80:3000'With Node.
npm i
npm startNote: you will need to export or add your environment variables to 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
If the MODEL is not provided big-pickle will be used which works without an API key.
Environment Variables.
| Variable | Default | Description |
|---|---|---|
MODEL | - | Model to Use |
MAX_TOKENS | - | Max Output Tokens |
INSTRUCTIONS | - | System Instructions |
AI_SDK_LOG_WARNINGS | - | Disable SDK Warnings |
CORS_ORIGINS | - | Allowed CORS Origins (supports *) |
BASE_URL | https://opencode.ai/zen/v1 | OpenAI Compatible Provider Base URL |
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.
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.
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