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

# Connect OpenCode

> Set up OpenCode with the Fortytwo API: add Fortytwo as an OpenAI-compatible provider, connect it with /connect and select qwen/qwen3.8-27b.

[OpenCode ](https://opencode.ai/) is a coding agent for the terminal.

> [!NOTE]
>
> **Before you start:** create a Fortytwo API key and buy credits — see [Quickstart, step 1](https://docs.fortytwo.network/docs/quickstart.md#1-create-an-api-key). Give each agent its own key with a **Spend limit**.
>
> | Setting | Value |
> | - | - |
> | Base URL | `https://api.fortytwo.network/v1` |
> | Model ID | `qwen/qwen3.8-27b` in this guide, or another ID from [Models](https://docs.fortytwo.network/docs/models.md) |

**1. Install OpenCode**

```bash theme={null}
curl -fsSL https://opencode.ai/v2/install | bash
```

Open a new terminal window when the installer finishes: the `opencode` command works only there. Other install options: [OpenCode on GitHub ](https://github.com/anomalyco/opencode#installation).

**2. Add Fortytwo to the config**

Open `~/.config/opencode/opencode.json` and add the `fortytwo` provider. For a new file:

> [!NOTE]
>
> `~` is your home folder. Folders that start with a dot, such as `.pi`, `.config` or `.codex`, are hidden. To show them: **Cmd+Shift+.** in Finder on macOS, **View** → **Show** → **Hidden items** in File Explorer on Windows, **Ctrl+H** in most Linux file managers.

```json ~/.config/opencode/opencode.json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "fortytwo": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Fortytwo",
      "options": {
        "baseURL": "https://api.fortytwo.network/v1"
      },
      "models": {
        "qwen/qwen3.8-27b": {
          "name": "Qwen3.8 27B",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": { "input": ["text", "image"], "output": ["text"] },
          "limit": { "context": 262144, "output": 235929 }
        },
        "deepseek/deepseek-v4.1-flash-1017": {
          "name": "DeepSeek V4.1 Flash 1017",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": { "input": ["text", "image"], "output": ["text"] },
          "limit": { "context": 1048576, "output": 262144 }
        },
        "deepseek/deepseek-v4.1-flash-1017:free": {
          "name": "DeepSeek V4.1 Flash 1017 Free",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": { "input": ["text", "image"], "output": ["text"] },
          "limit": { "context": 1048576, "output": 262144 }
        },
        "nvidia/nemotron-3.5-super-vl": {
          "name": "Nemotron 3.5 Super VL",
          "reasoning": true,
          "tool_call": true,
          "attachment": true,
          "modalities": { "input": ["text", "image"], "output": ["text"] },
          "limit": { "context": 262144, "output": 235929 }
        }
      }
    }
  }
}
```

If the file has other settings, add `fortytwo` inside its `provider` object.

Fortytwo is also in the OpenCode provider list, so `/connect` finds it without this file. OpenCode updates that list on its own schedule, so new Fortytwo models can appear there later. The config gives you every model at once.

*Another model works the same way: take its ID, context window and max output from [Models](https://docs.fortytwo.network/docs/models.md).*

**3. Connect Fortytwo**

1. Start OpenCode in your project folder:

```bash theme={null}
opencode
```

2. Type `/connect`, search for `Fortytwo` and select it.

   ![OpenCode: Fortytwo in the Connect an integration list](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/opencode-1.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=eee2d50e480ccffc21f38fe369df62ed)

3. Paste your API key and press **Enter**. OpenCode shows **Connected Fortytwo**.

4. OpenCode opens the model list. Choose **Qwen3.8 27B**.

   ![OpenCode: Qwen3.8 27B under Fortytwo, with the Connected Fortytwo message](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/opencode-2.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=3540cdfb25834781708b604c59564f0b)

5. In **Select variant**, choose **medium** to turn on reasoning.

   ![OpenCode: Select variant with medium selected](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/opencode-3.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=372d456dbba8cf61b5c909635a984fde)

The prompt shows **Qwen3.8 27B Fortytwo · medium**.

![OpenCode: prompt with Qwen3.8 27B Fortytwo and variant medium](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/opencode-4.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=486dc38c335205d798e5e1517c14623d)

**4. Start a task**

Type a task and press **Enter**. To change the model later, type `/models`; to change the reasoning level, type `/variants`.

![OpenCode: task done on Qwen3.8 27B Fortytwo with variant medium](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/opencode-5.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=45acadf4019246e1aabab5d8294022d9)

The model ID inside OpenCode is `fortytwo/qwen/qwen3.8-27b`: the provider ID, then the Fortytwo model ID. More options: [OpenCode custom provider ](https://opencode.ai/docs/providers/#custom-provider).

***

Something not working with your agent, or using one we have not listed? Tell us in the platform: [Feedback](https://docs.fortytwo.network/docs/support.md#ideas-feedback-and-small-bugs) for ideas and small bugs, [Contact support](https://docs.fortytwo.network/docs/support.md#support-account-api-billing-credits-errors) if it blocks your work, or [Report a security issue](https://docs.fortytwo.network/docs/support.md#security-issue).


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