# OpenCodex — Universal LLM Proxy for AI Coding Agents > Universal provider proxy that lets you use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama) with OpenAI Codex CLI, Claude Code, and other AI coding agents through a single gateway. ## Install Save in your project root: # OpenCodex — Universal LLM Proxy for AI Coding Agents ## Quick Use ```bash npm install -g opencodex # Start the proxy with your preferred model opencodex start --provider deepseek --model deepseek-coder # Point your coding agent to the proxy endpoint export OPENAI_BASE_URL=http://localhost:8787/v1 ``` ## Introduction OpenCodex is an open-source proxy server that bridges any LLM provider to AI coding agents like OpenAI Codex CLI and Claude Code. Instead of being locked into a single model vendor, OpenCodex translates API calls on the fly so you can use Claude, Gemini, Grok, DeepSeek, or locally hosted models through Ollama with any coding agent that speaks the OpenAI-compatible API format. ## What OpenCodex Does - Proxies OpenAI-compatible API requests to 10+ LLM providers transparently - Enables using Claude, Gemini, DeepSeek, or Ollama models with Codex CLI - Translates tool-use and function-calling formats between provider APIs - Supports streaming responses for real-time coding agent feedback - Runs as a local proxy server with zero cloud dependency ## Architecture Overview OpenCodex runs a lightweight TypeScript-based HTTP proxy that intercepts OpenAI-formatted API requests and translates them to the target provider's native format. It handles authentication, request transformation, streaming response adaptation, and error normalization. The proxy supports hot-swapping between providers without restarting the coding agent, and includes a caching layer to reduce redundant API calls during iterative coding sessions. ## Self-Hosting & Configuration - Install globally via npm or run with npx for quick sessions - Configure provider credentials via environment variables or config file - Start the proxy and point your coding agent's API base URL to localhost - Set up model aliases to map generic names to provider-specific identifiers - Enable request logging for debugging and cost tracking ## Key Features - Supports Claude, Gemini, Grok, DeepSeek, Ollama, and OpenRouter providers - Tool-use format translation between OpenAI, Anthropic, and Google schemas - Request caching reduces token costs during iterative agent workflows - Provider failover automatically switches to backup providers on errors - Model aliasing lets agents reference models by simple names ## Comparison with Similar Tools - **LiteLLM** — broader scope API gateway; OpenCodex is optimized for coding agents - **OpenRouter** — SaaS routing service; OpenCodex runs entirely locally - **Portkey AI Gateway** — enterprise-focused; OpenCodex is lightweight and self-hosted - **Bifrost CLI** — wraps Claude Code specifically; OpenCodex supports multiple agents - **Ollama** — local model runner; OpenCodex proxies to Ollama and many other providers ## FAQ **Q: Does it work with Claude Code out of the box?** A: Yes, set the API base URL environment variable to point at the proxy and Claude Code will use your chosen provider. **Q: Can I use local models through Ollama?** A: Yes, configure Ollama as the provider and OpenCodex will proxy requests to your local Ollama instance. **Q: Does it support streaming?** A: Yes, server-sent events are translated between provider formats for real-time output. **Q: Is there any performance overhead?** A: Minimal. The proxy adds single-digit milliseconds of latency for request translation. ## Sources - https://github.com/lidge-jun/opencodex - https://github.com/lidge-jun/opencodex/blob/main/README.md --- Source: https://tokrepo.com/en/workflows/asset-700c44f6 Author: AI Open Source