> For the complete documentation index, see [llms.txt](https://docs.otari.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.otari.ai/guides/integrations/opencode.md).

# opencode

[opencode](https://opencode.ai) can use any OpenAI-compatible backend as a provider, including Otari.

## Quick start

1. Create a key on the dashboard's **API keys** page.
2. Add Otari as a provider in your `opencode.jsonc`:

   ```jsonc
   {
     "provider": {
       "otari": {
         "npm": "@ai-sdk/openai-compatible",
         "options": {
           "baseURL": "https://api.otari.ai/api/v1",
           "apiKey": "{env:OTARI_API_KEY}"
         }
       }
     }
   }
   ```
3. Export the key and run opencode with a model:

   ```bash
   export OTARI_API_KEY=<your-otari-key>
   opencode --model otari/openai:gpt-4o
   ```

`baseURL` ends in `/api/v1`; opencode adds `/chat/completions` itself. EU accounts use `https://eu.api.otari.ai/api/v1`, and a gateway you run uses its URL plus `/api/v1`. See [Base URL](https://docs.otari.ai/reference#base-url).

## Choosing a model

opencode names a model `<provider id>/<model>`, and everything after `otari/` goes to Otari unchanged, so write it as Otari spells it:

* On otari.ai, a catalog id such as `otari/deepseek/deepseek-v4.1-flash` lets Otari choose the provider, and `otari/anthropic:claude-sonnet-4-6` pins one.
* On your own gateway, use `provider:model` for a provider it has, such as `otari/openai:gpt-4o`.

See [Model format](https://docs.otari.ai/reference/gateway/models#model-format) and [Listing available models](https://docs.otari.ai/reference/gateway/models#listing-available-models).

To list only the open-weight models a key can use, ask the catalog for them: `GET /api/v1/catalog/models?capability=open_weights`. Each entry's `selectors` are the names to configure.

## See also

* [Claude Code](https://docs.otari.ai/guides/integrations/claude-code.md)
* [Codex](https://docs.otari.ai/guides/integrations/codex.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.otari.ai/guides/integrations/opencode.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
