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

# AI Coding Agents Overview

> Configure AI coding agents to use MegaLLM - CLI tools and GUI extensions

MegaLLM supports all major AI coding agents. This unified guide covers configuration for Claude Code, Codex/Windsurf, OpenCode, Kilocode, RooCode, and Cline.

## Available Agents

> [card] [Claude Code](https://docs.megallm.io/en/agents/claude.md)
>
> CLI + Editor integration with JSON config

> [card] [Codex/Windsurf](https://docs.megallm.io/en/agents/codex.md)
>
> CLI + Editor with TOML config

> [card] [OpenCode](https://docs.megallm.io/en/agents/opencode.md)
>
> CLI + Editor with auto-model fetching

> [card] [Kilocode](https://docs.megallm.io/en/agents/kilocode.md)
>
> VSCode extension with inline chat (CLI coming soon)

> [card] [RooCode](https://docs.megallm.io/en/agents/roocode.md)
>
> Standalone app with visual interface

> [card] [Cline](https://docs.megallm.io/en/agents/cline.md)
>
> VSCode extension with autonomous tasks (CLI coming soon)

## Quick Comparison

| Agent | Interfaces | Config Format | Config Level | Best For |
| - | - | - | - | - |
| **Claude Code** | CLI + VSCode | JSON | System + Project | Terminal workflows, VSCode integration |
| **Codex/Windsurf** | CLI + Editor | TOML | System only | Advanced users, Cascade AI |
| **OpenCode** | CLI + Editor | JSON | System + Project | Multi-model switching, flexibility |
| **Kilocode** | VSCode (CLI soon) | VSCode settings | User + Workspace | Inline chat, code completion |
| **RooCode** | Standalone app | JSON | App-level | Visual UI, standalone workflow |
| **Cline** | VSCode (CLI soon) | VSCode settings | User + Workspace | Autonomous tasks, terminal ops |

## Agent Types

### CLI-First Agents (with Editor Support)

> [card] Claude Code
>
> * CLI-first design
> * VSCode extension available
> * JSON configuration
> * System & project-level
> * Statusline support

> [card] Codex/Windsurf
>
> * CLI-first design
> * Editor integrations
> * TOML configuration
> * Cascade AI (Windsurf)
> * Supercomplete features

> [card] OpenCode
>
> * CLI-first design
> * Editor plugins available
> * JSON configuration
> * Auto-fetch models
> * Multi-provider support

**When to use CLI-first agents:**

* Terminal-based workflows
* CI/CD integration
* Server environments
* Scripting and automation
* Also work great in editors with extensions

### Editor-Only Agents (CLI Coming Soon)

> [card] Kilocode
>
> * VSCode extension (primary)
> * CLI under maintenance
> * Inline chat interface
> * Code completion
> * File tree integration

> [card] RooCode
>
> * Standalone app
> * Visual interface
> * Multi-project support
> * Code review features

> [card] Cline
>
> * VSCode extension (primary)
> * CLI under maintenance
> * Autonomous task execution
> * Terminal integration
> * Git workflow support

> [!NOTE]
>
> **CLI Support for Kilocode & Cline:** CLI versions are currently under maintenance and will be available soon. Use the VSCode extensions in the meantime.

**When to use editor-focused agents:**

* Pure visual editing workflows
* Inline suggestions and completions
* Multi-file refactoring
* Code review workflows
* IDE-native experience

## Getting Started

**1. Choose Your Agent**

Select a CLI agent for terminal workflows or a GUI agent for visual editing

**2. Get Your API Key**

Sign up at [MegaLLM Dashboard](https://megallm.io/dashboard) and get your API key starting with `sk-mega-`

**3. Configure Your Agent**

Follow the specific configuration guide for your chosen agent (linked below)

**4. Start Coding**

Launch your agent and start using AI-powered coding assistance

## Configuration Guides

### CLI-First Agents (also work in editors)

> [accordion] Claude Code - CLI + VSCode
>
> **Works as:** CLI tool + VSCode extension
>
> **Configuration files:**
>
> * System: `~/.claude/settings.json`
> * Project: `./.claude/settings.json`
> * Local: `./.claude/settings.local.json`
>
> **Quick setup:**
>
> ```json theme={null}
> {
>   "env": {
>     "ANTHROPIC_BASE_URL": "https://ai.megallm.io",
>     "ANTHROPIC_API_KEY": "sk-mega-your-api-key-here"
>   }
> }
> ```
>
> [Full Claude Code Configuration Guide →](https://docs.megallm.io/agents/claude)

> [accordion] Codex/Windsurf - CLI + Editor
>
> **Works as:** CLI tool + Editor integrations (Windsurf is enhanced variant)
>
> **Configuration file:**
>
> * System: `~/.codex/config.toml` (only)
>
> **Quick setup:**
>
> ```toml theme={null}
> model_provider = "megallm"
> model = "gpt-5"
>
> [model_providers.megallm]
> name = "OpenAI using Chat Completions"
> base_url = "https://ai.megallm.io/v1"
> env_key = "MEGALLM_API_KEY"
>
> [tools]
> web_search = true
> file_browser = true
> ```
>
> [Full Codex/Windsurf Configuration Guide →](https://docs.megallm.io/agents/codex)

> [accordion] OpenCode - CLI + Editor Plugins
>
> **Works as:** CLI tool + Editor plugins (VSCode, Vim, etc.)
>
> **Configuration files:**
>
> * System: `~/.config/opencode/opencode.json`
> * Project: `./.opencode/opencode.json`
>
> **Quick setup:**
>
> ```json theme={null}
> {
>   "providers": [
>     {
>       "id": "megallm",
>       "name": "MegaLLM",
>       "type": "openai",
>       "baseURL": "https://ai.megallm.io/v1",
>       "apiKey": "sk-mega-your-api-key-here"
>     }
>   ],
>   "defaultProvider": "megallm"
> }
> ```
>
> [Full OpenCode Configuration Guide →](https://docs.megallm.io/agents/opencode)

### Editor-Only Agents

> [accordion] Kilocode - VSCode Extension
>
> **Configuration location:**
>
> * User Settings (global): VSCode Settings UI or `settings.json`
> * Workspace Settings (project): `.vscode/settings.json`
>
> **Quick setup (settings.json):**
>
> ```json theme={null}
> {
>   "kilocode.apiProvider": "custom",
>   "kilocode.customProvider": {
>     "name": "MegaLLM",
>     "baseURL": "https://ai.megallm.io/v1",
>     "apiKey": "${env:MEGALLM_API_KEY}"
>   },
>   "kilocode.defaultModel": "gpt-5"
> }
> ```
>
> **Environment variable:**
>
> ```bash theme={null}
> export MEGALLM_API_KEY="sk-mega-your-api-key-here"
> ```
>
> [Full Kilocode Configuration Guide →](https://docs.megallm.io/agents/kilocode)

> [accordion] RooCode - Standalone App
>
> **Configuration location:**
>
> * Windows: `%APPDATA%\RooCode\config.json`
> * macOS: `~/Library/Application Support/RooCode/config.json`
> * Linux: `~/.config/roocode/config.json`
>
> **Quick setup:**
>
> ```json theme={null}
> {
>   "provider": "openai-compatible",
>   "api": {
>     "baseURL": "https://ai.megallm.io/v1",
>     "apiKey": "sk-mega-your-api-key-here",
>     "model": "gpt-5"
>   },
>   "features": {
>     "codeCompletion": true,
>     "chatInterface": true,
>     "codeReview": true,
>     "terminalIntegration": false
>   }
> }
> ```
>
> [Full RooCode Configuration Guide →](https://docs.megallm.io/agents/roocode)

> [accordion] Cline - VSCode Extension with Autonomy
>
> **Configuration location:**
>
> * User Settings (global): VSCode Settings UI or `settings.json`
> * Workspace Settings (project): `.vscode/settings.json`
>
> **Quick setup for GPT models (OpenAI format):**
>
> ```json theme={null}
> {
>   "cline.apiProvider": "openai",
>   "cline.openai": {
>     "apiKey": "${env:MEGALLM_API_KEY}",
>     "baseURL": "https://ai.megallm.io/v1"
>   },
>   "cline.defaultModel": "gpt-5"
> }
> ```
>
> **Quick setup for Claude models (Anthropic format):**
>
> ```json theme={null}
> {
>   "cline.apiProvider": "anthropic",
>   "cline.anthropic": {
>     "apiKey": "${env:MEGALLM_API_KEY}",
>     "baseURL": "https://ai.megallm.io"
>   },
>   "cline.defaultModel": "claude-sonnet-4"
> }
> ```
>
> **Environment variable:**
>
> ```bash theme={null}
> export MEGALLM_API_KEY="sk-mega-your-api-key-here"
> ```
>
> [Full Cline Configuration Guide →](https://docs.megallm.io/agents/cline)

## Model Selection

All agents support the same models through MegaLLM:

### GPT Models

* `gpt-5` - Latest GPT model (recommended)
* `gpt-4` - GPT-4
* `gpt-4o` - GPT-4 Optimized
* `gpt-4o-mini` - Fast, cost-effective

### Claude Models

* `claude-opus-4-1-20250805` - Most capable
* `claude-sonnet-4` - Balanced (recommended)
* `claude-haiku-4` - Fast, efficient

### Gemini Models

* `gemini-2.5-pro` - Latest Gemini
* `gemini-2.0-flash` - Fast responses

[See Full Model Catalog →](https://docs.megallm.io/home/models)

## Environment Variables

Most agents support environment variables for API keys:

```bash theme={null}
# For CLI agents and some GUI agents
export MEGALLM_API_KEY="sk-mega-your-api-key-here"

# For Claude Code specifically
export ANTHROPIC_BASE_URL="https://ai.megallm.io"
export ANTHROPIC_API_KEY="sk-mega-your-api-key-here"
```

Add to your shell configuration:

* Bash: `~/.bashrc`
* Zsh: `~/.zshrc`
* Fish: `~/.config/fish/config.fish`

## Common Configuration Patterns

### Pattern 1: System-Level for Personal Use

**Best for**: Personal projects, single user

> [tab] Claude Code
>
> ```bash theme={null}
> # System configuration
> ~/.claude/settings.json
>
> # Environment variables
> export ANTHROPIC_BASE_URL="https://ai.megallm.io"
> export ANTHROPIC_API_KEY="sk-mega-your-key"
> ```

> [tab] Kilocode
>
> ```bash theme={null}
> # VSCode User Settings
> # File > Preferences > Settings > Search "kilocode"
>
> # Environment variable
> export MEGALLM_API_KEY="sk-mega-your-key"
> ```

> [tab] RooCode
>
> ```bash theme={null}
> # App configuration
> ~/.config/roocode/config.json
>
> # Store API key in config or use env var
> ```

### Pattern 2: Project-Level for Teams

**Best for**: Team projects, shared configuration

> [tab] Claude Code
>
> ```bash theme={null}
> # Shared config (committed)
> .claude/settings.json
> {
>   "env": {
>     "ANTHROPIC_BASE_URL": "https://ai.megallm.io"
>   }
> }
>
> # Personal key (not committed)
> .claude/settings.local.json
> {
>   "env": {
>     "ANTHROPIC_API_KEY": "your-personal-key"
>   }
> }
>
> # .gitignore
> .claude/settings.local.json
> ```

> [tab] Kilocode
>
> ```bash theme={null}
> # Workspace settings (committed)
> .vscode/settings.json
> {
>   "kilocode.apiProvider": "custom",
>   "kilocode.customProvider": {
>     "name": "MegaLLM",
>     "baseURL": "https://ai.megallm.io/v1",
>     "apiKey": "${env:MEGALLM_API_KEY}"
>   }
> }
>
> # Team members set their own env var
> export MEGALLM_API_KEY="personal-key"
> ```

> [tab] OpenCode
>
> ```bash theme={null}
> # Project config (committed)
> .opencode/opencode.json
> {
>   "providers": [{
>     "baseURL": "https://ai.megallm.io/v1"
>   }]
> }
>
> # Personal key via env var
> export MEGALLM_API_KEY="personal-key"
> ```

### Pattern 3: Multi-Model Configuration

**Best for**: Using different models for different tasks

> [tab] OpenCode
>
> ```json theme={null}
> {
>   "providers": [
>     {
>       "id": "megallm-gpt",
>       "type": "openai",
>       "baseURL": "https://ai.megallm.io/v1",
>       "models": ["gpt-5", "gpt-4o"]
>     },
>     {
>       "id": "megallm-claude",
>       "type": "anthropic",
>       "baseURL": "https://ai.megallm.io",
>       "models": ["claude-sonnet-4", "claude-opus-4"]
>     }
>   ]
> }
> ```

> [tab] RooCode
>
> ```json theme={null}
> {
>   "providers": [
>     {
>       "name": "GPT for Chat",
>       "model": "gpt-5",
>       "useFor": ["chat", "completion"]
>     },
>     {
>       "name": "Claude for Review",
>       "model": "claude-sonnet-4",
>       "useFor": ["review", "analysis"]
>     }
>   ]
> }
> ```

## Troubleshooting

> [accordion] API Key Not Working
>
> **Verify your API key:**
>
> ```bash theme={null}
> # Check it starts with sk-mega-
> echo $MEGALLM_API_KEY
>
> # Test the API directly
> curl -H "Authorization: Bearer $MEGALLM_API_KEY" \
>      https://ai.megallm.io/v1/models
> ```
>
> **Common issues:**
>
> * Missing `sk-mega-` prefix
> * Extra spaces or quotes
> * Wrong environment variable name
> * Shell config not reloaded (run `source ~/.bashrc`)

> [accordion] Wrong API Endpoint
>
> **Check your base URL:**
>
> For **OpenAI-compatible format** (GPT, Gemini):
>
> ```
> https://ai.megallm.io/v1  <Icon icon="check" /> (with /v1)
> ```
>
> For **Anthropic format** (Claude):
>
> ```
> https://ai.megallm.io  <Icon icon="check" /> (no /v1)
> ```
>
> **Agent-specific endpoints:**
>
> * Claude Code: `https://ai.megallm.io` (no /v1)
> * Codex/Windsurf: `https://ai.megallm.io/v1`
> * OpenCode: `https://ai.megallm.io/v1`
> * Kilocode: `https://ai.megallm.io/v1`
> * RooCode: `https://ai.megallm.io/v1`
> * Cline: `https://ai.megallm.io` (Anthropic) or `https://ai.megallm.io/v1` (OpenAI)

> [accordion] Model Not Found
>
> **Verify model name spelling:**
>
> Check [Models Catalog](https://docs.megallm.io/home/models) for exact model names:
>
> ```bash theme={null}
> # Common mistakes:
> "gpt5"           <Icon icon="xmark" />  # Missing dash
> "gpt-5"          <Icon icon="check" />
>
> "claude-sonnet"  <Icon icon="xmark" />  # Missing version
> "claude-sonnet-4" <Icon icon="check" />
>
> "gemini-pro"     <Icon icon="xmark" />  # Wrong version
> "gemini-2.5-pro" <Icon icon="check" />
> ```

> [accordion] Configuration Not Loading
>
> **Check file locations:**
>
> ```bash theme={null}
> # CLI agents
> ls -la ~/.claude/settings.json      # Claude Code
> ls -la ~/.codex/config.toml         # Codex
> ls -la ~/.config/opencode/           # OpenCode
>
> # Project configs
> ls -la .claude/settings.json         # Claude Code
> ls -la .opencode/opencode.json       # OpenCode
> ls -la .vscode/settings.json         # VSCode extensions
>
> # Validate JSON/TOML syntax
> jq . ~/.claude/settings.json         # Test JSON
> cat ~/.codex/config.toml | grep -    # Test TOML
> ```
>
> **Check permissions:**
>
> ```bash theme={null}
> chmod 644 ~/.claude/settings.json
> chmod 644 ~/.codex/config.toml
> ```

> [accordion] Environment Variables Not Set
>
> **Reload your shell config:**
>
> ```bash theme={null}
> # Bash
> source ~/.bashrc
>
> # Zsh
> source ~/.zshrc
>
> # Fish
> source ~/.config/fish/config.fish
>
> # Verify
> echo $MEGALLM_API_KEY
> echo $ANTHROPIC_BASE_URL
> ```
>
> **Check where it's defined:**
>
> ```bash theme={null}
> # Search all shell configs
> grep -r "MEGALLM_API_KEY" ~/.*rc ~/.config/
> ```

## Feature Comparison

### Interfaces & Usage

| Agent | CLI Available | Editor/GUI | Chat Interface | Multi-file Edit |
| - | - | - | - | - |
| Claude Code |   Primary |   VSCode ext |   CLI + GUI | |
| Codex/Windsurf |   Primary |   Editor |   CLI + GUI | |
| OpenCode |   Primary |   Plugins |   CLI + GUI | |
| Kilocode |   Coming soon |   VSCode only |   GUI | |
| RooCode | |   Standalone |   GUI | |
| Cline |   Coming soon |   VSCode only |   GUI | |

### Integrations

| Agent | Terminal Access | Git Integration | File Tree | Code Review |
| - | - | - | - | - |
| Claude Code |   Native CLI |   Native | |   In editor |
| Codex/Windsurf |   Native CLI |   Native | |   In editor |
| OpenCode |   Native CLI |   Native | |   In editor |
| Kilocode |   Via VSCode |   VSCode | | |
| RooCode |   Built-in |   Built-in | | |
| Cline |   VSCode term |   VSCode | | |

### Configuration Flexibility

| Agent | System Config | Project Config | Env Vars | Team Sharing |
| - | - | - | - | - |
| Claude Code | | | | |
| Codex/Windsurf | | | |   Limited |
| OpenCode | | | | |
| Kilocode | | | | |
| RooCode | |   Import |   Limited |   Export |
| Cline | | | | |

## Best Practices

> [card] Use Environment Variables
>
> Store API keys in environment variables, never commit them to version control

> [card] Project-Level for Teams
>
> Use project-level config for shared settings, local files for personal keys

> [card] Choose Right Agent
>
> CLI for automation/CI/CD, GUI for interactive coding and visual workflows

> [card] Test Configuration
>
> Verify API connection with curl before configuring agents

> [card] Keep Keys Secure
>
> Add sensitive files to .gitignore, use different keys for dev/prod

> [card] Regular Updates
>
> Keep agents updated for latest features, security patches, and bug fixes

## Next Steps

> [card] [Claude Code](https://docs.megallm.io/en/agents/claude.md)
>
> CLI with JSON config

> [card] [Codex/Windsurf](https://docs.megallm.io/en/agents/codex.md)
>
> CLI with TOML config

> [card] [OpenCode](https://docs.megallm.io/en/agents/opencode.md)
>
> CLI with auto-fetch

> [card] [Kilocode](https://docs.megallm.io/en/agents/kilocode.md)
>
> VSCode extension

> [card] [RooCode](https://docs.megallm.io/en/agents/roocode.md)
>
> Standalone app

> [card] [Cline](https://docs.megallm.io/en/agents/cline.md)
>
> VSCode + autonomy

> [card] [Models Catalog](https://docs.megallm.io/en/home/models.md)
>
> Browse all available models

> [card] [API Reference](https://docs.megallm.io/en/api-reference/introduction.md)
>
> Direct API integration


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