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

# OpenCode

> Open source agent supporting 75+ LLM providers with privacy-focused architecture

## Overview

OpenCode is an open source coding agent that supports 75+ LLM providers. In Blocks, OpenCode runs Anthropic, OpenAI, Moonshot AI and Google models, using either your own provider keys, an OpenCode Zen or OpenCode Go key, or Blocks LLM credits. With over 650,000 monthly users, OpenCode offers a privacy-focused approach where no code is stored on external servers.

<Warning>
  OpenCode is currently **experimental** and may have different behavior or limitations compared to stable agents like Claude Code or Codex.
</Warning>

## Latest Models

In Blocks, OpenCode can run the following models:

* **Anthropic**: Claude Opus 5, Claude Sonnet 5, Claude Fable 5.1, Claude Opus 4.8, Claude Sonnet 4.6, Claude Haiku 4.5
* **OpenAI**: GPT-5.6 Luna, GPT-5.6 Terra, GPT-5.6 Sol, GPT-5.5, GPT-5.4
* **Moonshot AI**: Kimi K2.5, Kimi K2.6, Kimi K2.7 Code, Kimi K3
* **Google**: Gemini 3.1 Pro Preview, Gemini 3.7 Flash, Gemini 2.5 Pro

<Note>
  Which of these you can select depends on the authentication method. A provider API key covers that provider's models, OpenCode Zen covers everything except Gemini 2.5 Pro, OpenCode Go covers five models, and Blocks covers the full list.
</Note>

## Authentication

OpenCode supports several authentication methods. Pick one under **Settings** → **Agents** → **OpenCode** → **Authentication Method**:

<Tabs>
  <Tab title="Anthropic API Key">
    **Use Anthropic models (Claude Opus 5, Sonnet 5)**

    1. Get an API key at [Anthropic Console](https://console.anthropic.com/)
    2. Set the environment variable: `ANTHROPIC_API_KEY=sk-ant-...`
    3. In [Blocks Dashboard](https://blocks.team), go to **Dashboard** → **Agents**
    4. Select **OpenCode** and choose "Anthropic"
    5. Paste your API key
  </Tab>

  <Tab title="OpenAI API Key">
    **Use OpenAI models (GPT-5.6, GPT-5.5)**

    1. Get an API key at [OpenAI Platform](https://platform.openai.com/api-keys)
    2. Set the environment variable: `OPENAI_API_KEY=sk-...`
    3. In [Blocks Dashboard](https://blocks.team), go to **Dashboard** → **Agents**
    4. Select **OpenCode** and choose "OpenAI"
    5. Paste your API key
  </Tab>

  <Tab title="Kimi API Key">
    **Use Moonshot AI's Kimi models**

    1. Get an API key at [Moonshot AI Platform](https://platform.moonshot.cn/)
    2. Set the environment variable: `KIMI_API_KEY=...`
    3. In [Blocks Dashboard](https://blocks.team), go to **Dashboard** → **Agents**
    4. Select **OpenCode** and choose "Kimi"
    5. Paste your API key
  </Tab>

  <Tab title="OpenCode Zen">
    **Use one OpenCode Zen key for the whole roster**

    1. Get a key at [OpenCode Zen](https://opencode.ai/zen)
    2. Set the environment variable: `OPENCODE_API_KEY=...`
    3. In [Blocks Dashboard](https://blocks.team), go to **Settings** → **Agents** → **OpenCode**
    4. Set **Authentication Method** to "OpenCode Zen"

    One key covers every model in the list above except Gemini 2.5 Pro, which Zen does not serve. Usage draws on your prepaid Zen balance.
  </Tab>

  <Tab title="OpenCode Go">
    **The cheaper OpenCode tier, on a smaller roster**

    1. Set the same `OPENCODE_API_KEY` environment variable
    2. In [Blocks Dashboard](https://blocks.team), go to **Settings** → **Agents** → **OpenCode**
    3. Set **Authentication Method** to "OpenCode Go"
    4. Select a model Go serves: Kimi K2.5, Kimi K2.6, Kimi K2.7 Code, Kimi K3, or GPT-5.6 Luna

    <Warning>
      OpenCode Go serves no Anthropic models, so switch your model when you select Go. Go also bills a separate subscription wallet from Zen, with per-model quotas, which is why it is its own authentication method rather than a variation of Zen.
    </Warning>
  </Tab>

  <Tab title="Blocks">
    **Run on Blocks LLM credits**

    1. In [Blocks Dashboard](https://blocks.team), go to **Settings** → **Agents** → **OpenCode**
    2. Set **Authentication Method** to "Blocks"

    There is no API key to set. Requests route through the Blocks AI Gateway and usage draws on your Blocks LLM credits. Every model listed above is available.
  </Tab>
</Tabs>

## Setting as Default

To use OpenCode automatically for all requests:

1. Go to **Dashboard** → **Agents**
2. Select "Set as default agent" from OpenCode's dropdown menu

## Using OpenCode

Once configured, OpenCode is used automatically if it's your default agent:

```
@blocks can you review this code?
```

Or use the `/opencode` slash command to use it specifically:

```
@blocks /opencode implement this feature using GPT-5.6 Terra
```

## Best For

* Flexibility between OpenAI, Anthropic, Kimi and Gemini models
* Privacy-focused development (no code storage)
* Open source transparency
* Cost optimization (switch between providers based on task complexity)
* Experimentation with different models from major providers
* Teams wanting to avoid vendor lock-in

<Tip>
  Anthropic, OpenAI, Moonshot AI and Google models are all available in Blocks, so you can move between them as a task demands.
</Tip>

## Cost

OpenCode costs depend on the authentication method:

* **Provider API key**: Billed directly by that provider. Check [Anthropic Pricing](https://www.anthropic.com/pricing), [OpenAI Pricing](https://openai.com/pricing) or the [Moonshot AI Platform](https://platform.moonshot.cn/)
* **OpenCode Zen**: Drawn from your prepaid Zen balance
* **OpenCode Go**: Drawn from your Go subscription wallet, with per-model quotas
* **Blocks**: Billed against your Blocks LLM credits

<Note>
  OpenCode Zen and OpenCode Go usage is billed by OpenCode against your own key. It does not go through the Blocks AI Gateway and is not billed by Blocks.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Claude Code" icon="brain" href="/using-blocks/agents/claude-code">
    Learn about Claude Code
  </Card>

  <Card title="Codex Agent" icon="code" href="/using-blocks/agents/codex">
    Explore Codex capabilities
  </Card>
</CardGroup>


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