Introduction
switchAILocal provides an OpenAI-compatible HTTP API that works with any OpenAI SDK or tool. Point your client tohttp://localhost:18080/v1 and use your existing code without modifications.
Base URL
Key Features
OpenAI Compatible
Works with OpenAI SDKs in Python, Node.js, and more without code changes
Multi-Provider
Access Gemini, Claude, Ollama, and other providers through a single endpoint
Auto-Routing
Omit provider prefixes to let switchAILocal choose the best available provider
Local-First
Everything runs on your machine - your data never leaves
Quick Example
Available Endpoints
| Endpoint | Method | Description |
|---|---|---|
/v1/chat/completions | POST | Send chat messages and receive completions |
/v1/completions | POST | Legacy completions endpoint |
/v1/models | GET | List all available models |
/v1/providers | GET | List provider status and capabilities |
/v1/embeddings | POST | Generate text embeddings |
/v1/ws | WebSocket | Real-time bidirectional streaming |
/v1/messages | POST | Claude-compatible messages endpoint |
Provider Support
switchAILocal supports multiple AI providers through a unified interface:CLI Providers (Use Your Subscriptions)
- Gemini CLI (
geminicli:) - Google Gemini via local CLI - Claude CLI (
claudecli:) - Anthropic Claude via local CLI - Codex (
codex:) - OpenAI Codex - Vibe (
vibe:) - Mistral Vibe CLI - OpenCode (
opencode:) - OpenCode CLI
Local Models
- Ollama (
ollama:) - Local open-source models - LM Studio (
lmstudio:) - Local model hosting
Cloud APIs
- switchAI (
switchai:) - Traylinx unified gateway - Gemini API (
gemini:) - Google AI Studio - Claude API (
claude:) - Anthropic API - OpenAI API (
openai:) - OpenAI platform - OpenAI Compatible (
openai-compat:) - OpenRouter, etc.
Error Handling
All errors follow the OpenAI error format:Common Error Types
| Type | HTTP Code | Description |
|---|---|---|
authentication_error | 401 | Invalid or missing API key |
invalid_request_error | 400 | Malformed request body |
permission_error | 403 | Insufficient quota or permissions |
rate_limit_error | 429 | Too many requests |
server_error | 500 | Internal server error |
Next Steps
Authentication
Learn how to authenticate API requests
Chat Completions
Send messages and receive AI responses
Provider Prefixes
Route requests to specific providers
Management API
Configure and monitor your server