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

# OpenCode Integration Guide

> Configure OpenCode terminal UI for Infercom's EU sovereign inference. Step-by-step setup with MiniMax-M2.7 for agentic coding with full data sovereignty.

[OpenCode](https://opencode.ai) is a terminal-based AI coding assistant with a rich TUI (text user interface). It provides an interactive coding experience with file management, reasoning visualization, and tool calling capabilities.

<Info>
  **Verified working** with MiniMax-M2.7 on Infercom.
</Info>

## Prerequisites

* macOS, Linux, or Windows
* [Infercom API key](https://cloud.infercom.ai/apis)

## Installation

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

Verify installation:

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

## Configuration

OpenCode requires a configuration file to define the Infercom provider.

### Step 1: Create Config File

Create `~/.config/opencode/opencode.json`:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "infercom": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Infercom (EU Sovereign)",
      "options": {
        "baseURL": "https://api.infercom.ai/v1"
      },
      "models": {
        "MiniMax-M2.7": {
          "name": "MiniMax M2.7 (EU Sovereign)"
        }
      }
    }
  },
  "model": "infercom/MiniMax-M2.7"
}
```

<Tip>
  For complex tasks, OpenCode supports separate plan/build agents. You can use a frontier model (Claude, GPT, Gemini) for planning and MiniMax-M2.7 for execution. See [OpenCode documentation](https://opencode.ai) for multi-provider configuration.
</Tip>

### Step 2: Add API Key

Run the auth login command:

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

Select the Infercom provider and paste your API key when prompted.

<Tip>
  Credentials are stored in `~/.local/share/opencode/auth.json`
</Tip>

### Step 3: Verify Setup

Check that the provider is configured:

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

Expected output:

```
+  Credentials ~/.local/share/opencode/auth.json
|
*  infercom api
|
-  1 credential
```

List available models:

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

Expected output:

```
infercom/MiniMax-M2.7
```

## Model

Use `infercom/MiniMax-M2.7` - optimized for agentic coding with 192K context, reasoning, and tool calling.

## Usage

### Interactive TUI

Launch the TUI:

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

Use `/models` to switch models if needed.

### Non-Interactive Mode

For scripts and CI:

```bash theme={null}
opencode run --model infercom/MiniMax-M2.7 "Your task description"
```

Example:

```bash theme={null}
opencode run --model infercom/MiniMax-M2.7 \
  "Add input validation to the login function in auth.py"
```

## Model Configuration Options

Customize model capabilities in `opencode.json`:

| Option              | Description                 | Default             |
| ------------------- | --------------------------- | ------------------- |
| `reasoning`         | Enable reasoning/thinking   | `true` for MiniMax  |
| `interleaved.field` | Field for reasoning context | `reasoning_content` |
| `tool_call`         | Enable function calling     | `true`              |
| `temperature`       | Temperature parameter       | `true`              |
| `limit.context`     | Max context tokens          | Model-specific      |
| `limit.output`      | Max output tokens           | Model-specific      |

## Troubleshooting

### Tool/File Operations Return Empty

If tool or file operations return empty responses, ensure `npm` is set to `@ai-sdk/openai-compatible`, not `@ai-sdk/openai`. The `@ai-sdk/openai` package routes to an endpoint that has a known streaming issue with tool calls.

### Read-Before-Write Errors

OpenCode requires reading files before overwriting them (safety feature):

```
Error: You must read file /path/to/file.py before overwriting it.
```

This is expected behavior. OpenCode will automatically read the file and retry.

### Provider Not Found

Ensure the config file is in the correct location:

```bash theme={null}
ls ~/.config/opencode/opencode.json
```

### Authentication Failed

Re-run the login command:

```bash theme={null}
opencode providers login -p infercom
```

Or manually edit `~/.local/share/opencode/auth.json`:

```json theme={null}
{
  "infercom": {
    "type": "api",
    "key": "your-infercom-api-key"
  }
}
```

## Performance

* **Token throughput:** 400+ tokens/sec with MiniMax-M2.7
* **Context window:** 192K tokens
* **Tool calling:** Fully supported for file operations

## Next Steps

* [Aider](/en/agentic-coding/aider) - Simpler terminal tool
* [Choosing a Tool](/en/agentic-coding/choosing-a-tool) - Compare options
* [API Reference](/en/api-reference/overview) - Direct API usage
