OpenCode integration
Point the OpenCode terminal agent at Modellane through a custom OpenAI-compatible provider block in its configuration.
OpenCode supports custom OpenAI-compatible providers. Declare Modellane once in its configuration and select a model when you start a session.
OpenCode is a coding agent for the terminal. It supports custom OpenAI-compatible providers through the @ai-sdk/openai-compatible package, which calls the Chat Completions API (POST /v1/chat/completions).
Configure the provider#
Create or edit opencode.json in your project, or ~/.config/opencode/opencode.json for every project:
JSON
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"modellane": {
"npm": "@ai-sdk/openai-compatible",
"name": "Modellane",
"options": {
"baseURL": "https://usemodellane.com/v1",
"apiKey": "{env:MODELLANE_API_KEY}"
},
"models": {
"lane-1": {
"name": "Lane 1",
"limit": { "context": 128000, "output": 8192 }
}
}
}
}
}Replace the two limit numbers with the context length and output limit of the model from Models & pricing, and add one entry under models for each model you want to use.
Use @ai-sdk/openai-compatible, not @ai-sdk/openai: the second package targets OpenAI's own API. Instead of {env:MODELLANE_API_KEY} you can also store the key with /connect inside OpenCode (choose Other and the provider id modellane).
Export the key in your shell, then start OpenCode in your project and pick the model with /models:
Shell
export MODELLANE_API_KEY="your-api-key"
cd your-project
opencodeVerify#
Send a short prompt such as "Reply with the word ready." A reply means the provider works. An authentication error points at the key, and model_not_found at the model id.