Skip to main content

OpenCode

OpenCode is an AI coding agent that provides both CLI and IDE integration capabilities for AI-powered development tasks.

Features

  • CLI Access: Run AI coding tasks directly from terminal
  • IDE Integration: Works with VS Code, Cursor, and compatible editors
  • GitHub Integration: Interact with issues and PRs via comments
  • Conversation Sharing: Share coding sessions with others
  • MCP Support: Enhanced functionality through MCP servers

Installation

curl -fsSL https://opencode.ai/install | bash

Method 2: NPM

npm install -g opencode-ai

Configuration for Apertis API

Create or edit the configuration file at ~/.config/opencode/opencode.json:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"apertis": {
"name": "Apertis AI",
"npm": "@apertis/ai-sdk-provider",
"options": {
"apiKey": "your_apertis_api_key"
},
"models": {
"claude-opus-4-6-thinking": {
"name": "Claude Opus 4.6 (Thinking)"
},
"claude-opus-4-6": {
"name": "Claude Opus 4.6"
},
"claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6"
},
"claude-haiku-4.5": {
"name": "Claude Haiku 4.5"
},
"gemini-3.1-pro-preview": {
"name": "Gemini 3.1 Pro Preview"
},
"gemini-3.1-flash-lite-preview": {
"name": "Gemini 3.1 Flash Lite Preview"
}
}
}
},
"model": "apertis/claude-opus-4-6"
}

Option 2: Without SDK (OpenAI-Compatible)

If you prefer not to use the Apertis SDK, you can use the built-in OpenAI-compatible mode by specifying baseURL:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"apertis": {
"name": "Apertis AI",
"options": {
"baseURL": "https://api.apertis.ai/v1",
"apiKey": "your_apertis_api_key"
},
"models": {
"claude-opus-4-6": {
"name": "Claude Opus 4.6"
},
"claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6"
}
}
}
},
"model": "apertis/claude-opus-4-6"
}

Replace your_apertis_api_key with your actual API key from Apertis Dashboard.

No code: prefix needed

Unlike Claude Code, OpenCode does not require the code: prefix for Claude model IDs. Use the standard model ID directly (e.g., claude-opus-4-6 instead of code:claude-opus-4-6).

Configuration Fields

FieldDescription
provider.apertis.npmApertis SDK package. Use @apertis/ai-sdk-provider for automatic setup.
provider.apertis.options.baseURLApertis API endpoint. Only needed without the SDK.
provider.apertis.options.apiKeyYour API key from Apertis Dashboard.
provider.apertis.modelsAvailable models to use. Add or remove as needed.
modelDefault model on launch. Format: apertis/<model-id>.

Available Model IDs

Model IDDescription
claude-opus-4-6-thinkingClaude Opus 4.6 with extended thinking
claude-opus-4-6Claude Opus 4.6 — most capable
claude-sonnet-4-6Claude Sonnet 4.6 — balanced speed and capability
claude-haiku-4.5Claude Haiku 4.5 — fastest
gemini-3.1-pro-previewGemini 3.1 Pro Preview
gemini-3.1-flash-lite-previewGemini 3.1 Flash Lite Preview

For the full list of available models, check the Model List.

Launch OpenCode

opencode

Use the /models command within OpenCode to switch models.

IDE Integration

OpenCode works with VS Code, Cursor, and compatible terminals.

Keyboard Shortcuts

ActionmacOSWindows/Linux
Quick LaunchCmd+EscCtrl+Esc
New SessionCmd+Shift+EscCtrl+Shift+Esc
File ReferencesCmd+Option+KAlt+Ctrl+K

Commands

CommandDescription
/modelsSelect AI model
/shareCreate public conversation link
/unshareRemove public access
/helpShow available commands

GitHub Integration

Interact with OpenCode directly in GitHub issues and pull requests.

Setup

Run this command in your GitHub repository:

opencode github install

Usage

Comment with /opencode or /oc in GitHub issues/PRs to:

  • Explain Issues: Get AI explanations for bug reports
  • Fix Bugs: Generate fixes for reported issues
  • Implement Features: Create code for feature requests
  • Review PRs: Get AI-powered code reviews

MCP Server Support

OpenCode supports Model Context Protocol servers:

  • Vision Server: Analyze images and screenshots
  • Web Search Server: Search the web for information
  • Web Reader Server: Extract content from web pages

Troubleshooting

Connection Issues

  • Verify your API key at Apertis Dashboard
  • Ensure the Base URL is set correctly
  • Check environment variables are exported

Authentication Problems

Reset authentication and reconfigure:

opencode auth logout
opencode auth login