Configure OpenCode

OpenCode calls InOneAPI through the @ai-sdk/openai-compatible provider. Model configuration and credentials are stored separately: the provider definition goes in the configuration file, and the API key goes in the local credentials file.

Configure the provider

Create or open ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "inoneapi/YOUR_MODEL_ID",
  "provider": {
    "inoneapi": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "InOneAPI",
      "options": {
        "baseURL": "https://api.inoneapi.com/v1"
      },
      "models": {
        "YOUR_MODEL_ID": {
          "name": "YOUR_MODEL_ID"
        }
      }
    }
  }
}

Note that model combines OpenCode's provider name with the InOneAPI model ID, in the form inoneapi/YOUR_MODEL_ID.

Store credentials through the client

  1. Start opencode and enter /connect.
  2. Choose Other, and set the provider ID to inoneapi, exactly matching the key in the configuration file.
  3. Paste your InOneAPI API key and let OpenCode store the credential. You do not need to create or edit auth.json.
  4. /connect only stores the credential. It does not define the endpoint and models for a custom provider, so the opencode.json above is still required.

The default configuration path is ~/.config/opencode/opencode.json, and on Windows %USERPROFILE%\.config\opencode\opencode.json. When XDG_CONFIG_HOME is set, use the opencode directory inside it.

Start and verify

Run opencode inside a test repository, enter /models, and confirm that inoneapi/YOUR_MODEL_ID is selected. Send a task that does not modify files first, then check the trace, tokens and cost in the console.

Common issues

  • Provider not listed: check the JSON syntax, $schema, and whether provider.inoneapi sits in the root object.
  • Model not found: model needs the inoneapi/ prefix, while the keys under models contain only the InOneAPI model ID.
  • 401: the provider key in the credentials file must also be inoneapi.
  • Incomplete tool calling: confirm that the model supports tool calling. OpenAI-compatible only means protocol compatibility; it does not mean every model has the same capabilities.

To configure several models, add entries under models, and re-check the project's model restrictions after switching.

Optional: import into CC Switch

On the model detail page, select this tool and an API key, then click “Open CC Switch and import”. Use the official CC Switch release; the import link already contains the current model ID, so you do not need to enter it again. After confirming the import, finish the connection by enabling the provider and setting the default model for this tool. If it reports that this app is unsupported, update CC Switch or follow the manual steps in this document.

The import link only adds a provider. It does not mean the model is already the default or that a request succeeded. The link contains an API key, so do not share it. Use either the manual setup or the CC Switch import, not both.

After a CC Switch import you still select the model with /models. Use the provider ID from the imported result, and do not create another provider with the same name.

Official reference: OpenCode custom provider.

OpenCode · Documentation · InOneAPI