OpenCode
Configure OpenCode, the open-source AI coding assistant, to route through Arvika Labs for unified model access and billing.
Model slugs in examples are illustrative. Confirm current availability in the live catalog and your account's /v1/models before use.
What This Does
OpenCode is an open-source AI coding assistant for the terminal. It supports 75+ LLM providers and local models out of the box. By configuring it to use Arvika Labs's OpenAI-compatible endpoint, you can access any supported model through a single account while keeping all your AI spending consolidated.
Setup
Step 1: Install OpenCode
curl -fsSL https://opencode.ai/install.sh | bashOr via npm:
npm install -g opencode-aiStep 2: Configure the Provider
OpenCode uses a JSON config file. Create or edit opencode.json in your project root (or globally at ~/.config/opencode/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openai": {
"options": {
"baseURL": "https://api.labs.arvikaconsulting.com/v1"
}
}
},
"model": "openai/kimi-k2.6",
"small_model": "openai/glm-5.3-flash"
}Replace the API key placeholder with your actual key from labs.arvikaconsulting.com/keys.
Step 3: Set Your API Key
Run the built-in auth command to store your Arvika Labs API key:
opencode auth loginSelect OpenAI as the provider and paste your Arvika Labs API key when prompted. Credentials are stored in ~/.local/share/opencode/auth.json.
Alternatively, set the environment variable:
export OPENAI_API_KEY="YOUR_Arvika Labs_API_KEY"Step 4: Verify the Connection
Launch OpenCode and select your model:
opencodeUse the /models command inside the TUI to confirm your models are available.
Recommended Models for OpenCode
| Use Case | Model | Why |
|---|---|---|
| Complex reasoning & planning | openai/kimi-k2.6 | Highest capability |
| Code generation & refactoring | openai/deepseek-v4-pro | Optimized for code |
| Large codebase analysis | openai/minimax-m3 | 1M+ token context |
| Quick operations | openai/glm-5.3-flash | Fast, 1M-token context |
| Budget workloads | openai/glm-5.3-flash | $0.075 input / $0.25 output per 1M tokens |
Non-Interactive Usage
Run a single prompt without launching the TUI:
opencode run "Explain how closures work in JavaScript"Specify a model directly:
opencode run -m openai/deepseek-v4-pro "Refactor this function"Troubleshooting
Provider not showing models
- Verify the
baseURLis exactlyhttps://api.labs.arvikaconsulting.com/v1(no trailing slash) - Run
opencode auth listto confirm your API key is stored - Try
opencode models --refreshto update the cached model list
Authentication errors
- Ensure your Arvika Labs API key is set via
opencode auth loginor theOPENAI_API_KEYenvironment variable - Check that your key is valid at labs.arvikaconsulting.com/keys
Model not found errors
- Use model names in the
provider/modelformat (e.g.,openai/kimi-k2.6) - Run
opencode models openaito list available models from the OpenAI provider
Connection timeout
- Verify your network can reach
api.labs.arvikaconsulting.com - Try increasing the timeout in your provider config:
{
"provider": {
"openai": {
"options": {
"baseURL": "https://api.labs.arvikaconsulting.com/v1",
"timeout": 600000
}
}
}
}Notes
- OpenCode model names use the
provider/modelformat — prefix Arvika Labs models withopenai/ - The
small_modelsetting is used for lightweight tasks like title generation — set it to a low-cost model - Config can be placed globally (
~/.config/opencode/opencode.json) or per-project (opencode.jsonin project root) - All token consumption appears in your Arvika Labs dashboard in real-time