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

Step 1: Authentication Setup

Run the authentication command:

opencode auth login

Step 2: Configure Custom Provider

When prompted, select custom API configuration and enter:

SettingValue
Base URLhttps://api.apertis.ai/v1
API KeyYour Apertis API key

Alternatively, set environment variables:

export OPENAI_API_BASE="https://api.apertis.ai/v1"
export OPENAI_API_KEY="your_apertis_api_key"

Add to your shell profile (~/.zshrc or ~/.bashrc) for persistence:

# Add to ~/.zshrc or ~/.bashrc
export OPENAI_API_BASE="https://api.apertis.ai/v1"
export OPENAI_API_KEY="your_apertis_api_key"

Step 3: Launch OpenCode

opencode

Step 4: Select Model

Use the /models command within OpenCode to select your preferred model.

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