Open sourceOpenAI-compatibleopencode
opencode
Open-source terminal agent, works with any provider.
opencode configures each provider with a base URL rather than reading OPENAI_BASE_URL. The fastest way is the interactive login; for full control, edit the config file.
Setup steps
- 1
Install opencode
Requires Node.js 18 or newer. Installs the global opencode command.
bashnpm install -g opencode-ai - 2
Option A: quick login
Run the login command, scroll to "Other", then paste your base URL and API key.
bashopencode auth login - 3
Option B: config file
Declare an OpenAI-compatible provider with its base URL, key and model. Replace the values with your own.
~/.config/opencode/opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "custom": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://api.example.com/v1", "apiKey": "your-api-key" }, "models": { "your-model-name": {} } } } } - 4
Start coding
Launch it in your project folder and select your custom model with the /models command.
bashopencode
Tip: opencode does not read OPENAI_BASE_URL or OPENAI_API_KEY for custom endpoints. You must declare the provider, either via auth login or the config file.
Pick a cheaper model or provider first, then plug its key and endpoint into the steps above. Compare prices · Browse providers