feat: add OpenAI-compatible provider shim — use any LLM with Claude Code
Adds a new 'openai' API provider that translates Anthropic SDK calls to OpenAI chat completions format, enabling Claude Code's full tool system (bash, file read/write/edit, grep, glob, agents) with any OpenAI-compatible model: GPT-4o, DeepSeek, Gemini, Llama, Ollama, OpenRouter, and 200+ more. Set CLAUDE_CODE_USE_OPENAI=1, OPENAI_API_KEY, and OPENAI_MODEL to use. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d2542c9a62
commit
619b5fb603
@@ -150,6 +150,14 @@ export async function getAnthropicClient({
|
||||
fetch: resolvedFetch,
|
||||
}),
|
||||
}
|
||||
if (isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI)) {
|
||||
const { createOpenAIShimClient } = await import('./openaiShim.js')
|
||||
return createOpenAIShimClient({
|
||||
defaultHeaders,
|
||||
maxRetries,
|
||||
timeout: parseInt(process.env.API_TIMEOUT_MS || String(600 * 1000), 10),
|
||||
}) as unknown as Anthropic
|
||||
}
|
||||
if (isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK)) {
|
||||
const { AnthropicBedrock } = await import('@anthropic-ai/bedrock-sdk')
|
||||
// Use region override for small fast model if specified
|
||||
|
||||
Reference in New Issue
Block a user