openclaude-multi-llm
Use Claude Code's full tool system with any OpenAI-compatible LLM — GPT-4o, DeepSeek, Gemini, Ollama, and 200+ models via environment variable configuration.
What this skill does
# OpenClaude Multi-LLM Skill
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
OpenClaude is a fork of Claude Code that routes all LLM calls through an OpenAI-compatible shim (`openaiShim.ts`), letting you use any model that speaks the OpenAI Chat Completions API — GPT-4o, DeepSeek, Gemini via OpenRouter, Ollama, Groq, Mistral, Azure, and more — while keeping every Claude Code tool intact (Bash, FileRead, FileWrite, FileEdit, Glob, Grep, WebFetch, Agent, MCP, Tasks, LSP, NotebookEdit).
---
## Installation
### npm (recommended)
```bash
npm install -g @gitlawb/openclaude
# CLI command installed: openclaude
```
### From source (requires Bun)
```bash
git clone https://node.gitlawb.com/z6MkqDnb7Siv3Cwj7pGJq4T5EsUisECqR8KpnDLwcaZq5TPr/openclaude.git
cd openclaude
bun install
bun run build
# optionally link globally
npm link
```
### Run without build
```bash
bun run dev # run directly with Bun, no build step
```
---
## Activation — Required Environment Variables
You must set `CLAUDE_CODE_USE_OPENAI=1` to enable the shim. Without it, the tool falls back to the Anthropic SDK.
| Variable | Required | Purpose |
|---|---|---|
| `CLAUDE_CODE_USE_OPENAI` | Yes | Set to `1` to activate OpenAI provider |
| `OPENAI_API_KEY` | Yes* | API key (*omit for local Ollama/LM Studio) |
| `OPENAI_MODEL` | Yes | Model identifier |
| `OPENAI_BASE_URL` | No | Custom endpoint (default: `https://api.openai.com/v1`) |
| `CODEX_API_KEY` | Codex only | ChatGPT/Codex access token |
| `CODEX_AUTH_JSON_PATH` | Codex only | Path to Codex CLI `auth.json` |
`OPENAI_MODEL` takes priority over `ANTHROPIC_MODEL` if both are set.
---
## Provider Configuration Examples
### OpenAI
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=$OPENAI_API_KEY
export OPENAI_MODEL=gpt-4o
openclaude
```
### DeepSeek
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=$DEEPSEEK_API_KEY
export OPENAI_BASE_URL=https://api.deepseek.com/v1
export OPENAI_MODEL=deepseek-chat
openclaude
```
### Google Gemini (via OpenRouter)
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=$OPENROUTER_API_KEY
export OPENAI_BASE_URL=https://openrouter.ai/api/v1
export OPENAI_MODEL=google/gemini-2.0-flash
openclaude
```
### Ollama (local, no API key needed)
```bash
ollama pull llama3.3:70b
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_BASE_URL=http://localhost:11434/v1
export OPENAI_MODEL=llama3.3:70b
openclaude
```
### Groq
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=$GROQ_API_KEY
export OPENAI_BASE_URL=https://api.groq.com/openai/v1
export OPENAI_MODEL=llama-3.3-70b-versatile
openclaude
```
### Mistral
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=$MISTRAL_API_KEY
export OPENAI_BASE_URL=https://api.mistral.ai/v1
export OPENAI_MODEL=mistral-large-latest
openclaude
```
### Azure OpenAI
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=$AZURE_OPENAI_KEY
export OPENAI_BASE_URL=https://your-resource.openai.azure.com/openai/deployments/your-deployment/v1
export OPENAI_MODEL=gpt-4o
openclaude
```
### Codex (ChatGPT backend)
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_MODEL=codexplan # or codexspark for faster loops
# reads ~/.codex/auth.json automatically if present
# or set: export CODEX_API_KEY=$CODEX_TOKEN
openclaude
```
### LM Studio (local)
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_BASE_URL=http://localhost:1234/v1
export OPENAI_MODEL=your-model-name
openclaude
```
### Together AI
```bash
export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_API_KEY=$TOGETHER_API_KEY
export OPENAI_BASE_URL=https://api.together.xyz/v1
export OPENAI_MODEL=meta-llama/Llama-3.3-70B-Instruct-Turbo
openclaude
```
---
## Architecture — How the Shim Works
The shim file is `src/services/api/openaiShim.ts` (724 lines). It duck-types the Anthropic SDK interface so the rest of Claude Code is unaware it's talking to a different provider.
```
Claude Code Tool System
│
▼
Anthropic SDK interface (duck-typed)
│
▼
openaiShim.ts ← format translation layer
│
▼
OpenAI Chat Completions API
│
▼
Any compatible model
```
### What the shim translates
- Anthropic message content blocks → OpenAI `messages` array
- Anthropic `tool_use` / `tool_result` blocks → OpenAI `function_calls` / `tool` messages
- OpenAI SSE streaming chunks → Anthropic stream events
- Anthropic system prompt arrays → OpenAI `system` role messages
### Files changed from upstream
```
src/services/api/openaiShim.ts ← NEW: the shim (724 lines)
src/services/api/client.ts ← routes to shim when CLAUDE_CODE_USE_OPENAI=1
src/utils/model/providers.ts ← added 'openai' provider type
src/utils/model/configs.ts ← added openai model mappings
src/utils/model/model.ts ← respects OPENAI_MODEL for defaults
src/utils/auth.ts ← recognizes OpenAI as valid 3rd-party provider
```
---
## Developer Workflow — Key Commands
```bash
# Run in dev mode (no build)
bun run dev
# Build distribution
bun run build
# Launch with persisted profile (.openclaude-profile.json)
bun run dev:profile
# Launch with OpenAI profile (requires OPENAI_API_KEY in shell)
bun run dev:openai
# Launch with Ollama profile (localhost:11434, llama3.1:8b default)
bun run dev:ollama
# Launch with Codex profile
bun run dev:codex
# Quick startup sanity check
bun run smoke
# Validate provider env + reachability
bun run doctor:runtime
# Machine-readable runtime diagnostics
bun run doctor:runtime:json
# Persist diagnostics report to reports/doctor-runtime.json
bun run doctor:report
# Full local hardening check (typecheck + smoke + runtime doctor)
bun run hardening:check
# Strict hardening (includes project-wide typecheck)
bun run hardening:strict
```
---
## Profile Bootstrap — One-Time Setup
Profiles save provider config to `.openclaude-profile.json` so you don't repeat env exports.
```bash
# Auto-detect provider (ollama if running, otherwise openai)
bun run profile:init
# Bootstrap for OpenAI
bun run profile:init -- --provider openai --api-key $OPENAI_API_KEY
# Bootstrap for Ollama with custom model
bun run profile:init -- --provider ollama --model llama3.1:8b
# Bootstrap for Codex
bun run profile:init -- --provider codex --model codexspark
bun run profile:codex
```
After bootstrapping, run the app via the persisted profile:
```bash
bun run dev:profile
```
---
## TypeScript Integration — Using the Shim Directly
If you want to use the shim in your own TypeScript code:
```typescript
// src/services/api/client.ts pattern — routing to the shim
import { openaiShim } from './openaiShim.js';
const useOpenAI = process.env.CLAUDE_CODE_USE_OPENAI === '1';
const client = useOpenAI
? openaiShim({
apiKey: process.env.OPENAI_API_KEY,
baseURL: process.env.OPENAI_BASE_URL ?? 'https://api.openai.com/v1',
model: process.env.OPENAI_MODEL ?? 'gpt-4o',
})
: new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
```
```typescript
// Streaming usage pattern (mirrors Anthropic SDK interface)
const stream = await client.messages.stream({
model: process.env.OPENAI_MODEL!,
max_tokens: 32000,
system: 'You are a helpful coding assistant.',
messages: [
{ role: 'user', content: 'Refactor this function for readability.' }
],
tools: myTools, // Anthropic-format tool definitions — shim translates them
});
for await (const event of stream) {
// events arrive in Anthropic format regardless of underlying provider
if (event.type === 'content_block_delta') {
process.stdout.write(event.delta.text ?? '');
}
}
```
---
## Model Quality Reference
| Model | Tool Calling | Code Quality | Speed |
|---|---|---|---|
| GPT-4o | Excellent | Excellent | Fast |
| DeepSeek-V3 | Great | Great | Fast |
| Gemini 2.0 Flash | Great | Good | Very Fast |
| Llama 3.3 70B | Good | Good | Medium |
| Mistral Large | Good | Good | Fast |
| GPT-4o-mini | Good | Good | Very Fast |
| Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.