> ## 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.

# Kilocode Configuration

> Configure Kilocode VSCode extension to use MegaLLM

Kilocode is a powerful VSCode extension that provides AI-powered code completion, inline chat, and code actions. Configure it to use MegaLLM for access to multiple AI models.

## Quick Configuration

> [tab] Via Settings UI
>
> ### Step-by-Step Setup
>
> **1. Open VSCode Settings**
>
> * Press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac)
> * Type: `Preferences: Open Settings (UI)`
> * Search for: `Kilocode`
>
> **2. Configure API Provider**
>
> * **API Provider**: Select `Custom`
> * **Provider Name**: `MegaLLM`
> * **Base URL**: `https://ai.megallm.io/v1`
> * **API Key**: `sk-mega-your-api-key-here`
>
> **3. Select Default Model**
>
> * **Default Model**: `gpt-5` (or any [supported model](https://docs.megallm.io/home/models))
> * **Temperature**: `0.3` (lower = more deterministic)
> * **Max Tokens**: `500` (for completions)
>
> **4. Enable Features**
>
> * &#x20;**Enable AutoComplete**
> * &#x20;**Enable Inline Chat**
> * &#x20;**Enable Code Actions**
> * &#x20;**Enable Suggestions**

> [tab] Via settings.json
>
> ### Configuration File
>
> **Location**: `.vscode/settings.json` or `~/.config/Code/User/settings.json`
>
> ```json theme={null}
> {
>   "kilocode.apiProvider": "custom",
>   "kilocode.customProvider": {
>     "name": "MegaLLM",
>     "baseURL": "https://ai.megallm.io/v1",
>     "apiKey": "sk-mega-your-api-key-here"
>   },
>   "kilocode.defaultModel": "gpt-5",
>   "kilocode.enableAutoComplete": true,
>   "kilocode.enableInlineChat": true,
>   "kilocode.enableCodeActions": true,
>   "kilocode.modelSettings": {
>     "temperature": 0.3,
>     "maxTokens": 500,
>     "topP": 0.9
>   }
> }
> ```
>
> > [!TIP]
> >
> > You can use environment variables: `"apiKey": "${env:MEGALLM_API_KEY}"`

> [tab] Using Environment Variables
>
> ### Secure Configuration
>
> **Step 1**: Set environment variables
>
> ```bash theme={null}
> # Add to ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish
> export MEGALLM_API_KEY="sk-mega-your-api-key-here"
> export MEGALLM_BASE_URL="https://ai.megallm.io/v1"
> ```
>
> **Step 2**: Reload shell
>
> ```bash theme={null}
> source ~/.bashrc  # or ~/.zshrc
> ```
>
> **Step 3**: Reference in settings.json
>
> ```json theme={null}
> {
>   "kilocode.apiProvider": "custom",
>   "kilocode.customProvider": {
>     "name": "MegaLLM",
>     "baseURL": "${env:MEGALLM_BASE_URL}",
>     "apiKey": "${env:MEGALLM_API_KEY}"
>   },
>   "kilocode.defaultModel": "gpt-5"
> }
> ```
>
> &#x20;API key stays secure and out of version control

## Scenario Examples

### Scenario 1: First-Time Installation

Complete setup from scratch:

**1. Install Kilocode Extension**

1. Open VSCode
2. Go to Extensions: `Ctrl+Shift+X` / `Cmd+Shift+X`
3. Search: `Kilocode`
4. Click **Install**
5. Reload VSCode window

**2. Get MegaLLM API Key**

1. Visit [MegaLLM Dashboard](https://megallm.io/dashboard)
2. Navigate to **API Keys** section
3. Click **Create New Key**
4. Copy the key (starts with `sk-mega-`)
5. Store it securely

**3. Configure Extension**

Open settings (`Ctrl+,` / `Cmd+,`) and add:

```json theme={null}
{
  "kilocode.apiProvider": "custom",
  "kilocode.customProvider": {
    "name": "MegaLLM",
    "baseURL": "https://ai.megallm.io/v1",
    "apiKey": "sk-mega-your-actual-key-here"
  },
  "kilocode.defaultModel": "gpt-5"
}
```

**4. Test Configuration**

1. Create a new file: `test.js`
2. Type a comment: `// function to calculate fibonacci`
3. Press `Tab` to trigger completion
4. Should see AI-generated code

**Expected Result:**

```javascript theme={null}
// function to calculate fibonacci
function fibonacci(n) {
  if (n <= 1) return n;
  return fibonacci(n - 1) + fibonacci(n - 2);
}
```

***

### Scenario 2: Team Project Configuration

Set up Kilocode for entire development team:

**Project Structure:**

```
my-project/
├── .vscode/
│   ├── settings.json          # Shared config (committed)
│   └── settings.local.json    # Personal keys (gitignored)
├── .gitignore
└── README.md
```

**Step 1: Create Shared Config**

`.vscode/settings.json` (committed to git):

```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",
  "kilocode.modelSettings": {
    "temperature": 0.7,
    "maxTokens": 1000
  },
  "kilocode.enableAutoComplete": true,
  "kilocode.enableInlineChat": true
}
```

**Step 2: Setup .gitignore**

```bash theme={null}
# .gitignore
.vscode/settings.local.json
.env
```

**Step 3: Create Setup Instructions**

`README.md`:

````markdown theme={null}
## Kilocode Setup

### Prerequisites
1. VSCode with Kilocode extension installed
2. MegaLLM API key ([Get one](https://megallm.io/dashboard))

### Configuration

1. **Set environment variable:**
   ```bash
   export MEGALLM_API_KEY="your-key-here"
````

Add to your shell config (\~/.bashrc or \~/.zshrc) to persist.

2. **Or create local settings** (not committed):

   `.vscode/settings.local.json`:

   ```json theme={null}
   {
     "kilocode.customProvider": {
       "apiKey": "your-key-here"
     }
   }
   ```

3. **Reload VSCode** and start coding!

### Verification

Type `// hello world function` and press Tab.
Should see AI-generated code.

````

**Step 4: Team Members Clone and Setup**

```bash
# Team member workflow
git clone https://github.com/company/my-project.git
cd my-project

# Add personal API key
export MEGALLM_API_KEY="their-personal-key"

# Or create .vscode/settings.local.json with their key

# Open in VSCode
code .
````

***

### Scenario 3: Project-Specific Model Selection

Use different models for different projects:

**Python Data Science Project:**

`.vscode/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": "claude-opus-4-1-20250805",
  "kilocode.customPrompts": {
    "analyze": "Analyze this data processing code for efficiency",
    "doc": "Generate numpy-style docstring for this function"
  }
}
```

**JavaScript/React Project:**

`.vscode/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",
  "kilocode.customPrompts": {
    "component": "Generate a React functional component",
    "test": "Write Jest tests for this component"
  }
}
```

**Systems Programming (Rust/Go):**

`.vscode/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": "gemini-2.5-pro",
  "kilocode.modelSettings": {
    "temperature": 0.2  // Lower for more precise systems code
  }
}
```

***

### Scenario 4: Multi-Model Workflow

Switch models dynamically based on task:

**Configuration:**

```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",
  "kilocode.modelProfiles": {
    "fast": {
      "model": "gpt-4o-mini",
      "temperature": 0.5,
      "maxTokens": 300
    },
    "quality": {
      "model": "claude-opus-4-1-20250805",
      "temperature": 0.3,
      "maxTokens": 1000
    },
    "creative": {
      "model": "gpt-5",
      "temperature": 0.9,
      "maxTokens": 800
    }
  }
}
```

**Usage:**

* **Morning (rapid prototyping)**: Use `fast` profile with GPT-4o-mini
* **Afternoon (quality code)**: Use `quality` profile with Claude Opus
* **Documentation**: Use `creative` profile with higher temperature

**Switch profiles via Command Palette:**

1. `Ctrl+Shift+P` / `Cmd+Shift+P`
2. `Kilocode: Switch Model Profile`
3. Select: `fast`, `quality`, or `creative`

***

### Scenario 5: Migration from GitHub Copilot

Switching from Copilot to Kilocode with MegaLLM:

**Current Setup (Copilot):**

```json theme={null}
{
  "github.copilot.enable": true
}
```

**New Setup (Kilocode + MegaLLM):**

**1. Disable Copilot**

```json theme={null}
{
  "github.copilot.enable": false
}
```

**2. Install Kilocode**

VSCode Extensions → Search "Kilocode" → Install

**3. Configure MegaLLM**

```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"
}
```

**4. Compare Experience**

**Benefits over Copilot:**

* &#x20;Access to multiple models (GPT, Claude, Gemini)
* &#x20;Better pricing and no seat limits
* &#x20;Inline chat for explanations
* &#x20;Custom model selection per project
* &#x20;Code actions beyond completion

## Configuration Options

### Complete Reference

```json theme={null}
{
  // Provider Configuration
  "kilocode.apiProvider": "custom",
  "kilocode.customProvider": {
    "name": "MegaLLM",
    "baseURL": "https://ai.megallm.io/v1",
    "apiKey": "${env:MEGALLM_API_KEY}"
  },

  // Model Settings
  "kilocode.defaultModel": "gpt-5",
  "kilocode.modelSettings": {
    "temperature": 0.3,        // 0.0-2.0: Lower = more focused
    "maxTokens": 500,          // Max completion length
    "topP": 0.9,               // Nucleus sampling
    "frequencyPenalty": 0.0,   // Reduce repetition
    "presencePenalty": 0.0     // Encourage diversity
  },

  // Feature Toggles
  "kilocode.enableAutoComplete": true,
  "kilocode.enableInlineChat": true,
  "kilocode.enableCodeActions": true,
  "kilocode.enableSuggestions": true,
  "kilocode.enableHover": true,

  // Behavior
  "kilocode.autoTrigger": true,
  "kilocode.debounceDelay": 300,     // ms before triggering
  "kilocode.maxSuggestions": 3,
  "kilocode.showInlineHints": true,

  // Custom Prompts
  "kilocode.customPrompts": {
    "doc": "Generate comprehensive documentation",
    "test": "Write unit tests with high coverage",
    "refactor": "Refactor for better maintainability",
    "optimize": "Optimize for performance",
    "secure": "Review for security vulnerabilities"
  },

  // Keyboard Shortcuts
  "kilocode.shortcuts": {
    "acceptSuggestion": "Tab",
    "nextSuggestion": "Alt+]",
    "prevSuggestion": "Alt+[",
    "dismissSuggestion": "Esc",
    "triggerInlineChat": "Ctrl+K"
  },

  // UI Preferences
  "kilocode.ui": {
    "showStatusBar": true,
    "showInlineButtons": true,
    "theme": "auto",               // auto, light, dark
    "position": "right"            // left, right
  }
}
```

### Model Selection Guide

| Task | Recommended Model | Reason |
| - | - | - |
| **Code Completion** | `gpt-4o-mini` | Fast, cost-effective |
| **Complex Logic** | `claude-opus-4-1-20250805` | Superior reasoning |
| **Web Development** | `gpt-5` | Excellent JS/TS/React |
| **Data Science** | `claude-sonnet-4` | Strong analysis |
| **Documentation** | `gpt-5` | Clear explanations |
| **Algorithms** | `gemini-2.5-pro` | Mathematical precision |

See [full model catalog](https://docs.megallm.io/home/models) for all options.

## Verification

### Test 1: Basic Completion

```javascript theme={null}
// Type this comment and press Tab:
// function to check if string is palindrome

// Expected output:
function isPalindrome(str) {
  const cleaned = str.toLowerCase().replace(/[^a-z0-9]/g, '');
  return cleaned === cleaned.split('').reverse().join('');
}
```

### Test 2: Inline Chat

1. Select a function
2. Press `Ctrl+K` (or `Cmd+K` on Mac)
3. Type: `Explain this function`
4. Should see explanation in chat panel

### Test 3: Code Actions

1. Right-click on code
2. Should see "Kilocode Actions" in context menu
3. Options: Explain, Improve, Generate Tests, etc.

### Test 4: Status Bar

Check bottom-right of VSCode:

* Should show: `Kilocode: Connected`
* Model name: `gpt-5` (or your selected model)
* Click to see connection details

## Troubleshooting

> [accordion] Completions not appearing
>
> **Symptoms:**
>
> * No suggestions when typing
> * Status bar shows "Disconnected"
>
> **Solutions:**
>
> 1. **Check API key:**
>    ```bash theme={null}
>    echo $MEGALLM_API_KEY
>    # Should output: sk-mega-...
>    ```
>
> 2. **Verify configuration:**
>    ```json theme={null}
>    {
>      "kilocode.apiProvider": "custom",  // Must be "custom"
>      "kilocode.customProvider": {
>        "baseURL": "https://ai.megallm.io/v1"  // No trailing slash
>      }
>    }
>    ```
>
> 3. **Reload VSCode:**
>    * `Ctrl+Shift+P` / `Cmd+Shift+P`
>    * Run: `Developer: Reload Window`
>
> 4. **Check extension is enabled:**
>    * Extensions panel
>    * Search: Kilocode
>    * Should show "Enabled"
>
> 5. **Test API manually:**
>    ```bash theme={null}
>    curl -X POST https://ai.megallm.io/v1/chat/completions \
>      -H "Authorization: Bearer $MEGALLM_API_KEY" \
>      -H "Content-Type: application/json" \
>      -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"test"}]}'
>    ```

> [accordion] Wrong or poor quality completions
>
> **Symptoms:**
>
> * Completions are incorrect
> * Suggestions don't match code style
> * Irrelevant responses
>
> **Solutions:**
>
> 1. **Adjust temperature:**
>    ```json theme={null}
>    {
>      "kilocode.modelSettings": {
>        "temperature": 0.2  // Lower = more focused (0.0-1.0)
>      }
>    }
>    ```
>
> 2. **Try different model:**
>    ```json theme={null}
>    {
>      "kilocode.defaultModel": "claude-sonnet-4"  // Better for analysis
>    }
>    ```
>
> 3. **Increase context:**
>    ```json theme={null}
>    {
>      "kilocode.modelSettings": {
>        "maxTokens": 1000  // More detailed completions
>      }
>    }
>    ```
>
> 4. **Add project-specific prompt:**
>    ```json theme={null}
>    {
>      "kilocode.systemPrompt": "You are an expert in TypeScript and React. Follow Airbnb style guide."
>    }
>    ```

> [accordion] High latency / slow completions
>
> **Symptoms:**
>
> * Long wait for suggestions
> * Timeout errors
>
> **Solutions:**
>
> 1. **Use faster model:**
>    ```json theme={null}
>    {
>      "kilocode.defaultModel": "gpt-4o-mini"  // Fastest
>    }
>    ```
>
> 2. **Reduce max tokens:**
>    ```json theme={null}
>    {
>      "kilocode.modelSettings": {
>        "maxTokens": 300  // Faster completions
>      }
>    }
>    ```
>
> 3. **Increase debounce delay:**
>    ```json theme={null}
>    {
>      "kilocode.debounceDelay": 500  // Wait longer before triggering
>    }
>    ```
>
> 4. **Check network:**
>    ```bash theme={null}
>    ping ai.megallm.io
>    curl -w "@-" -o /dev/null -s https://ai.megallm.io/v1/models <<'EOF'
>    time_total: %{time_total}s
>    EOF
>    ```

> [accordion] API key not recognized
>
> **Symptoms:**
>
> * "Invalid API key" error
> * 401 Unauthorized
>
> **Solutions:**
>
> 1. **Verify key format:**
>    * Must start with `sk-mega-`
>    * At least 60 characters
>    * No spaces or quotes
>
> 2. **Check key is active:**
>    * Login to [Dashboard](https://megallm.io/dashboard)
>    * Go to API Keys
>    * Verify key is not revoked/expired
>
> 3. **Test key directly:**
>    ```bash theme={null}
>    curl -H "Authorization: Bearer sk-mega-your-key" \
>         https://ai.megallm.io/v1/models
>    ```
>
> 4. **Regenerate if needed:**
>    * Dashboard → API Keys → Create New
>    * Update configuration with new key

> [accordion] Conflicts with other extensions
>
> **Symptoms:**
>
> * Kilocode completions conflict with other AI tools
> * Multiple suggestions appearing
>
> **Solutions:**
>
> 1. **Disable conflicting extensions:**
>    ```json theme={null}
>    {
>      "github.copilot.enable": false,
>      "tabnine.disable": true,
>      "aws.codeWhisperer.enabled": false
>    }
>    ```
>
> 2. **Adjust trigger keys:**
>    ```json theme={null}
>    {
>      "kilocode.shortcuts": {
>        "acceptSuggestion": "Alt+Enter"  // Different from Tab
>      }
>    }
>    ```
>
> 3. **Set priority:**
>    ```json theme={null}
>    {
>      "editor.suggest.snippetsPreventQuickSuggestions": false,
>      "editor.quickSuggestions": {
>        "other": "on",
>        "comments": "off",
>        "strings": "on"
>      }
>    }
>    ```

## Best Practices

> [card] Use Environment Variables
>
> Keep API keys in env vars, reference with `${env:MEGALLM_API_KEY}`

> [card] Project-Specific Models
>
> Configure different models in `.vscode/settings.json` per project

> [card] Lower Temperature for Code
>
> Use 0.2-0.4 for code generation, 0.7-0.9 for documentation

> [card] Monitor Token Usage
>
> Check [Dashboard](https://megallm.io/dashboard) to optimize costs

## Advanced Tips

### Custom Keyboard Shortcuts

Add to `keybindings.json`:

```json theme={null}
[
  {
    "key": "ctrl+alt+k",
    "command": "kilocode.triggerSuggestion",
    "when": "editorTextFocus"
  },
  {
    "key": "ctrl+alt+e",
    "command": "kilocode.explainCode",
    "when": "editorHasSelection"
  },
  {
    "key": "ctrl+alt+t",
    "command": "kilocode.generateTests",
    "when": "editorTextFocus"
  }
]
```

### Workspace-Specific Prompts

`.vscode/settings.json`:

```json theme={null}
{
  "kilocode.customPrompts": {
    "api": "Generate RESTful API endpoint following our conventions",
    "schema": "Create Prisma schema model",
    "hook": "Generate React custom hook",
    "component": "Create styled-component with TypeScript"
  }
}
```

### Context-Aware Completions

```json theme={null}
{
  "kilocode.contextSettings": {
    "includeOpenFiles": true,
    "includeImports": true,
    "includeTypes": true,
    "maxContextFiles": 5
  }
}
```

## Next Steps

> [card] [RooCode Setup](https://docs.megallm.io/en/agents/roocode.md)
>
> Configure RooCode application

> [card] [Cline Setup](https://docs.megallm.io/en/agents/cline.md)
>
> Configure Cline VSCode extension

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

> [card] [Other Agents](https://docs.megallm.io/en/agents/overview.md)
>
> View all CLI and GUI agents

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

> [card] [Discord Community](https://discord.gg/Megallm)
>
> Join for support


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