### Quick Start Source: https://context7_llms A brief guide to get started with the MegaLLM API quickly. ```APIDOC ## Quick Start Get up and running with MegaLLM API in just a few minutes. This guide will walk you through the initial setup and your first API call. **Prerequisites**: You'll need a MegaLLM API key to use our services. ``` -------------------------------- ### Install and Run MegaLLM Setup Tool Source: https://www.npmjs.com/package/megallm This section provides commands for installing and running the MegaLLM setup tool using NPX. It includes specific instructions for Windows users, macOS/Linux users, and global installation. The tool helps configure Claude Code and Codex with MegaLLM AI. ```bash npx megallm@latest ``` ```bash # Clear npm cache first npm cache clean --force # Use with explicit version npx megallm@latest # Or use cmd.exe cmd /c "npx megallm" # Or install globally npm install -g megallm@latest megallm ``` ```bash npx megallm ``` ```bash npm install -g megallm megallm ``` -------------------------------- ### First-Time Setup for Claude Code via CLI Source: https://context7_llms This example demonstrates a scenario-based first-time setup for Claude Code using the MegaLLM CLI. It involves running the CLI tool and then following a series of prompts to select the tool, setup level, and provide the API key. The output shows the expected prompts and selections. ```bash # Step 1: Run the CLI npx megallm@latest # Step 2: Follow the prompts # System detected ✓ # Claude Code detected ✓ # # ? Which tool would you like to configure? # › Claude Code # Codex/Windsurf # OpenCode # Configure All # Step 3: Choose setup level # ? Setup level? # › System-level (global) - Applies to all projects # Project-level (local) - Current directory only # Step 4: API Key # ? Do you have a MegaLLM API key? # › Yes ``` -------------------------------- ### Interactive MegaLLM CLI Setup Source: https://context7_llms This command initiates an interactive setup process for the MegaLLM CLI. It guides the user through detecting the system and tools, selecting a tool to configure, choosing a setup level (system or project), and entering API keys. The output shows a sample interaction and summary. ```bash # Run the interactive setup npx megallm@latest # Output: # __ __ _ _ __ __ # | \/ | ___ __ _ __ _| | | | | \/ | # | |\/| |/ _ \/ _` |/ _` | | | | | |\/| | # | | | | __/ (_| | (_| | |___| |___| | | | # |_| |_|\___|\__, |\__,_|_____|_____|_| |_| # |___/ # # 🚀 MegaLLM CLI Setup Tool # Supported: Claude Code, Codex/Windsurf, OpenCode # # ✓ System detected: Linux (bash) # ✓ Tools detected: Claude Code ✓ # # ? Which tool would you like to configure? Claude Code # ? Setup level? System-level (global) # ? Do you have a MegaLLM API key? Yes # ? Enter your MegaLLM API key: sk-mega-*** # # Configuration Summary: # - Tool: Claude Code # - Level: System-level # - API Key: sk-mega-***86b9 (last 4 chars) # # ? Apply this configuration? Yes # # ✓ Configuration applied successfully! # ✓ Shell reloaded # # 🎉 Setup complete! You can now use Claude Code with MegaLLM. ``` -------------------------------- ### Install MegaLLM SDK (Go) Source: https://context7_llms This command installs the Go SDK for interacting with OpenAI-compatible APIs, which can be used with MegaLLM. The `go get` command fetches and installs the specified package, making its functionalities available in your Go projects. ```bash go get github.com/sashabaranov/go-openai ``` -------------------------------- ### System-Level MegaLLM Setup Source: https://context7_llms This example shows how to perform a system-level (global) setup for MegaLLM, which configures it for all projects on the system. It involves running the CLI, providing an API key, and confirming the application of settings, which may update configuration files like `~/.claude/settings.json` and `~/.claude.json`, and environment variables in `~/.bashrc`. ```bash # ? Enter your MegaLLM API key: sk-mega-25f8b5b41a531921b24bf59daa8ccc0d38da68364662fb8956d972333b8d86b9 # ? Apply this configuration? Yes # ✓ Created ~/.claude/settings.json # ✓ Created ~/.claude.json # ✓ Added environment variables to ~/.bashrc # ✓ Configuration applied successfully! ``` -------------------------------- ### OpenCode Setup Instructions (Markdown) Source: https://context7_llms A markdown snippet providing setup instructions for OpenCode, including prerequisites like obtaining a MegaLLM API key, installing the CLI, and setting the MEGALLM_API_KEY environment variable persistently. ```markdown # OpenCode Setup ## Prerequisites 1. Get MegaLLM API key from https://megallm.io/dashboard 2. Install OpenCode: `npm install -g opencode-ai` ## Setup Set the MEGALLM_API_KEY environment variable: ```bash export MEGALLM_API_KEY="your-api-key-here" ``` Add to your shell config (\~/.bashrc or \~/.zshrc) to make it permanent. ``` -------------------------------- ### OpenCode Setup Instructions (Markdown) Source: https://context7_llms Provides step-by-step instructions for setting up OpenCode, including prerequisites like obtaining a MegaLLM API key and installing the tool. It also details how to set the necessary environment variable. ```markdown # OpenCode Setup ## Prerequisites 1. Get MegaLLM API key from https://megallm.io/dashboard 2. Install OpenCode: `npm install -g opencode-ai` ## Setup Set the MEGALLM_API_KEY environment variable: ```bash export MEGALLM_API_KEY="your-api-key-here" ```` Add to your shell config (\~/.bashrc or \~/.zshrc) to make it permanent. ``` -------------------------------- ### Run MegaLLM CLI Source: https://github.com/Megallm/megallm-npm Initiates the MegaLLM interactive command-line interface for setup and configuration. This is the recommended way to start using MegaLLM. ```bash npx megallm@latest ``` -------------------------------- ### Install and Run MegaLLM CLI Globally (Bash) Source: https://context7_llms This example shows how to install the MegaLLM CLI globally using npm, allowing it to be run from any directory. After global installation, the `megallm` command can be executed directly. ```bash npm install -g megallm megallm ``` -------------------------------- ### New Developer Onboarding Workflow with MegaLLM Source: https://context7_llms This bash script outlines the workflow for onboarding a new developer to a project using MegaLLM. It covers cloning the repository, finding setup instructions, obtaining an API key, running the MegaLLM CLI for configuration, and starting development. ```bash # 1. New developer clones the repository git clone https://github.com/company/project.git cd project # 2. Sees MegaLLM setup instructions in README cat README.md # "Get your API key from https://megallm.io/dashboard" # 3. Gets API key from dashboard # Opens https://megallm.io/dashboard in browser # 4. Runs setup (with NO_BANNER for cleaner output) NO_BANNER=1 npx megallm@latest # 5. Enters API key when prompted # Configuration automatically merges with project settings # 6. Starts developing npm run dev ``` -------------------------------- ### Project-Specific MegaLLM Setup Source: https://context7_llms This example details how to set up MegaLLM for a specific project, creating a local configuration. It involves navigating to the project directory, running the CLI, selecting project-level setup, and then adding the local configuration file (`.claude/settings.local.json`) to `.gitignore` and committing the shared `settings.json` to version control. ```bash # Navigate to your project cd ~/projects/my-app # Run the CLI npx megallm@latest # Choose project-level setup # ? Setup level? # System-level (global) # › Project-level (local) - Current directory only # After configuration: ls -la .claude/ # .claude/ # settings.json # settings.local.json # Add to .gitignore echo ".claude/settings.local.json" >> .gitignore # Commit project settings (without API key) cat .claude/settings.json # { # "env": { # "ANTHROPIC_BASE_URL": "https://ai.megallm.io" # } # } git add .claude/settings.json .gitignore git commit -m "Add MegaLLM configuration" ``` -------------------------------- ### Claude Code Setup Instructions Source: https://context7_llms Provides step-by-step instructions for setting up Claude Code, including installing the package, obtaining an API key, and configuring it either through a local JSON file or an environment variable. ```markdown # MegaLLM Claude Code Setup ## Prerequisites 1. Get your MegaLLM API key from https://megallm.io/dashboard 2. Install Claude Code: `npm install -g @anthropic-ai/claude-code` ## Setup 1. Create `.claude/settings.local.json`: ```json { "env": { "ANTHROPIC_API_KEY": "your-key-here" } } ```` 2. Or set environment variable: ```bash export ANTHROPIC_API_KEY="your-key-here" ``` ``` -------------------------------- ### Install and Use MegaLLM CLI Source: https://context7_llms Instructions for installing the MegaLLM CLI using npm. It prompts the user to follow an interactive setup process for configuration. ```bash # Install MegaLLM CLI npx megallm@latest # Follow the interactive setup ``` -------------------------------- ### Team Setup Instructions README Source: https://context7_llms Provides setup instructions for team members using Claude Code, including prerequisites like obtaining an API key and installing the tool, and detailing how to configure personal settings via a local JSON file or environment variable. ```markdown # MegaLLM Claude Code Setup ## Prerequisites 1. Get your MegaLLM API key from https://megallm.io/dashboard 2. Install Claude Code: `npm install -g @anthropic-ai/claude-code` ## Setup 1. Create `.claude/settings.local.json`: ```json { "env": { "ANTHROPIC_API_KEY": "your-key-here" } } ``` 2. Or set environment variable: ```bash export ANTHROPIC_API_KEY="your-key-here" ``` ``` -------------------------------- ### MegaLLM Setup Process Flow Diagram Source: https://github.com/Megallm/megallm-npm A text-based diagram illustrating the step-by-step flow of the MegaLLM setup process, from initiating the CLI to completing the configuration. ```text ┌──────────────────────────────────────────────────────┐ │ npx megallm │ └────────────────────────┬─────────────────────────────┘ ▼ ┌──────────────────────────────────────────────────────┐ │ 🔍 Environment Detection │ ├──────────────────────────────────────────────────────┤ │ • Operating System (Mac/Linux/Win) │ │ • Shell Type (bash/zsh/fish/PS) │ │ • Installed Tools (Claude/Codex) │ └────────────────────────┬─────────────────────────────┘ ▼ ┌──────────────────────────────────────────────────────┐ │ 🔑 API Key Setup │ ├──────────────────────────────────────────────────────┤ │ Have API Key? │ ├─ No → Opens megallm.io │ │ Shows instructions │ │ Waits for key entry │ └─ Yes → Enter API key └────────────────────────┬─────────────────────────────┘ ▼ ┌──────────────────────────────────────────────────────┐ │ ⚙️ Configuration Choice │ ├──────────────────────────────────────────────────────┤ │ Tool Selection: │ • Claude Code only │ • Codex/Windsurf only │ • Both tools │ │ │ Setup Level: │ • System (~/.claude, ~/.codex) │ • Project (./.claude, ./.codex) └────────────────────────┬─────────────────────────────┘ ▼ ┌──────────────────────────────────────────────────────┐ │ 📝 Apply Configuration │ ├──────────────────────────────────────────────────────┤ │ • Create/update config files │ • Set environment variables │ • Backup existing configs │ • Reload shell if needed └────────────────────────┬─────────────────────────────┘ ▼ ┌──────────────────────────────────────────────────────┐ │ ✅ Complete! │ └──────────────────────────────────────────────────────┘ ``` -------------------------------- ### Install Node.js and npm on Linux (Ubuntu/Debian/Fedora) Source: https://context7_llms These commands guide users through installing Node.js and npm on Linux systems, specifically for Ubuntu/Debian using NodeSource and for Fedora. Proper installation ensures the MegaLLM CLI can function correctly. ```bash # Ubuntu/Debian curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs # Fedora sudo dnf install nodejs ``` -------------------------------- ### Create HTTP Server with Node.js Source: https://nodejs.org/ This example demonstrates how to create a basic HTTP server using Node.js. It listens on port 3000 and responds with 'Hello World!' to incoming requests. Ensure Node.js is installed to run this code. ```javascript import { createServer } from 'node:http'; const server = createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World!\n'); }); server.listen(3000, '127.0.0.1', () => { console.log('Listening on 127.0.0.1:3000'); }); ``` -------------------------------- ### Team Setup with Shared MegaLLM Config Source: https://context7_llms This example illustrates setting up MegaLLM for a team project where the base configuration is shared via version control. A project maintainer creates a shared `.claude/settings.json` (without API keys) and a `README.md` detailing setup instructions. Team members then clone the repository and add their own API keys, typically in a local `.claude/settings.local.json` file. ```bash # Project maintainer: Create base configuration cd ~/projects/team-project npx megallm@latest # Choose project-level # Setup level: Project-level # Create .claude/settings.json (without API key) cat > .claude/settings.json << 'EOF' { "env": { "ANTHROPIC_BASE_URL": "https://ai.megallm.io" } } EOF # Document API key requirement cat > .claude/README.md << 'EOF' # MegaLLM Setup To use this project with MegaLLM: 1. Get your API key from https://megallm.io/dashboard 2. Create `.claude/settings.local.json`: { "env": { "ANTHROPIC_API_KEY": "your-api-key-here" } } 3. Or set environment variable: export ANTHROPIC_API_KEY="your-api-key-here" EOF # Commit shared configuration git add .claude/settings.json .claude/README.md git commit -m "Add MegaLLM team configuration" # Team members: Clone and add their own API key git clone repo cd repo echo '{ "env": { "ANTHROPIC_API_KEY": "my-key" } }' > .claude/settings.local.json ``` -------------------------------- ### Project Contribution Workflow (Git Bash) Source: https://github.com/Megallm/megallm-npm This example outlines the steps for contributing to the MegaLLM project using Git. It covers forking the repository, cloning it locally, installing dependencies, making changes, testing, and submitting a pull request. This is a standard workflow for open-source contributions. ```bash # Fork and clone git clone https://github.com/yourusername/megallm-npm cd megallm-npm # Install dependencies npm install # Make changes and test npm start # Submit PR git push origin feature/your-feature ``` -------------------------------- ### Docker Container Setup for MegaLLM Source: https://context7_llms This Dockerfile outlines the steps to set up a Docker container environment for using MegaLLM. It includes installing the MegaLLM CLI globally, setting essential environment variables for API access, and copying custom configuration files. ```dockerfile FROM node:18 # Install MegaLLM CLI globally RUN npm install -g megallm # Set environment variables ENV ANTHROPIC_BASE_URL=https://ai.megallm.io ENV ANTHROPIC_API_KEY=your-key-here # Create configuration directory RUN mkdir -p /root/.claude # Copy configuration file COPY .claude/settings.json /root/.claude/settings.json # Your app setup WORKDIR /app COPY . . RUN npm install CMD ["npm", "start"] ``` -------------------------------- ### Install SDK Source: https://context7_llms Commands to install the necessary OpenAI SDK for Python and JavaScript projects. This is a prerequisite for using the Megallm API. ```bash pip install openai # Python npm install openai # JavaScript ``` -------------------------------- ### Globally Installing MegaLLM CLI Source: https://context7_llms This command shows how to install the MegaLLM CLI globally on your system using npm. Global installation allows you to run the 'megallm' command from any directory. ```bash npm install -g megallm ``` -------------------------------- ### Global Installation of MegaLLM CLI Source: https://context7_llms Installs the MegaLLM CLI globally on your system using npm, allowing it to be run anytime. This method is suitable for frequent users as it provides faster startup and offline access after the initial installation. ```bash # Install globally npm install -g megallm # Run the CLI megallm # Update the CLI npm update -g megallm # Uninstall the CLI npm uninstall -g megallm ``` -------------------------------- ### Install and Use Node.js 18 with nvm-windows Source: https://context7_llms Demonstrates how to install and use Node.js version 18 on Windows using nvm-windows. ```powershell nvm install 18 nvm use 18 ``` -------------------------------- ### Quick Start: Interact with MegaLLM Chat Completions Source: https://context7_llms Examples demonstrate how to send a 'Hello!' message to the 'gpt-4' model using MegaLLM's API. This includes Python and JavaScript SDKs, and a cURL command. Ensure you have the necessary API key and library installed. ```python from openai import OpenAI client = OpenAI( base_url="https://ai.megallm.io/v1", api_key="your-api-key" ) response = client.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": "Hello!"}] ) ``` ```javascript import OpenAI from 'openai'; const openai = new OpenAI({ baseURL: 'https://ai.megallm.io/v1', apiKey: process.env.MEGALLM_API_KEY, }); const response = await openai.chat.completions.create({ model: 'gpt-4', messages: [{ role: 'user', content: 'Hello!' }] }); ``` ```bash curl https://ai.megallm.io/v1/chat/completions \ -H "Authorization: Bearer $MEGALLM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4", "messages": [{"role": "user", "content": "Hello!"}] }' ``` -------------------------------- ### Verify Node.js and npm Installation Source: https://context7_llms After installing Node.js and npm, this command verifies that the installations were successful by checking their respective version numbers. This is a crucial step before proceeding with MegaLLM CLI setup. ```bash node --version npm --version ``` -------------------------------- ### Local Project Installation of MegaLLM CLI Source: https://context7_llms Installs the MegaLLM CLI as a development dependency within a local project using npm. This is recommended for team projects requiring a standardized setup, version-locked installations, and for use in CI/CD pipelines. ```bash # Install as dev dependency npm install --save-dev megallm ``` ```json { "scripts": { "setup-megallm": "megallm" } } ``` ```bash # Run via npm script npm run setup-megallm ``` -------------------------------- ### MegaLLM CLI Offering to Install Missing AI Tools Source: https://context7_llms This example shows the MegaLLM CLI's interactive prompt when it detects that a required AI tool, such as Claude Code, is not installed. It offers to install the missing tool via NPM. ```bash ? Claude Code is not installed. Would you like to install it? (Y/n) ``` -------------------------------- ### Install Kilocode Extension and Configure MegaLLM API Source: https://context7_llms Instructions for installing the Kilocode extension in VSCode and configuring it to use the MegaLLM API. This involves getting an API key from the MegaLLM dashboard and adding it to VSCode settings. ```json { "kilocode.apiProvider": "custom", "kilocode.customProvider": { "name": "MegaLLM", "baseURL": "https://ai.megallm.io/v1", "apiKey": "sk-mega-your-actual-key-here" }, "kilocode.defaultModel": "gpt-5" } ``` -------------------------------- ### MegaLLM Initial Configuration Prompt Source: https://context7_llms This example demonstrates the command-line interface prompt when an existing MegaLLM configuration is detected. It presents options to override, skip, or cancel the configuration process. ```bash Found existing MegaLLM configuration: - ~/.claude/settings.json - ~/.codex/config.toml ? What would you like to do? Override (remove old, apply new) Skip (keep existing) Cancel ``` -------------------------------- ### Manual System-Level OpenCode Setup (Bash) Source: https://context7_llms This bash script manually sets up the system-level OpenCode configuration. It creates the necessary directory, writes the `opencode.json` configuration file, sets the `MEGALLM_API_KEY` environment variable in `.bashrc`, and sources the file. It also includes a verification step using `jq`. Dependencies: `mkdir`, `cat`, `echo`, `source`, `jq`. ```bash # 1. Create directory ``` ```bash mkdir -p ~/.config/opencode ``` ```bash # 2. Create config file ``` ```bash cat > ~/.config/opencode/opencode.json << 'EOF' { "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": { "options": { "apiKey": "{env:MEGALLM_API_KEY}", "baseURL": "https://ai.megallm.io/v1" } } }, "autoupdate": true, "tools": { "bash": true, "edit": true, "write": true, "read": true } } EOF ``` ```bash # 3. Set environment variable ``` ```bash echo 'export MEGALLM_API_KEY="your-api-key"' >> ~/.bashrc source ~/.bashrc ``` ```bash # 4. Verify ``` ```bash cat ~/.config/opencode/opencode.json | jq . ``` -------------------------------- ### TypeScript - Weather Function Example Source: https://context7_llms This example demonstrates how to define and use a type-safe function for getting weather information using the MegaLLM API. It includes interface definitions for parameters and results, function implementation, and tool definitions for the OpenAI API. ```APIDOC ## TypeScript Function Calling Example ### Description This example demonstrates how to implement type-safe function calling with the MegaLLM API using TypeScript. It defines interfaces for function parameters and results, registers the function, and configures tools for the OpenAI client. ### Method N/A (Client-side implementation) ### Endpoint `https://ai.megallm.io/v1` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body N/A (Code-level implementation) ### Request Example ```typescript import OpenAI from 'openai'; interface WeatherParams { location: string; unit?: 'celsius' | 'fahrenheit'; } interface WeatherResult { location: string; temperature: number; unit: string; condition: string; } const openai = new OpenAI({ baseURL: 'https://ai.megallm.io/v1', apiKey: process.env.GITHUB_TOKEN!, }); async function getWeather({ location, unit = 'celsius' }: WeatherParams): Promise { // Real implementation would call an API return { location, temperature: 22, unit, condition: 'sunny' }; } const functionRegistry = { get_weather: getWeather } as const; const tools: OpenAI.Chat.ChatCompletionTool[] = [ { type: 'function', function: { name: 'get_weather', description: 'Get the current weather in a given location', parameters: { type: 'object', properties: { location: { type: 'string', description: 'The city and state, e.g. San Francisco, CA' }, unit: { type: 'string', enum: ['celsius', 'fahrenheit'], description: 'Temperature unit' } }, required: ['location'] } } } ]; async function handleToolCalls(message: OpenAI.Chat.ChatCompletionMessage) { if (!message.tool_calls) return null; const toolResults = await Promise.all( message.tool_calls.map(async (toolCall) => { const fn = functionRegistry[toolCall.function.name as keyof typeof functionRegistry]; if (!fn) throw new Error(`Unknown function: ${toolCall.function.name}`); const args = JSON.parse(toolCall.function.arguments); const result = await fn(args); return { role: 'tool' as const, tool_call_id: toolCall.id, content: JSON.stringify(result) }; }) ); return toolResults; } async function askAboutWeather() { const response = await openai.chat.completions.create({ model: 'gpt-4', messages: [{ role: 'user', content: "What's the weather in London and Paris?" }], tools, tool_choice: 'auto' }); const toolResults = await handleToolCalls(response.choices[0].message); if (toolResults) { const followUp = await openai.chat.completions.create({ model: 'gpt-4', messages: [ { role: 'user', content: "What's the weather in London and Paris?" }, response.choices[0].message, ...toolResults ] }); return followUp.choices[0].message.content; } return response.choices[0].message.content; } ``` ### Response #### Success Response (200) Returns the content of the chat completion message, which may include tool calls or final text responses. #### Response Example ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1700000000, "model": "gpt-4", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The weather in London is 22 degrees Celsius and sunny. The weather in Paris is 22 degrees Celsius and sunny." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30 } } ``` ``` -------------------------------- ### Run MegaLLM with Advanced Options Source: https://www.npmjs.com/package/megallm Demonstrates how to run the MegaLLM setup tool with advanced command-line options for debugging or skipping the banner. These options allow for more control over the tool's execution. ```bash DEBUG=* npx megallm ``` ```bash NO_BANNER=1 npx megallm ``` -------------------------------- ### Set Up Node.js Project for MegaLLM API Source: https://context7_llms This snippet details how to initialize a new Node.js project, install required packages (openai, dotenv), and prepare the environment for making API calls to MegaLLM. ```bash mkdir my-first-ai-app cd my-first-ai-app npm init -y npm install openai dotenv ``` -------------------------------- ### Manual System-Level OpenCode Setup Source: https://context7_llms Bash commands to manually set up OpenCode at the system level. This includes creating the configuration directory, creating the `opencode.json` file with MegaLLM provider details, and setting the API key environment variable. ```bash # 1. Create directory mkdir -p ~/.config/opencode # 2. Create config file cat > ~/.config/opencode/opencode.json << 'EOF' { "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": { "options": { "apiKey": "{env:MEGALLM_API_KEY}", "baseURL": "https://ai.megallm.io/v1" } } }, "autoupdate": true, "tools": { "bash": true, "edit": true, "write": true, "read": true } } EOF # 3. Set environment variable echo 'export MEGALLM_API_KEY="your-api-key"' >> ~/.bashrc source ~/.bashrc # 4. Verify cat ~/.config/opencode/opencode.json | jq . ``` -------------------------------- ### RooCode Team Setup Instructions (Markdown) Source: https://context7_llms This Markdown file provides step-by-step instructions for team members to set up RooCode with the shared team configuration. It covers prerequisites, importing the base configuration, adding personal API keys, and restarting the application. It also includes verification steps and troubleshooting tips. ```markdown # RooCode Team Setup Guide ## Prerequisites - RooCode application installed ([Download](https://roocode.io)) - MegaLLM API key ([Get yours](https://megallm.io/dashboard)) ## Setup Steps ### 1. Get Your Personal API Key 1. Go to https://megallm.io/dashboard 2. Navigate to **API Keys** 3. Click **Create New Key** 4. Copy your key (starts with `sk-mega-`) ### 2. Import Team Configuration 1. Download `team-roocode-config.json` from this repo 2. Open RooCode 3. Go to: `File → Import Configuration` 4. Select `team-roocode-config.json` ### 3. Add Your Personal API Key 1. After import, go to: `Settings → API Configuration` 2. Replace `TEAM_MEMBER_REPLACES_THIS` with your actual key 3. Click **Test Connection** (should show ✓ Success) 4. Click **Save** ### 4. Restart RooCode Close and reopen RooCode to apply all settings. ## Verification 1. Open a new chat 2. Type: `Generate a React component for a login form` 3. Should generate TypeScript code following Airbnb style ## Troubleshooting - **Connection failed**: Check API key is correct - **Wrong code style**: Verify configuration imported correctly - **Model errors**: Ensure using `gpt-5` or other supported models ## Support Contact team lead or check [MegaLLM Docs](https://docs.megallm.io) ``` -------------------------------- ### Manual Project-Level OpenCode Setup Source: https://context7_llms Bash commands to manually set up OpenCode for a specific project. This involves navigating to the project directory and creating an `opencode.json` file with MegaLLM provider configuration. ```bash # 1. Navigate to project cd ~/projects/my-project # 2. Create config file cat > opencode.json << 'EOF' { "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": { "options": { "apiKey": "{env:MEGALLM_API_KEY}", "baseURL": "https://ai.megallm.io/v1" } } }, "tools": { "bash": true, "edit": true, "write": true, "read": true } } EOF ``` -------------------------------- ### Project Initialization Script (Bash) Source: https://context7_llms This bash script outlines the steps for setting up a new project that uses MegaLLM. It includes creating a project directory, setting up a Python virtual environment with necessary packages (openai, python-dotenv), or initializing a Node.js project with npm (openai, dotenv). It also demonstrates creating a .env file and adding it to .gitignore. ```bash # Python python -m venv venv source venv/bin/activate pip install openai python-dotenv # JavaScript npm init -y npm install openai dotenv echo "MEGALLM_API_KEY=your-key-here" > .env echo ".env" >> .gitignore ``` -------------------------------- ### Manual Project-Level OpenCode Setup (Bash) Source: https://context7_llms This bash script manually sets up project-level OpenCode configuration. It navigates to the project directory, creates the `opencode.json` file, sets the `MEGALLM_API_KEY` environment variable (if not already set), and adds `opencode.json` to `.gitignore`. Dependencies: `cd`, `cat`, `echo`, `source`, `echo`. ```bash # 1. Navigate to project ``` ```bash cd ~/projects/my-project ``` ```bash # 2. Create config file ``` ```bash cat > opencode.json << 'EOF' { "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": { "options": { "apiKey": "{env:MEGALLM_API_KEY}", "baseURL": "https://ai.megallm.io/v1" } } }, "tools": { "bash": true, "edit": true, "write": true, "read": true } } EOF ``` ```bash # 3. Set environment variable (if not already set) ``` ```bash echo 'export MEGALLM_API_KEY="your-api-key"' >> ~/.bashrc source ~/.bashrc ``` ```bash # 4. Add to .gitignore ``` ```bash echo "opencode.json" >> .gitignore ``` -------------------------------- ### Set Up Python Project for MegaLLM API Source: https://context7_llms This snippet outlines the steps to create a new project directory, set up a virtual environment, and install necessary Python dependencies (openai, python-dotenv) for interacting with the MegaLLM API. ```bash mkdir my-first-ai-app cd my-first-ai-app python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install openai python-dotenv ``` -------------------------------- ### Automated CI/CD Setup for MegaLLM with GitHub Actions and GitLab CI Source: https://context7_llms This snippet demonstrates how to automate the setup of MegaLLM within CI/CD pipelines using both GitHub Actions and GitLab CI. It includes configuring environment variables for API keys and base URLs, and creating necessary configuration files. ```yaml name: Setup MegaLLM on: [push] jobs: setup: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '18' - name: Configure MegaLLM env: ANTHROPIC_API_KEY: ${{ secrets.MEGALLM_API_KEY }} ANTHROPIC_BASE_URL: https://ai.megallm.io run: | mkdir -p .claude cat > .claude/settings.json << EOF { "env": { "ANTHROPIC_BASE_URL": "$ANTHROPIC_BASE_URL", "ANTHROPIC_API_KEY": "$ANTHROPIC_API_KEY" } } EOF - name: Run tests with Claude Code run: npm test ``` ```yaml setup_megallm: stage: setup image: node:18 script: - mkdir -p .claude - | cat > .claude/settings.json << EOF { "env": { "ANTHROPIC_BASE_URL": "https://ai.megallm.io", "ANTHROPIC_API_KEY": "${MEGALLM_API_KEY}" } } EOF variables: ANTHROPIC_BASE_URL: "https://ai.megallm.io" artifacts: paths: - .claude/ ``` -------------------------------- ### Kilocode VSCode User Settings and Environment Variable Source: https://context7_llms Details the setup for Kilocode within VSCode, focusing on user settings and the required environment variable for authentication. It guides users to the VSCode settings search bar to find Kilocode configurations. ```bash # VSCode User Settings # File > Preferences > Settings > Search "kilocode" # Environment variable export MEGALLM_API_KEY="sk-mega-your-key" ``` -------------------------------- ### Configure Anthropic Client (JavaScript) Source: https://context7_llms This JavaScript snippet configures the Anthropic client to work with MegaLLM. It sets the `baseURL` to MegaLLM's API endpoint and retrieves the API key from `process.env.MEGALLM_API_KEY`. An example call to create a message is provided to verify the setup. ```javascript import Anthropic from '@anthropic-ai/sdk'; const client = new Anthropic({ baseURL: 'https://ai.megallm.io', apiKey: process.env.MEGALLM_API_KEY }); // Test the connection const message = await client.messages.create({ model: 'claude-3.5-sonnet', max_tokens: 100, messages: [{ role: 'user', content: 'Hello!' }] }); console.log(message.content[0].text); ``` -------------------------------- ### Windsurf-Specific Setup with MegaLLM CLI Source: https://context7_llms This bash script demonstrates configuring the Windsurf variant of MegaLLM using the command-line interface. It outlines the steps for selecting the tool, automatic detection of Windsurf, and how configuration is stored, including verifying the generated TOML file. ```bash # Run the CLI npx megallm@latest # Select Codex # ? Which tool would you like to configure? # Claude Code # › Codex/Windsurf # OpenCode # Note: Windsurf is automatically detected # ✓ Windsurf variant detected # Configuration proceeds normally # Creates ~/.codex/config.toml # Sets MEGALLM_API_KEY environment variable # Verify configuration cat ~/.codex/config.toml # 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" ``` -------------------------------- ### Configure Custom Prompts for Code Generation Source: https://context7_llms Define custom prompts to guide the LLM's output for specific tasks like code generation. This example sets a 'generate' prompt to ensure production-ready TypeScript code following best practices. ```json { "customPrompts": { "generate": "Generate production-ready TypeScript code following best practices" } } ``` -------------------------------- ### Fixing Permission Denied Errors with MegaLLM CLI Source: https://context7_llms This code snippet demonstrates how to resolve 'permission denied' errors when running the MegaLLM CLI, typically occurring during initial setup. It involves changing ownership and permissions of the .claude and .codex directories before retrying the CLI installation. ```bash # Error during setup npx megallm@latest # Error: EACCES: permission denied, mkdir '/home/user/.claude' # Fix permissions sudo chown -R $USER ~/.claude ~/.codex chmod -R 755 ~/.claude ~/.codex # Retry npx megallm@latest ``` -------------------------------- ### NPX Installation Methods for MegaLLM CLI Source: https://context7_llms Demonstrates how to run the MegaLLM CLI using NPX, including running the latest version, a specific version, and with environment variables. NPX is recommended for its ease of use and for always accessing the latest version without disk usage. ```bash # Run latest version npx megallm@latest # Run specific version npx megallm@2.5.9 # With environment variables NO_BANNER=1 npx megallm@latest ``` -------------------------------- ### Example Terminal Integration Workflow Source: https://context7_llms This example illustrates a terminal integration workflow where a user requests Cline to set up a Docker development environment for a Node.js application. Cline outlines the steps, including creating Dockerfile, docker-compose.yml, and .dockerignore, followed by build and run commands, and verification. ```plaintext You: "Setup Docker development environment for this Node.js app" Cline: "I'll help set up Docker. I'll need to: 1. Create Dockerfile 2. Create docker-compose.yml 3. Add .dockerignore 4. Test the build Shall I proceed?" You: "Yes" Cline executes: 1. Creates Dockerfile with Node.js 18 2. Creates docker-compose.yml with app + postgres 3. Adds .dockerignore 4. Runs: docker-compose build 5. Runs: docker-compose up -d 6. Runs: docker-compose ps (to verify) Result: Docker environment running ``` -------------------------------- ### Manual Claude Code Configuration (JSON) Source: https://www.npmjs.com/package/megallm Provides an example of manual configuration for Claude Code using a JSON file. This configuration sets the base URL and API key for the MegaLLM AI service and specifies approved API key characters for validation. ```json { "env": { "ANTHROPIC_BASE_URL": "https://ai.megallm.io", "ANTHROPIC_API_KEY": "your-api-key-here" }, "customApiKeyResponses": { "approved": ["last-20-chars-of-key"], "rejected": [] } } ``` -------------------------------- ### Prefill Assistant Response in Python Source: https://context7_llms Guides the assistant's response format by prefilling content. This is useful for setting the stage for the LLM's continuation, ensuring a specific structure or starting point for the generated text. It involves creating a message list with both user and assistant roles, where the assistant's content is partially provided. ```python messages = [ {"role": "user", "content": "Write a haiku about programming"}, {"role": "assistant", "content": "Here's a haiku about programming:\n\n"} # Prefill ] response = client.messages.create( model="claude-3.5-sonnet", max_tokens=50, messages=messages ) # The response will continue from the prefilled content ``` -------------------------------- ### Illustrate Clear vs. Vague Instructions for LLM Prompting in Python Source: https://context7_llms Demonstrates the difference between clear, specific instructions and vague instructions when prompting an LLM for code analysis. The 'Good' example provides a detailed task list (identify bugs, suggest improvements, rate quality) and context. The 'Less effective' example uses a general request, which is less likely to yield precise results. ```python # Good - Clear and specific messages = [{ "role": "user", "content": """Analyze this Python code: 1. Identify any bugs 2. Suggest performance improvements 3. Rate code quality (1-10) Code: ```python def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2) ```""" }] # Less effective - Vague messages = [{ "role": "user", "content": "Look at this fibonacci function and tell me about it" }] ``` -------------------------------- ### Install MegaLLM from Tarball Source: https://context7_llms Installs the MegaLLM CLI from a previously created .tgz tarball. Used for offline installations. ```bash npm install -g ./megallm-2.5.9.tgz ``` -------------------------------- ### Complete OpenCode Configuration Example (JSON) Source: https://context7_llms A comprehensive example of an OpenCode configuration file, combining provider settings for Anthropic/MegaLLM with tool configurations and autoupdate settings. It demonstrates how to specify multiple models and API options. ```json { "$schema": "https://opencode.ai/config.json", "provider": { "anthropic": { "models": { "gpt-5": { "id": "gpt-5", "name": "GPT-5 (Via MegaLLM)" }, "gpt-4": { "id": "gpt-4", "name": "GPT-4 (Via MegaLLM)" }, "claude-sonnet-4": { "id": "claude-sonnet-4", "name": "Claude Sonnet 4 (Via MegaLLM)" } }, "options": { "apiKey": "{env:MEGALLM_API_KEY}", "baseURL": "https://ai.megallm.io/v1" } } }, "autoupdate": true, "tools": { "bash": true, "edit": true, "write": true, "read": true } } ``` -------------------------------- ### Install MegaLLM Globally Source: https://github.com/Megallm/megallm-npm Installs the MegaLLM package globally on your system, allowing you to run the 'megallm' command from any directory. This method requires Node.js and npm to be installed. ```bash # Install globally npm install -g megallm # Run from anywhere megallm ```