This Docker image provides a complete and optimized environment to run the OpenCode AI server. It includes an integrated Translation Layer (Proxy) that makes OpenCode compatible with any tool that supports the OpenAI API.
- OpenAI Compatibility Proxy: Use OpenCode as if it were the OpenAI service. Compatible with LibreChat, Dify, TypingMind, etc.
- Streaming Support: Real-time responses via Server-Sent Events (SSE).
- Dynamic Model Mapping: Automatic support for multiple providers in
provider/modelformat. - Native API Exposed: Full access to OpenCode's original features and web interface.
- Secure by Default: Authentication via Bearer Token for the Proxy and Basic Auth for the native API.
- Data Persistence: Volumes configured to keep sessions, database, and settings.
- Permission Support (NAS): Supports
PUIDandPGIDvariables to avoid permission issues on network volumes.
Use the provided docker-compose.yml to spin up the service quickly:
-
Define your password in a
.envfile (or directly in the compose file):OPENCODE_PASSWORD=your_secret_password
-
Start the container:
docker-compose up -d
docker run -d \
--name opencode-server \
-p 4096:4096 \
-p 4097:4097 \
-e OPENCODE_SERVER_PASSWORD=your_secret_password \
-e PUID=1000 \
-e PGID=1000 \
-v opencode_data:/home/node/.local/share/opencode \
-v opencode_config:/home/node/.config/opencode \
ghcr.io/lucasliet/opencode-openai-proxy:latest| Port | Service | Description | Authentication |
|---|---|---|---|
| 4096 | OpenAI Proxy | OpenAI SDK/Tools compatible endpoint | Bearer <YOUR_PASSWORD> |
| 4097 | OpenCode Native | Original API and Web Interface (if available) | Basic opencode:<YOUR_PASSWORD> |
The proxy translates OpenAI format calls to the internal OpenCode SDK transparently.
- Base URL:
http://localhost:4096/v1 - API Key: Use the password defined in
OPENCODE_SERVER_PASSWORD. - Models: Use the
provider/model-idformat. Examples:opencode/gpt-5-nano(Free),anthropic/claude-3-5-sonnet.
curl http://localhost:4096/v1/chat/completions \
-H "Authorization: Bearer <YOUR_PASSWORD>" \
-H "Content-Type: application/json" \
-d '{
"model": "opencode/gpt-5-nano",
"messages": [{"role": "user", "content": "Hello, who are you?"}]
}'Simply add "stream": true to the payload and the proxy will send data word by word.
We ensure proxy stability through two test layers located in the tests/ folder:
- Unit Tests: Validates routing and mapping logic using SDK mocks.
./tests/test-unit.sh
- Integration Tests: Builds the actual Docker image and runs requests against a live OpenCode server.
./tests/test-integration.sh
The image is built on top of node:lts-slim to ensure it is lightweight and compatible.
docker build -t opencode-api .The container uses entrypoint.sh to start the OpenCode server in the background, wait for the health check, and then bring up the Express Proxy in the foreground.