Skip to content
SupportLogin
Edit on GitHub

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.

  1. Sign in to Adaption.

  2. Open Settings, then API keys.

  3. Create a key and copy it. You will not be able to view the key again.

  4. Export it as ADAPTION_API_KEY so OpenCode can read it automatically:

    Terminal window
    export ADAPTION_API_KEY="pt_live_..."

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:

opencode.jsonc
{
"$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.

In the TUI, run /models and choose an entry. To set a default instead, set the top-level model field:

opencode.jsonc
{
"$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.

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:

opencode.jsonc
{
"$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.

To let OpenCode call Adaption’s dataset and AutoScientist tools, add the hosted MCP server as well. The CLI preserves unrelated configuration:

Terminal window
opencode mcp add adaption --global --url https://api.prod.adaptionlabs.ai/api/v1/mcp

Then 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.

  • Model unavailable: ... — The model key in the models map 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 the stack:<name> pattern and match one of your stacks.
  • Requests fail with 401 or missing required scope(s). ADAPTION_API_KEY is unset in the OpenCode server’s environment, or the key was created with a scope list that lacks adaption-mcp:read or adaption-mcp:write. See Authentication and permissions.
  • A request returns 502 or 503. 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.
  • 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.