switchAILocal

module
v0.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0

README

switchAILocal Logo

switchAILocal

One local endpoint. All your AI providers.

Documentation • Quick Start • Installation • Configuration • API Reference


What is switchAILocal?

switchAILocal is a gateway you run on your own machine. It exposes one OpenAI-compatible API (plus Claude- and Gemini-compatible routes) and forwards each request to the provider you choose: CLI tools you are already logged in to, local model servers, or cloud API keys.

  • Use your existing subscriptions. Installed and logged-in gemini, claude, codex and vibe CLIs are detected at startup and become providers.
  • Local models. Ollama and LM Studio, plus an OpenCode server.
  • Cloud APIs. Gemini, Anthropic, OpenAI, and any OpenAI-compatible service (Groq, OpenRouter, DeepSeek, ...) through openai-compatibility.
  • One client config. Point any OpenAI SDK or tool at http://localhost:18080/v1.
  • Routing. provider:model prefixes, model aliases, virtual models, round-robin across credentials, circuit breakers and failover.
  • Operations. Web management panel, management API, Prometheus metrics, JSON logs and per-request NDJSON events.

Supported providers

Kind Provider Prefix How it connects
CLI Google Gemini CLI geminicli: gemini on your PATH
CLI Anthropic Claude Code claudecli: claude on your PATH
CLI OpenAI Codex codex: codex on your PATH
CLI Mistral Vibe vibecli: vibe on your PATH
Local Ollama ollama: ollama: block in config.yaml
Local LM Studio lmstudio: lmstudio: block in config.yaml
Local OpenCode server opencode: opencode: block in config.yaml
Cloud Google AI Studio gemini: gemini-api-key
Cloud Anthropic API claude: claude-api-key
Cloud OpenAI API codex: codex-api-key
Cloud Traylinx switchAI switchai: switchai-api-key
Cloud Any OpenAI-compatible API your prefix openai-compatibility

Details: Providers.

Requirements

Platform Prebuilt binary Docker image
macOS, Apple Silicon yes (darwin_arm64) yes
macOS, Intel no, build from source yes
Linux x86_64 / arm64 yes (linux_amd64, linux_arm64) yes
Windows no yes (or WSL)

Building from source needs Go 1.26.10+ with CGO enabled (a C compiler).

Quick start

1. Get the binary

Release archive (macOS Apple Silicon, Linux):

VERSION=0.6.2
OS=darwin ARCH=arm64          # or: OS=linux ARCH=amd64 / ARCH=arm64
curl -LO https://github.com/traylinx/switchAILocal/releases/download/v${VERSION}/switchAILocal_${VERSION}_${OS}_${ARCH}.tar.gz
tar xzf switchAILocal_${VERSION}_${OS}_${ARCH}.tar.gz
cd switchAILocal_${VERSION}_${OS}_${ARCH}

Docker: see Docker deployment.

From source:

git clone https://github.com/traylinx/switchAILocal.git
cd switchAILocal
./ail.sh setup      # builds binaries, creates config.yaml, installs the `ail` helper

The npx @traylinx/switchailocal launcher cannot unpack the current release archives. Use the release archive or Docker until it is fixed. See Installation.

2. Create config.yaml

The server reads config.yaml from the directory you start it in and refuses to start without one.

cat > config.yaml <<'EOF'
host: "127.0.0.1"
port: 18080
auth-dir: "~/.switchailocal"
api-keys:
  - "sk-your-key"        # clients send: Authorization: Bearer sk-your-key
EOF
chmod 600 config.yaml

config.example.yaml (in the archive and the repository) documents every section but enables providers and keys you probably do not have; start small.

3. Start the server

./switchAILocal          # or: ail start   (after ./ail.sh setup)

Check it:

curl http://localhost:18080/health
# {"status":"ok"}

4. Make a request

If a supported CLI is installed and logged in, it already works:

curl http://localhost:18080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-key" \
  -d '{"model": "geminicli:gemini-2.5-pro",
       "messages": [{"role": "user", "content": "Hello!"}]}'

List what is available with GET /v1/models. Without a prefix, the gateway picks any provider that serves the requested model name.

Connect providers

CLI tools. Install and log in to the CLI once (gemini, claude, codex, vibe). switchAILocal finds them on PATH at startup. No config needed.

API keys. Add a list entry per key:

gemini-api-key:
  - api-key: "your-gemini-key"
claude-api-key:
  - api-key: "sk-ant-your-key"
codex-api-key:
  - api-key: "sk-your-openai-key"
    base-url: "https://api.openai.com/v1"   # required for codex-api-key

Local models.

ollama:
  enabled: true
  base-url: "http://localhost:11434"
  auto-discover: true

OAuth logins (--login, --claude-login, --codex-login, ...) store tokens under auth-dir. See Login commands.

Use it from an SDK

from openai import OpenAI

client = OpenAI(base_url="http://localhost:18080/v1", api_key="sk-your-key")
reply = client.chat.completions.create(
    model="ollama:llama3.2",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)

Streaming, tools, vision, embeddings, images, audio and music endpoints are covered in the API reference.

Management panel

The server serves a web panel at http://localhost:18080/management for providers, model mappings and settings (bundled in the Docker image and source checkouts; release-archive users download one file). With no remote-management.secret-key, any local process can use the management API, so set one on shared machines. See Management dashboard.

Documentation

Topic Link
Installation (archive, Docker, source, ail.sh) installation
Server command, flags and environment variables cli/server
Configuration reference configuration/reference
Providers configuration/providers
Security configuration/security
Docker guides/docker-deployment
Managed Linux servers (channel updates, rollback) guides/managed-server
Troubleshooting guides/troubleshooting

Contributing

Contributions are welcome. See CONTRIBUTING.md.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes
  4. Push and open a pull request

License

MIT. See LICENSE.


Maintained by Sebastian Schkudlara

Directories

Path Synopsis
cmd
bridge-agent command
server command
Package main provides the entry point for the switchAILocal server.
Package main provides the entry point for the switchAILocal server.
examples
advanced command
Package main demonstrates how to create a custom AI provider executor and integrate it with the switchAILocal server.
Package main demonstrates how to create a custom AI provider executor and integrate it with the switchAILocal server.
internal
api
Package api provides the HTTP API server implementation for the switchAILocal.
Package api provides the HTTP API server implementation for the switchAILocal.
api/handlers/management
Package management provides the management API handlers and middleware for configuring the server and managing auth files.
Package management provides the management API handlers and middleware for configuring the server and managing auth files.
api/middleware
Package middleware provides HTTP middleware components for the switchAILocal server.
Package middleware provides HTTP middleware components for the switchAILocal server.
api/modules
Package modules provides a pluggable routing module system for extending the API server with optional features without modifying core routing logic.
Package modules provides a pluggable routing module system for extending the API server with optional features without modifying core routing logic.
api/modules/amp
Package amp implements the Amp CLI routing module, providing OAuth-based integration with Amp CLI for ChatGPT and Anthropic subscriptions.
Package amp implements the Amp CLI routing module, providing OAuth-based integration with Amp CLI for ChatGPT and Anthropic subscriptions.
auth
Package auth provides authentication functionality for various AI service providers.
Package auth provides authentication functionality for various AI service providers.
auth/claude
Package claude provides OAuth2 authentication functionality for Anthropic's Claude API.
Package claude provides OAuth2 authentication functionality for Anthropic's Claude API.
auth/codex
Package codex provides authentication and token management for OpenAI's Codex API.
Package codex provides authentication and token management for OpenAI's Codex API.
auth/credentialfile
Package credentialfile provides the single private, atomic persistence path for legacy provider credential serializers.
Package credentialfile provides the single private, atomic persistence path for legacy provider credential serializers.
auth/empty
Package empty provides a no-operation token storage implementation.
Package empty provides a no-operation token storage implementation.
auth/gemini
Package gemini provides authentication and token management functionality for Google's Gemini AI services.
Package gemini provides authentication and token management functionality for Google's Gemini AI services.
auth/qwen
Package qwen provides authentication and token management functionality for Alibaba's Qwen AI services.
Package qwen provides authentication and token management functionality for Alibaba's Qwen AI services.
auth/vertex
Package vertex provides token storage for Google Vertex AI Gemini via service account credentials.
Package vertex provides token storage for Google Vertex AI Gemini via service account credentials.
authid
Package authid defines the canonical identifier and containment contract for auth files managed by switchAILocal stores.
Package authid defines the canonical identifier and containment contract for auth files managed by switchAILocal stores.
browser
Package browser provides cross-platform functionality for opening URLs in the default web browser.
Package browser provides cross-platform functionality for opening URLs in the default web browser.
buildinfo
Package buildinfo exposes compile-time metadata shared across the server.
Package buildinfo exposes compile-time metadata shared across the server.
cli
cmd
Package cmd provides command-line interface functionality for the switchAILocal server.
Package cmd provides command-line interface functionality for the switchAILocal server.
config
Package config provides configuration management for the switchAILocal server.
Package config provides configuration management for the switchAILocal server.
constant
Package constant defines provider name constants used throughout the switchAILocal.
Package constant defines provider name constants used throughout the switchAILocal.
discovery
Package discovery provides model discovery interfaces and implementations.
Package discovery provides model discovery interfaces and implementations.
failover
Package failover classifies upstream-provider errors into a small, well-defined taxonomy that the cross-provider retry loop dispatches on.
Package failover classifies upstream-provider errors into a small, well-defined taxonomy that the cross-provider retry loop dispatches on.
heartbeat
Package heartbeat provides proactive background monitoring for provider health.
Package heartbeat provides proactive background monitoring for provider health.
integration
Package integration provides coordination and lifecycle management for intelligent systems.
Package integration provides coordination and lifecycle management for intelligent systems.
intelligence
Package intelligence provides the Cortex Router for intelligent request routing.
Package intelligence provides the Cortex Router for intelligent request routing.
intelligence/cache
Package cache provides semantic caching for routing decisions.
Package cache provides semantic caching for routing decisions.
intelligence/capability
Package capability provides model capability analysis for the intelligence system.
Package capability provides model capability analysis for the intelligence system.
intelligence/cascade
Package cascade provides model cascading functionality for intelligent routing.
Package cascade provides model cascading functionality for intelligent routing.
intelligence/discovery
Package discovery provides model discovery services for the intelligence system.
Package discovery provides model discovery services for the intelligence system.
intelligence/embedding
Package embedding provides an ONNX-based embedding engine for semantic matching.
Package embedding provides an ONNX-based embedding engine for semantic matching.
intelligence/feedback
Package feedback provides feedback collection and storage for routing decisions.
Package feedback provides feedback collection and storage for routing decisions.
intelligence/matrix
Package matrix provides dynamic capability matrix building for the intelligence system.
Package matrix provides dynamic capability matrix building for the intelligence system.
intelligence/semantic
Package semantic provides semantic intent matching for Phase 2 intelligent routing.
Package semantic provides semantic intent matching for Phase 2 intelligent routing.
intelligence/skills
Package skills provides an enhanced skill registry for Phase 2 intelligent routing.
Package skills provides an enhanced skill registry for Phase 2 intelligent routing.
interfaces
Package interfaces defines the core interfaces and shared structures for the switchAILocal server.
Package interfaces defines the core interfaces and shared structures for the switchAILocal server.
logging
Package logging provides Gin middleware for HTTP request logging and panic recovery.
Package logging provides Gin middleware for HTTP request logging and panic recovery.
memory
Package memory provides persistent storage for routing decisions, provider quirks, and user preferences.
Package memory provides persistent storage for routing decisions, provider quirks, and user preferences.
misc
Package misc provides miscellaneous utility functions and embedded data for the switchAILocal.
Package misc provides miscellaneous utility functions and embedded data for the switchAILocal.
observability
Package observability provides structured event logging, metrics, and tracing for integrating switchAILocal with external monitoring systems.
Package observability provides structured event logging, metrics, and tracing for integrating switchAILocal with external monitoring systems.
performance/loadshed
Package loadshed provides graceful load shedding middleware for the switchAILocal proxy.
Package loadshed provides graceful load shedding middleware for the switchAILocal proxy.
performance/ratelimit
Package ratelimit provides token-bucket rate limiting for the switchAILocal proxy.
Package ratelimit provides token-bucket rate limiting for the switchAILocal proxy.
plugin
Package plugin provides LUA-based plugin support for extending switchAILocal functionality.
Package plugin provides LUA-based plugin support for extending switchAILocal functionality.
privatefile
Package privatefile provides dependency-minimal owner-only atomic writes for sensitive artifacts used below the config/util dependency layer.
Package privatefile provides dependency-minimal owner-only atomic writes for sensitive artifacts used below the config/util dependency layer.
registry
Package registry provides model definitions for various AI service providers.
Package registry provides model definitions for various AI service providers.
runtime/executor
Package executor provides runtime execution capabilities for various AI service providers.
Package executor provides runtime execution capabilities for various AI service providers.
runtime/opencode
Package opencode provides a client for interacting with the OpenCode server API.
Package opencode provides a client for interacting with the OpenCode server API.
superbrain
Package superbrain provides intelligent orchestration and self-healing capabilities for the switchAILocal gateway.
Package superbrain provides intelligent orchestration and self-healing capabilities for the switchAILocal gateway.
superbrain/audit
Package audit provides structured logging for Superbrain autonomous actions.
Package audit provides structured logging for Superbrain autonomous actions.
superbrain/doctor
Package doctor provides AI-powered failure diagnosis for the Superbrain system.
Package doctor provides AI-powered failure diagnosis for the Superbrain system.
superbrain/injector
Package injector provides autonomous stdin injection capabilities for the Superbrain system.
Package injector provides autonomous stdin injection capabilities for the Superbrain system.
superbrain/metadata
Package metadata provides functionality for aggregating and managing healing metadata throughout the request lifecycle.
Package metadata provides functionality for aggregating and managing healing metadata throughout the request lifecycle.
superbrain/metrics
Package metrics provides observability infrastructure for the Superbrain system.
Package metrics provides observability infrastructure for the Superbrain system.
superbrain/overwatch
Package overwatch provides real-time execution monitoring capabilities for the Superbrain system.
Package overwatch provides real-time execution monitoring capabilities for the Superbrain system.
superbrain/recovery
Package recovery provides process recovery and restart capabilities for the Superbrain system.
Package recovery provides process recovery and restart capabilities for the Superbrain system.
superbrain/response
Package response provides response enrichment capabilities for the Superbrain system.
Package response provides response enrichment capabilities for the Superbrain system.
superbrain/router
Package router provides intelligent failover routing between AI providers.
Package router provides intelligent failover routing between AI providers.
superbrain/sculptor
Package sculptor provides pre-flight content analysis and optimization for the Superbrain system.
Package sculptor provides pre-flight content analysis and optimization for the Superbrain system.
superbrain/security
Package security provides security controls and fail-safes for the Superbrain system.
Package security provides security controls and fail-safes for the Superbrain system.
superbrain/types
Package types provides shared type definitions for the Superbrain system.
Package types provides shared type definitions for the Superbrain system.
translator/antigravity/claude
Package claude provides request translation functionality for Claude Code API compatibility.
Package claude provides request translation functionality for Claude Code API compatibility.
translator/antigravity/gemini
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
translator/antigravity/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
translator/claude/gemini
Package gemini provides request translation functionality for Gemini to Claude Code API compatibility.
Package gemini provides request translation functionality for Gemini to Claude Code API compatibility.
translator/claude/gemini-cli
Package geminiCLI provides request translation functionality for Gemini CLI to Claude Code API compatibility.
Package geminiCLI provides request translation functionality for Gemini CLI to Claude Code API compatibility.
translator/claude/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Claude Code API compatibility.
Package openai provides request translation functionality for OpenAI to Claude Code API compatibility.
translator/codex/claude
Package claude provides request translation functionality for Claude Code API compatibility.
Package claude provides request translation functionality for Claude Code API compatibility.
translator/codex/gemini
Package gemini provides request translation functionality for Codex to Gemini API compatibility.
Package gemini provides request translation functionality for Codex to Gemini API compatibility.
translator/codex/gemini-cli
Package geminiCLI provides request translation functionality for Gemini CLI to Codex API compatibility.
Package geminiCLI provides request translation functionality for Gemini CLI to Codex API compatibility.
translator/codex/openai/chat-completions
Package openai provides utilities to translate OpenAI Chat Completions request JSON into OpenAI Responses API request JSON using gjson/sjson.
Package openai provides utilities to translate OpenAI Chat Completions request JSON into OpenAI Responses API request JSON using gjson/sjson.
translator/gemini-cli/claude
Package claude provides request translation functionality for Claude Code API compatibility.
Package claude provides request translation functionality for Claude Code API compatibility.
translator/gemini-cli/gemini
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
translator/gemini-cli/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
translator/gemini/claude
Package claude provides request translation functionality for Claude API.
Package claude provides request translation functionality for Claude API.
translator/gemini/gemini
Package gemini provides in-provider request normalization for Gemini API.
Package gemini provides in-provider request normalization for Gemini API.
translator/gemini/gemini-cli
Package gemini provides request translation functionality for Claude API.
Package gemini provides request translation functionality for Claude API.
translator/gemini/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini API compatibility.
translator/openai/claude
Package claude provides request translation functionality for Anthropic to OpenAI API.
Package claude provides request translation functionality for Anthropic to OpenAI API.
translator/openai/gemini
Package gemini provides request translation functionality for Gemini to OpenAI API.
Package gemini provides request translation functionality for Gemini to OpenAI API.
translator/openai/gemini-cli
Package geminiCLI provides request translation functionality for Gemini to OpenAI API.
Package geminiCLI provides request translation functionality for Gemini to OpenAI API.
translator/openai/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
translator/translator
Package translator provides request and response translation functionality between different AI API formats.
Package translator provides request and response translation functionality between different AI API formats.
usage
Package usage provides usage tracking and logging functionality for the switchAILocal server.
Package usage provides usage tracking and logging functionality for the switchAILocal server.
util
Package util provides utility functions for the switchAILocal server.
Package util provides utility functions for the switchAILocal server.
virtualmodels
Package virtualmodels implements public virtual model pools such as ail-compound.
Package virtualmodels implements public virtual model pools such as ail-compound.
watcher
clients.go implements watcher client lifecycle logic and persistence helpers.
clients.go implements watcher client lifecycle logic and persistence helpers.
watcher/synthesizer
Package synthesizer provides auth synthesis strategies for the watcher package.
Package synthesizer provides auth synthesis strategies for the watcher package.
sdk
api
Package api exposes server option helpers for embedding switchAILocal.
Package api exposes server option helpers for embedding switchAILocal.
api/handlers
Package handlers provides core API handler functionality for the switchAILocal server.
Package handlers provides core API handler functionality for the switchAILocal server.
api/handlers/claude
Package claude provides HTTP handlers for Claude API code-related functionality.
Package claude provides HTTP handlers for Claude API code-related functionality.
api/handlers/gemini
Package gemini provides HTTP handlers for Gemini CLI API functionality.
Package gemini provides HTTP handlers for Gemini CLI API functionality.
api/handlers/notifications
Package notifications implements outbound notification relays so sandboxed clients (Tytus pods, restricted agents, etc.) can emit messages to external services like Telegram without ever holding the upstream credentials.
Package notifications implements outbound notification relays so sandboxed clients (Tytus pods, restricted agents, etc.) can emit messages to external services like Telegram without ever holding the upstream credentials.
api/handlers/openai
Package openai provides HTTP handlers for OpenAI API endpoints.
Package openai provides HTTP handlers for OpenAI API endpoints.
config
Package config provides the public SDK configuration API.
Package config provides the public SDK configuration API.
logging
Package logging re-exports request logging primitives for SDK consumers.
Package logging re-exports request logging primitives for SDK consumers.
switchailocal
Package switchailocal provides the core service implementation for the switchAILocal.
Package switchailocal provides the core service implementation for the switchAILocal.
translator
Package translator provides types and functions for converting chat requests and responses between different schemas.
Package translator provides types and functions for converting chat requests and responses between different schemas.
translator/builtin
Package builtin exposes the built-in translator registrations for SDK users.
Package builtin exposes the built-in translator registrations for SDK users.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL