> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokios.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Tokios exposes private local models through https://api.tokios.com using an outbound-only connector tunnel.
> Use 'connector' for the local tokios-connector process.
> Use 'deployment' for the public model name in the API model field.
> Use 'upstream model id' for the model served by Ollama, llama.cpp, vLLM, LM Studio, or another local backend.
> API keys use the prefix sk-tok-. Connector tokens use the prefix ct-tok-.

# Use OpenCode with your own local model

> Add Tokios as an OpenAI-compatible provider in opencode.json so OpenCode's terminal agent can reach a local model on Ollama, LM Studio, or vLLM.

OpenCode is a terminal-based coding agent that supports custom model providers. Add Tokios as a provider in `opencode.json` using the `@ai-sdk/openai-compatible` package, point `options.baseURL` at `https://api.tokios.com/v1`, and list your Tokios deployment name under `models`. OpenCode then routes every agent request down your private connector tunnel to your local model.

## Prerequisites

* A running Tokios connector paired with your local model — see [Connector install](https://docs.tokios.com/setup/connector-install.md)
* A registered model deployment name — see [Register a model](https://docs.tokios.com/setup/register-model.md)
* A Tokios API key (`sk-tok-…`) — see [API keys](https://docs.tokios.com/setup/api-keys.md)
* OpenCode installed

## Configure OpenCode

Add a Tokios provider block to your `opencode.json` config. The exact config file location (project-local `opencode.json` vs. a global config path) and the precise key names (`options`, `npm`, `models`) can vary across OpenCode releases, so confirm them against your installed version's provider schema.

```json opencode.json theme={"theme":{"light":"github-light","dark":"css-variables"}}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "tokios": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Tokios",
      "options": {
        "baseURL": "https://api.tokios.com/v1",
        "apiKey": "sk-tok-YOUR_KEY"
      },
      "models": {
        "gemma-tunnel": {
          "name": "gemma-tunnel"
        }
      }
    }
  }
}
```

> [!NOTE]
>
> Replace `gemma-tunnel` with the **public deployment name** you registered on the [Models](https://tokios.com/console/models) tab — not the local model id your backend (Ollama, llama.cpp, vLLM, or LM Studio) uses. Replace `sk-tok-YOUR_KEY` with your own key, and avoid committing it into a shared or version-controlled config file.

> [!WARNING]
>
> `options.baseURL` must include `/v1`. OpenCode's OpenAI-compatible provider sends requests relative to this URL, so a base URL without `/v1` fails to reach the Tokios API surface.

## Pick a tool-capable model

OpenCode's agent relies on tool calling to read files, run commands, and edit code. Not every local model handles tool calls reliably — pick a deployment backed by a model with strong tool-calling support before you rely on OpenCode's agent for real edits. See [Choose a local model](https://docs.tokios.com/guides/choose-a-local-model.md) for how to compare candidates.

## Troubleshooting

> [accordion] 401 error
>
> The API key OpenCode sent is missing, malformed, or has been revoked. Confirm `options.apiKey` holds the full `sk-tok-…` key with no extra whitespace, and check its status on the [Keys](https://tokios.com/console/keys) tab.

> [accordion] 404 error
>
> The model key under `models` doesn't match a registered deployment. Confirm it exactly matches the public name on the [Models](https://tokios.com/console/models) tab — not your Ollama, llama.cpp, vLLM, or LM Studio local model id.

> [accordion] 503 error
>
> The connector for that deployment is offline or at its concurrency cap. Check the [Connectors](https://tokios.com/console/connectors) tab — the connector needs to show as **Online**, and the machine running it needs to still be up and reachable.

## Next steps

> [card] [Compatible clients](https://docs.tokios.com/guides/compatible-clients.md)
>
> See base URL and key setup for other OpenAI- and Anthropic-compatible clients.

> [card] [Choose a local model](https://docs.tokios.com/guides/choose-a-local-model.md)
>
> Compare backends and models before you commit a deployment to agentic workflows.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.