OpenCode
Configure Adaption as an inference provider in OpenCode and code with Adaption models.
OpenCode can use Adaption’s hosted models as an inference provider. Adaption serves the OpenAI Responses API, so OpenCode’s compatible Responses runtime connects without a plugin. You bring an Adaption API key and a model ID from Models.
You can also connect the Adaption MCP server separately to give OpenCode tools for interacting with the Adaption Platform.
Create and export an API key
Section titled “Create and export an API key”-
Sign in to Adaption.
-
Create a key and copy it. You will not be able to view the key again.
-
Export it as
ADAPTION_API_KEYso OpenCode can read it automatically:Terminal window export ADAPTION_API_KEY="pt_live_..."
Add the provider
Section titled “Add the provider”OpenCode reads project configuration from opencode.json(c) or .opencode/opencode.json(c) in the current directory, and global configuration from ~/.config/opencode/opencode.json(c). Use the global file to make Adaption available in every project.
Adaption’s inference endpoint implements the Responses API, so the provider uses the compatible Responses runtime package:
{ "$schema": "https://opencode.ai/config.json", "providers": { "adaption": { "name": "Adaption", "env": ["ADAPTION_API_KEY"], "package": "@opencode/ai/providers/openai-compatible/responses", "settings": { "baseURL": "https://api.prod.adaptionlabs.ai/api/v1", }, "models": { "qwen3.5-397b": { "name": "Qwen 3.5 397B", }, "glm-5.2": { "name": "GLM 5.2", }, "glm-5.3-flash": { "name": "GLM 5.3 Flash", }, "deepseek-v4-flash": { "name": "DeepSeek V4 Flash", }, "gemma-4-31b-it": { "name": "Gemma 4 31B IT", }, "gemma-4-26b-a4b-it": { "name": "Gemma 4 26B A4B IT", }, "qwen3.8-27b": { "name": "Qwen 3.8 27B", }, }, }, },}env tells OpenCode to send ADAPTION_API_KEY as Authorization: Bearer ... on every request. API keys are bound to an organization, so no X-Organization-Id header is needed. Add or remove entries in models to match what your key can access; see Models for the full list.
Config changes apply without a restart. OpenCode watches the file and reloads providers after a save.
Select a model
Section titled “Select a model”In the TUI, run /models and choose an entry. To set a default instead, set the top-level model field:
{ "$schema": "https://opencode.ai/config.json", "model": "adaption/qwen3.5-397b", "providers": { "adaption": { "env": ["ADAPTION_API_KEY"], "package": "@opencode/ai/providers/openai-compatible/responses", "settings": { "baseURL": "https://api.prod.adaptionlabs.ai/api/v1", }, "models": { "qwen3.5-397b": { "name": "Qwen 3.5 397B" }, }, }, },}Then ask OpenCode:
Explain this repository to me.
The response comes from the Adaption Responses API. Streaming works the same way it does for any OpenCode model.
Use an inference stack
Section titled “Use an inference stack”An inference stack is a saved configuration of a model, tools, datasets, and memory. Pass its name as stack:<name> through the same provider.
Stacks belong to your account and cannot be auto-discovered, so add one as a model entry whose key follows the stack:<name> pattern. The key is also what Adaption receives as the model:
{ "$schema": "https://opencode.ai/config.json", "providers": { "adaption": { "env": ["ADAPTION_API_KEY"], "package": "@opencode/ai/providers/openai-compatible/responses", "settings": { "baseURL": "https://api.prod.adaptionlabs.ai/api/v1", }, "models": { "stack:support-assistant": { "name": "Support Assistant Stack", }, }, }, },}Select adaption/stack:support-assistant in /models, or set "model": "adaption/stack:support-assistant". See Key concepts for how a stack’s model, tools, datasets, and memory apply to each request.
Optional: connect the MCP server
Section titled “Optional: connect the MCP server”To let OpenCode call Adaption’s dataset and AutoScientist tools, add the hosted MCP server as well. The CLI preserves unrelated configuration:
opencode mcp add adaption --global --url https://api.prod.adaptionlabs.ai/api/v1/mcpThen run /mcps, select the adaption server, and sign in with your Adaption account in the browser. No API key is needed for the MCP connection.
See MCP for the complete tool catalog. The MCP server is separate from the inference provider and does not affect model selection.
Troubleshooting
Section titled “Troubleshooting”Model unavailable: ...— The model key in themodelsmap is not what your key grants. For a hosted model, the key must match a model ID from Models. For a stack, the key must follow thestack:<name>pattern and match one of your stacks.- Requests fail with
401ormissing required scope(s).ADAPTION_API_KEYis unset in the OpenCode server’s environment, or the key was created with a scope list that lacksadaption-mcp:readoradaption-mcp:write. See Authentication and permissions. - A request returns
502or503. The model provider could not complete the request, or inference is not configured for this environment. Wait and retry; if it persists, check the model’s status in the Adaption app.
Next steps
Section titled “Next steps”- Models — full list of hosted models, context lengths, and modalities.
- Generate a model response — conversation state, streaming, tools, and image inputs.
- MCP — dataset and AutoScientist tools for OpenCode’s MCP client.