### Install and Run llm-mux Source: https://github.com/nghyane/llm-mux/blob/main/docs/README.md This snippet demonstrates the basic installation and startup process for llm-mux using curl and the llm-mux command-line interface. It covers installation, logging into providers, starting the server, and verifying the setup. ```bash # 1. Install curl -fsSL https://raw.githubusercontent.com/nghyane/llm-mux/main/install.sh | bash # 2. Login to a provider llm-mux login antigravity # Google Gemini llm-mux login claude # Claude Pro/Max llm-mux login copilot # GitHub Copilot # 3. Start the server llm-mux # 4. Verify curl http://localhost:8317/v1/models ``` -------------------------------- ### Quick Install llm-mux Source: https://github.com/nghyane/llm-mux/blob/main/docs/installation.md Installs the llm-mux tool using a curl command to download and execute an installation script. This is the fastest way to get started. The script handles downloading the binary, verifying integrity, installing to PATH, and initializing configuration. ```bash curl -fsSL https://raw.githubusercontent.com/nghyane/llm-mux/main/install.sh | bash ``` ```powershell irm https://raw.githubusercontent.com/nghyane/llm-mux/main/install.ps1 | iex ``` -------------------------------- ### Install and Run llm-mux CLI Source: https://github.com/nghyane/llm-mux/blob/main/README.md This snippet demonstrates how to install the llm-mux command-line interface using a curl script and then log in to various LLM providers. Finally, it shows how to start the llm-mux server and test its availability. ```bash # Install curl -fsSL https://raw.githubusercontent.com/nghyane/llm-mux/main/install.sh | bash # Login to a provider llm-mux login antigravity # Google Gemini llm-mux login claude # Claude Pro/Max llm-mux login copilot # GitHub Copilot # Start server llm-mux # Test curl http://localhost:8317/v1/models ``` -------------------------------- ### llm-mux Configuration Example Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/cline.md This YAML snippet shows a sample configuration for llm-mux. It includes settings for the authentication directory and a debug flag. Ensure this configuration is placed correctly within your llm-mux setup. ```yaml auth-dir: "~/.config/llm-mux/auth" debug: true ``` -------------------------------- ### Apply Patch Command Example Source: https://github.com/nghyane/llm-mux/blob/main/internal/misc/gpt_5_instructions.txt Demonstrates how to invoke the 'apply_patch' command with a sample patch string. This is a shell command example showing the structure of a basic patch operation. ```shell shell {"command":["apply_patch","*** Begin Patch\n*** Add File: hello.txt\n+Hello, world!\n*** End Patch\n"]} ``` -------------------------------- ### Install llm-mux with Options Source: https://github.com/nghyane/llm-mux/blob/main/docs/installation.md Provides options for customizing the llm-mux installation process. These include installing only the binary without a background service, specifying a version, setting a custom installation directory, skipping checksum verification, or forcing a reinstall. Options are passed as arguments to the installation script. ```bash # Binary only, no background service curl -fsSL .../install.sh | bash -s -- --no-service # Install specific version curl -fsSL .../install.sh | bash -s -- --version v1.2.0 # Custom install directory curl -fsSL .../install.sh | bash -s -- --dir ~/bin # Skip checksum verification curl -fsSL .../install.sh | bash -s -- --no-verify # Force reinstall curl -fsSL .../install.sh | bash -s -- --force ``` ```powershell # Binary only, no scheduled task & { $NoService = $true; irm .../install.ps1 | iex } # Specific version & { $Version = "v1.2.0"; irm .../install.ps1 | iex } # Custom directory & { $InstallPath = "C:\tools\llm-mux"; irm .../install.ps1 | iex } ``` -------------------------------- ### Verify llm-mux Installation Source: https://github.com/nghyane/llm-mux/blob/main/docs/installation.md Commands to verify that llm-mux has been installed correctly and is functioning. This includes checking the version, initializing the configuration if needed, starting the server, and testing the API endpoint with curl. ```bash # Check version (prints on startup) llm-mux # Initialize (if not done by installer) llm-mux init # Start server llm-mux # Test API (in another terminal) curl http://localhost:8317/v1/models ``` -------------------------------- ### Gemini CLI Setup (Bash) Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/README.md Environment variables setup for the Gemini CLI to connect to llm-mux. It exports the GOOGLE_GEMINI_BASE_URL. ```bash export GOOGLE_GEMINI_BASE_URL=http://localhost:8317 gemini ``` -------------------------------- ### Build llm-mux from Source Source: https://github.com/nghyane/llm-mux/blob/main/docs/installation.md Builds the llm-mux executable from its source code using Go. This method requires Git and Go 1.21+ to be installed. It involves cloning the repository, navigating to the directory, building the binary, and then initializing the application. ```bash git clone https://github.com/nghyane/llm-mux.git cd llm-mux go build -o llm-mux ./cmd/server/ ./llm-mux init ``` -------------------------------- ### Install llm-mux Source: https://context7.com/nghyane/llm-mux/llms.txt Installs llm-mux using a quick script for macOS/Linux and PowerShell for Windows. It also provides instructions to build from source using Go. ```bash # macOS / Linux curl -fsSL https://raw.githubusercontent.com/nghyane/llm-mux/main/install.sh | bash # Windows (PowerShell) irm https://raw.githubusercontent.com/nghyane/llm-mux/main/install.ps1 | iex # Build from source git clone https://github.com/nghyane/llm-mux.git cd llm-mux go build -o llm-mux ./cmd/server/ ./llm-mux init ``` -------------------------------- ### Python Example for llm-mux OpenAI API Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/cline.md This Python code demonstrates how to interact with the llm-mux API, which is compatible with the OpenAI API. It initializes an OpenAI client pointing to the llm-mux local server and makes a chat completion request. Ensure llm-mux is running and configured. ```python from openai import OpenAI client = OpenAI( base_url="http://localhost:8317/v1", api_key="unused" ) response = client.chat.completions.create( model="x-ai/grok-code-fast-1", # or minimax/minimax-m2 messages=[{"role": "user", "content": "Hello!"}] ) ``` -------------------------------- ### Quick Start Docker Deployment Source: https://context7.com/nghyane/llm-mux/llms.txt This bash script demonstrates a quick start for deploying llm-mux using Docker. It creates necessary directories, runs the container in detached mode, maps ports, and mounts configuration and authentication volumes. ```bash mkdir -p auth docker run -d \ --name llm-mux \ -p 8317:8317 \ -v ./config.yaml:/llm-mux/config.yaml \ -v ./auth:/llm-mux/auth \ nghyane/llm-mux:latest \ ./llm-mux serve --config /llm-mux/config.yaml ``` -------------------------------- ### Install llm-mux with custom directory Source: https://github.com/nghyane/llm-mux/blob/main/docs/troubleshooting.md This command downloads and executes an installation script for llm-mux, directing the installation to the specified directory (~/.local/bin). It's used when facing permission issues during a standard installation. ```bash curl -fsSL .../install.sh | bash -s -- --dir ~/.local/bin ``` -------------------------------- ### Docker Compose Setup for llm-mux Source: https://context7.com/nghyane/llm-mux/llms.txt This snippet shows how to configure and run llm-mux using Docker Compose. It defines the container image, ports, volumes for configuration and authentication, environment variables, and a health check. The `docker compose up -d` command starts the service, and subsequent commands handle authentication token copying and service restart. ```yaml # image: nghyane/llm-mux:latest # container_name: llm-mux # command: ["./llm-mux", "serve", "--config", "/llm-mux/config.yaml"] # ports: # - "8317:8317" # volumes: # - ./config.yaml:/llm-mux/config.yaml # - ./auth:/llm-mux/auth # environment: # - TZ=UTC # - LLM_MUX_MANAGEMENT_KEY=your-secret-key # - LLM_MUX_ALLOW_REMOTE=true # restart: unless-stopped # healthcheck: # test: ["CMD", "wget", "-q", "--spider", "http://localhost:8317/v1/models"] # interval: 30s # timeout: 10s # retries: 3 docker compose up -d # Copy OAuth tokens from host to Docker llm-mux login antigravity cp -r ~/.config/llm-mux/auth/* ./auth/ docker compose restart ``` -------------------------------- ### cURL Example to List Models in llm-mux Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/cline.md This cURL command demonstrates how to retrieve a list of available models from the llm-mux API. It sends a GET request to the /v1/models endpoint. ```bash curl http://localhost:8317/v1/models ``` -------------------------------- ### Codex CLI Setup (Bash) Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/README.md Environment variables setup for the Codex CLI to connect to llm-mux. It exports the OPENAI_BASE_URL and OPENAI_API_KEY. ```bash export OPENAI_BASE_URL=http://localhost:8317/v1 export OPENAI_API_KEY=unused codex ``` -------------------------------- ### Open WebUI Docker Setup Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/README.md Docker command to run Open WebUI and connect it to llm-mux. It maps the host's port and sets environment variables for the OpenAI API base URL and key. ```bash docker run -d \ -p 3000:8080 \ -e OPENAI_API_BASE_URL=http://host.docker.internal:8317/v1 \ -e OPENAI_API_KEY=unused \ ghcr.io/open-webui/open-webui:main ``` -------------------------------- ### Stream Content with Gemini API Source: https://context7.com/nghyane/llm-mux/llms.txt This example shows how to stream content using the Gemini API. It targets the `streamGenerateContent` endpoint and provides the text to be streamed. This is useful for real-time responses where the output can be processed as it arrives. ```bash curl "http://localhost:8317/v1beta/models/gemini-2.5-flash:streamGenerateContent" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [{"text": "Write a short story about a robot."}] }] }' ``` -------------------------------- ### Start LLM Mux with Docker Compose Source: https://github.com/nghyane/llm-mux/blob/main/docs/docker.md This command starts the services defined in the docker-compose.yaml file in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Manually Set Up Linux llm-mux Service Source: https://github.com/nghyane/llm-mux/blob/main/docs/service-management.md Instructions and code to manually set up the llm-mux service on Linux using systemd. This involves creating the systemd service file and then enabling and starting it. ```bash mkdir -p ~/.config/systemd/user cat > ~/.config/systemd/user/llm-mux.service << 'EOF' [Unit] Description=llm-mux After=network-online.target [Service] ExecStart=%h/.local/bin/llm-mux Restart=on-failure [Install] WantedBy=default.target EOF systemctl --user daemon-reload && systemctl --user enable --now llm-mux ``` -------------------------------- ### Claude Code CLI Setup (Bash) Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/README.md Environment variables setup for the Claude Code CLI to connect to llm-mux. It exports the ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY. ```bash export ANTHROPIC_BASE_URL=http://localhost:8317 export ANTHROPIC_API_KEY=unused claude ``` -------------------------------- ### Authenticate with llm-mux Providers Source: https://github.com/nghyane/llm-mux/blob/main/docs/troubleshooting.md These commands log in to various LLM providers using llm-mux. The first example logs into 'antigravity', and subsequent examples show logging into 'claude' or 'copilot'. It also includes a command to verify available models via the API. ```bash llm-mux login antigravity # or: login claude, login copilot curl http://localhost:8317/v1/models ``` -------------------------------- ### llm-mux Configuration File Example Source: https://context7.com/nghyane/llm-mux/llms.txt This YAML snippet shows a sample configuration file for llm-mux. It covers settings for port, authentication, request handling, external API providers (Gemini, Anthropic, OpenAI, Vertex-compat), model routing, usage statistics, and TLS configuration. ```yaml # ~/.config/llm-mux/config.yaml port: 8317 auth-dir: "~/.config/llm-mux/auth" disable-auth: true debug: false logging-to-file: false proxy-url: "" # Request handling request-retry: 3 max-retry-interval: 30 stream-timeout: 300 disable-cooling: false quota-window: 60 # Quota behavior quota-exceeded: switch-project: true switch-preview-model: true # External API providers (in addition to OAuth providers) providers: - type: gemini api-key: "AIzaSy..." - type: anthropic api-key: "sk-ant-..." - type: openai name: "deepseek" base-url: "https://api.deepseek.com/v1" api-key: "sk-..." models: - name: "deepseek-chat" alias: "deepseek" - type: vertex-compat name: "custom-provider" base-url: "https://api.example.com" api-key: "vk-..." models: - name: "custom-model" # Model routing and fallbacks routing: provider-priority: claude: 1 antigravity: 2 gemini-cli: 3 github-copilot: 4 aliases: "claude-sonnet-4.5": "claude-sonnet-4-5" "gpt-4": "gpt-4o" fallbacks: "claude-opus-4-5": - "claude-sonnet-4-5" - "gpt-4o" # Usage statistics usage: dsn: "sqlite://~/.config/llm-mux/usage.db" batch-size: 100 flush-interval: "5s" retention-days: 30 # TLS configuration tls: enable: false cert: "/path/to/cert.pem" key: "/path/to/key.pem" ``` -------------------------------- ### llm-mux Provider Configuration with Multiple API Keys (YAML) Source: https://github.com/nghyane/llm-mux/blob/main/docs/configuration.md Example of configuring a provider with multiple API keys, allowing for load balancing or failover, and specifying per-key proxy settings. ```yaml - type: gemini api-keys: - key: "AIzaSy...01" - key: "AIzaSy...02" proxy-url: "socks5://proxy2:1080" ``` -------------------------------- ### OpenAI Chat Completions API Requests with llm-mux Source: https://context7.com/nghyane/llm-mux/llms.txt Demonstrates sending chat completion requests to the OpenAI-compatible endpoint of llm-mux. Includes examples for basic completion, streaming responses, forcing specific providers, and utilizing tool/function calling. ```bash # Basic chat completion curl http://localhost:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-2.5-pro", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain quantum computing in simple terms."} ], "temperature": 0.7, "max_tokens": 1024 }' # Streaming response curl http://localhost:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-20250514", "messages": [{"role": "user", "content": "Write a haiku about programming"}], "stream": true }' # Force specific provider using prefix curl http://localhost:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gemini://gemini-2.5-pro", "messages": [{"role": "user", "content": "Hello!"}] }' # Tool/function calling curl http://localhost:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o", "messages": [{"role": "user", "content": "What is the weather in Tokyo?"}], "tools": [{ "type": "function", "function": { "name": "get_weather", "description": "Get weather for a location", "parameters": { "type": "object", "properties": { "location": {"type": "string", "description": "City name"} }, "required": ["location"] } } }] }' ``` -------------------------------- ### Ollama API Generate Endpoint Source: https://context7.com/nghyane/llm-mux/llms.txt This example shows how to use the Ollama-compatible generate endpoint for non-chat based text generation. It requires specifying the model and providing a prompt. This is useful for tasks like summarization or question answering. ```bash curl http://localhost:8317/api/generate \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4", "prompt": "Why is the sky blue?" }' ``` -------------------------------- ### Start OAuth Flow Programmatically Source: https://context7.com/nghyane/llm-mux/llms.txt This POST request initiates an OAuth flow for a specified provider programmatically. It requires the management key and sends a JSON payload with the provider name to the `/v1/management/oauth/start` endpoint. ```bash curl -X POST http://localhost:8317/v1/management/oauth/start \ -H "X-Management-Key: $LLM_MUX_MANAGEMENT_KEY" \ -H "Content-Type: application/json" \ -d '{"provider": "claude"}' ``` -------------------------------- ### Accessing Management Configuration Locally with cURL Source: https://github.com/nghyane/llm-mux/blob/main/docs/api-reference.md This example shows how to access the LLM Mux management configuration endpoint when running locally. It requires the management key to be passed in the `X-Management-Key` header. This allows for secure configuration changes. ```bash curl -H "X-Management-Key: $KEY" http://localhost:8317/v1/management/config ``` -------------------------------- ### Making Chat Completions with cURL (OpenAI Compatible) Source: https://github.com/nghyane/llm-mux/blob/main/docs/api-reference.md This example demonstrates how to make a chat completion request using the OpenAI compatible endpoint of LLM Mux. It requires specifying the model and the user's message in the request body. The base URL and authentication method are also provided. ```bash curl http://localhost:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{"model": "gemini-2.5-pro", "messages": [{"role": "user", "content": "Hello!"}]}' ``` -------------------------------- ### Enable llm-mux Service on Linux Boot Source: https://github.com/nghyane/llm-mux/blob/main/docs/troubleshooting.md These commands enable the llm-mux service to start automatically on boot for the current user on Linux systems using systemd. `loginctl enable-linger` ensures user services persist after logout. ```bash loginctl enable-linger $(whoami) systemctl --user enable llm-mux ``` -------------------------------- ### Common LLM Mux Docker Commands Source: https://github.com/nghyane/llm-mux/blob/main/docs/docker.md A collection of frequently used Docker commands for managing the LLM Mux service, including starting, stopping, updating, viewing logs, and accessing the container's shell. ```bash docker compose up -d # Start docker compose down # Stop docker compose pull && docker compose up -d # Update docker logs -f llm-mux # Logs docker exec -it llm-mux sh # Shell ``` -------------------------------- ### Anthropic Messages API Requests with llm-mux Source: https://context7.com/nghyane/llm-mux/llms.txt Shows how to send requests using the Anthropic-compatible Messages API endpoint provided by llm-mux. Examples cover basic message requests, extended thinking mode for Claude, and token counting. ```bash # Basic message request curl http://localhost:8317/v1/messages \ -H "Content-Type: application/json" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "claude-sonnet-4-20250514", "max_tokens": 1024, "messages": [ {"role": "user", "content": "Explain the difference between TCP and UDP."} ] }' # Extended thinking mode (Claude-specific) curl http://localhost:8317/v1/messages \ -H "Content-Type: application/json" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "claude-opus-4-5-20251101", "max_tokens": 16000, "messages": [{"role": "user", "content": "Solve this complex math problem..."}], "thinking": { "type": "enabled", "budget_tokens": 10000 } }' # Token counting curl http://localhost:8317/v1/messages/count_tokens \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-20250514", "messages": [{"role": "user", "content": "Count my tokens please."}] }' ``` -------------------------------- ### LLM Mux Authentication Options Source: https://github.com/nghyane/llm-mux/blob/main/docs/docker.md Demonstrates different authentication methods for LLM Mux. Option 1 involves logging in on the host and copying tokens. Option 2 configures API keys directly. Option 3 shows how to get a management key. ```bash llm-mux login antigravity # Login on host mkdir -p auth cp -r ~/.config/llm-mux/auth/* ./auth/ ``` ```yaml providers: - type: openai name: "openai" base-url: "https://api.openai.com/v1" api-key: "sk-..." models: - name: "gpt-4o" ``` ```bash docker exec llm-mux ./llm-mux init ``` -------------------------------- ### Vercel AI SDK Integration (TypeScript) Source: https://context7.com/nghyane/llm-mux/llms.txt Illustrates integrating llm-mux with the Vercel AI SDK in TypeScript. It uses the `generateText` function with a configured `openai` provider pointing to the llm-mux instance. The example generates text for a given prompt and logs the result. ```typescript // Vercel AI SDK (TypeScript) import { openai } from '@ai-sdk/openai'; import { generateText } from 'ai'; const result = await generateText({ model: openai('gemini-2.5-pro', { baseURL: 'http://localhost:8317/v1', }), prompt: 'Write a function to reverse a string', }); console.log(result.text); ``` -------------------------------- ### Authenticate LLM Providers with llm-mux Source: https://context7.com/nghyane/llm-mux/llms.txt Authenticates with various subscription-based LLM providers using OAuth. Tokens are stored locally. Includes commands to log in to Gemini, Claude, Copilot, Codex, Qwen, Kiro, Cline, and iFlow, followed by starting the server and verifying models. ```bash # Google Gemini (Google One AI Premium) llm-mux login antigravity # Claude Pro/Max subscription llm-mux login claude # GitHub Copilot subscription llm-mux login copilot # OpenAI Codex (ChatGPT Plus/Pro) llm-mux login codex # Alibaba Qwen llm-mux login qwen # Amazon Kiro (Q Developer) llm-mux login kiro # Cline subscription llm-mux login cline # iFlow integration llm-mux login iflow # Start the server after login llm-mux # Verify available models curl http://localhost:8317/v1/models ``` -------------------------------- ### cURL Example for llm-mux Chat Completions Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/cline.md This cURL command shows how to make a chat completion request to the llm-mux API. It sends a POST request to the /v1/chat/completions endpoint with the model and message content. The API is accessible at http://localhost:8317. ```bash curl http://localhost:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{"model":"x-ai/grok-code-fast-1","messages":[{"role":"user","content":"Hello!"}]}' ``` -------------------------------- ### Apply Patch Tool Usage Source: https://github.com/nghyane/llm-mux/blob/main/internal/misc/gpt_5_instructions.txt Demonstrates the correct usage of the `apply_patch` tool for modifying files. It highlights the expected JSON structure for the command, including the patch details with file path and @@ hunks for changes. ```json { "command": [ "apply_patch", "*** Begin Patch\\n*** Update File: path/to/file.py\\n@@ def example():\\n- pass\\n+ return 123\\n*** End Patch" ] } ``` -------------------------------- ### Initialize llm-mux Configuration Source: https://github.com/nghyane/llm-mux/blob/main/docs/troubleshooting.md This command initializes the llm-mux configuration, which is necessary if the configuration files are missing or corrupted. ```bash llm-mux init ``` -------------------------------- ### Self-Update llm-mux Source: https://github.com/nghyane/llm-mux/blob/main/docs/installation.md Updates the llm-mux tool to the latest available version. This command checks GitHub for new releases and automatically downloads and installs the newer version if one is found. It simplifies keeping the tool up-to-date. ```bash llm-mux update ``` -------------------------------- ### Go Programmatic Usage for Cline Authentication Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/cline.md This Go code snippet illustrates how to programmatically manage Cline authentication tokens using the llm-mux internal library. It shows creating a Cline authentication service, refreshing tokens, and creating token storage. Ensure the necessary configuration and context are provided. ```go import "github.com/nghyane/llm-mux/internal/auth/cline" authSvc := cline.NewClineAuth(cfg) tokenData, err := authSvc.RefreshTokens(ctx, refreshToken) storage := authSvc.CreateTokenStorage(tokenData) ``` -------------------------------- ### Manually Set Up macOS llm-mux Service Source: https://github.com/nghyane/llm-mux/blob/main/docs/service-management.md Instructions and code to manually set up the llm-mux service on macOS using launchd. This involves creating the necessary directories and the launchd plist file, then loading it. ```bash mkdir -p ~/Library/LaunchAgents ~/.local/var/log cat > ~/Library/LaunchAgents/com.llm-mux.plist << 'EOF' Labelcom.llm-mux ProgramArguments/usr/local/bin/llm-mux RunAtLoad KeepAliveSuccessfulExit StandardOutPath~/.local/var/log/llm-mux.log StandardErrorPath~/.local/var/log/llm-mux.log EOF launchctl load ~/Library/LaunchAgents/com.llm-mux.plist ``` -------------------------------- ### List Available Gemini Models Source: https://context7.com/nghyane/llm-mux/llms.txt This command retrieves a list of all available models that can be used with the Gemini API. It sends a GET request to the `/v1beta/models` endpoint. ```bash curl http://localhost:8317/v1beta/models ``` -------------------------------- ### Specifying Model Names and Providers with cURL Source: https://github.com/nghyane/llm-mux/blob/main/docs/api-reference.md This example demonstrates how to specify a model directly or by forcing a specific provider using LLM Mux. By prefixing the model name with the provider (e.g., "gemini://" or "claude://"), you can ensure the request is routed to the intended LLM service. ```bash # Direct name "model": "gemini-2.5-pro" # Force provider "model": "gemini://gemini-2.5-pro" "model": "claude://claude-sonnet-4-20250514" ``` -------------------------------- ### Restart llm-mux Service on macOS Source: https://github.com/nghyane/llm-mux/blob/main/docs/troubleshooting.md These commands are used on macOS to stop and then start the llm-mux background service managed by `launchd`. This is typically done to apply configuration changes or resolve service issues. ```bash launchctl unload ~/Library/LaunchAgents/com.llm-mux.plist launchctl load ~/Library/LaunchAgents/com.llm-mux.plist ``` -------------------------------- ### Verify Aider Connection to llm-mux (Bash & cURL) Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/aider.md Provides commands to verify the connection between Aider and llm-mux. It includes checking available models via the llm-mux API and starting Aider. ```bash # Check available models curl http://localhost:8317/v1/models # Start aider aider --model gemini-2.5-pro ``` -------------------------------- ### Get Current llm-mux Configuration Source: https://context7.com/nghyane/llm-mux/llms.txt This curl command retrieves the current runtime configuration of llm-mux. It requires the `X-Management-Key` header for authentication and targets the `/v1/management/config` endpoint. ```bash curl -H "X-Management-Key: $LLM_MUX_MANAGEMENT_KEY" \ http://localhost:8317/v1/management/config ``` -------------------------------- ### Build LLM Mux Docker Image from Source Source: https://github.com/nghyane/llm-mux/blob/main/docs/docker.md Provides commands to build the LLM Mux Docker image locally. It includes a helper script for macOS/Linux and Windows, and a manual build process using `docker build`. ```bash ./scripts/docker-build.sh # macOS/Linux ./scripts/docker-build.ps1 # Windows ``` ```bash git clone https://github.com/nghyane/llm-mux.git && cd llm-mux docker build -t llm-mux:local . ``` -------------------------------- ### Generate Content with Gemini API Source: https://context7.com/nghyane/llm-mux/llms.txt This snippet demonstrates how to generate content using the Gemini API via a curl command. It specifies the model, provides the text for generation, and includes generation configuration like temperature and max output tokens. The request is sent to the `generateContent` endpoint. ```bash curl "http://localhost:8317/v1beta/models/gemini-2.5-pro:generateContent" \ -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [{"text": "Explain machine learning in one paragraph."}] }], "generationConfig": { "temperature": 0.7, "maxOutputTokens": 1024 } }' ``` -------------------------------- ### Manage macOS llm-mux Service with launchd Source: https://github.com/nghyane/llm-mux/blob/main/docs/service-management.md Commands to manage the llm-mux background service on macOS using launchd. This includes starting, stopping, checking the status, viewing logs, and enabling/disabling auto-start. ```bash launchctl start com.llm-mux launchctl stop com.llm-mux launchctl list | grep llm-mux tail -f ~/.local/var/log/llm-mux.log launchctl load ~/Library/LaunchAgents/com.llm-mux.plist launchctl unload ~/Library/LaunchAgents/com.llm-mux.plist ``` -------------------------------- ### Uninstall llm-mux on macOS Source: https://github.com/nghyane/llm-mux/blob/main/docs/installation.md Removes the llm-mux tool and its associated background service from a macOS system. This involves stopping and removing the launch agent, deleting the binary, and optionally removing configuration and credential files. ```bash # Stop and remove service launchctl bootout gui/$(id -u)/com.llm-mux 2>/dev/null rm ~/Library/LaunchAgents/com.llm-mux.plist # Remove binary rm /usr/local/bin/llm-mux # Remove config and credentials (optional) rm -rf ~/.config/llm-mux ``` -------------------------------- ### Manage llm-mux Background Task on Windows Source: https://github.com/nghyane/llm-mux/blob/main/docs/troubleshooting.md These PowerShell commands are used on Windows to check the status of the 'llm-mux Background Service' scheduled task and to start it if it's not running. This is essential for ensuring the service operates correctly. ```powershell Get-ScheduledTaskInfo -TaskName "llm-mux Background Service" Start-ScheduledTask -TaskName "llm-mux Background Service" ``` -------------------------------- ### Configure Aider with a YAML Config File Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/aider.md Sets up Aider by defining the OpenAI API base, API key, and model in a YAML configuration file located at ~/.aider.conf.yml. This provides persistent configuration. ```yaml openai-api-base: http://localhost:8317/v1 openai-api-key: unused model: gemini-2.5-pro ``` -------------------------------- ### Configure Aider with Command Line Flags (Bash) Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/aider.md Configures Aider using command-line flags for the OpenAI API base URL, API key, and the desired model. This method is useful for one-off configurations or scripting. ```bash aider --openai-api-base http://localhost:8317/v1 \ --openai-api-key unused \ --model gemini-2.5-pro ``` -------------------------------- ### Get Usage Statistics from llm-mux Source: https://context7.com/nghyane/llm-mux/llms.txt This command retrieves usage statistics for llm-mux, optionally filtered by the number of days. It requires the management key for authentication and queries the `/v1/management/usage` endpoint. ```bash curl -H "X-Management-Key: $LLM_MUX_MANAGEMENT_KEY" \ "http://localhost:8317/v1/management/usage?days=7" ``` -------------------------------- ### List Available Models (Tags) via Ollama API Source: https://context7.com/nghyane/llm-mux/llms.txt This command lists the available model tags accessible through the Ollama-compatible API. It sends a GET request to the `/api/tags` endpoint. ```bash curl http://localhost:8317/api/tags ``` -------------------------------- ### Select Aider Models (Bash) Source: https://github.com/nghyane/llm-mux/blob/main/docs/integrations/aider.md Demonstrates how to select different language models with Aider, including Gemini, Claude (via llm-mux), and GPT via Copilot, using the --model flag. ```bash # Gemini aider --model gemini-2.5-pro # Claude (via llm-mux) aider --model claude-sonnet-4 # GPT via Copilot aider --model gpt-4o ```