Claude agent sdk multi provider bridge
Skill kjuhwa/skills-hub/skills/agent-sdk/claude-agent-sdk-multi-provider-bridge
Drive non-Anthropic providers (OpenRouter, Ollama, Vercel AI Gateway, any Anthropic-compatible endpoint) through the Claude Agent SDK by swapping base URL + auth env, and route Google/OpenAI/Copilot through a parallel Pi SDK backend with a shared AgentBackend interface.From its SKILL.md
npx -y skills add kjuhwa/skills-hub --skill claude-agent-sdk-multi-provider-bridgeAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.3 KB, 669 tokens by cl100k_base, as published. Nobody here has run it
Multi-provider agent behind one AgentBackend
When to use
- App wants "use Claude, but also OpenAI, Gemini, Llama-via-Ollama, Codex, Copilot" without maintaining N bespoke client stacks.
- Claude Agent SDK already handles Claude and any Anthropic-compatible endpoint; a second SDK (Pi) covers OpenAI/Google/Copilot idioms.
- Need a single
AgentBackendinterface so session storage, tool dispatch, event adapters don't branch per provider.
How it works
- Define a common
AgentBackendinterface:start(options),query(messages),abort(), event stream, permission callbacks. BothClaudeAgentandPiAgentimplement it. - Driver registry keyed by
provider:const DRIVER_REGISTRY: Record<AgentProvider, ProviderDriver> = { anthropic: anthropicDriver, pi: piDriver, }; - Each LLM connection record carries
providerType(anthropic,openai,google,openrouter,groq,mistral,xai, ...) andauthType(apiKey,oauth,claudeMax, ...). - For Anthropic-family providers,
anthropicDriverresolves the API key / OAuth token and setsANTHROPIC_BASE_URL+ANTHROPIC_AUTH_TOKEN(orANTHROPIC_API_KEY) before instantiating the Claude SDK. That's ALL it takes to point at OpenRouter or Ollama. - For Pi-family providers,
piDriverconfigures@mariozechner/pi-aiwith provider-specific auth (GOOGLE_API_KEY, Codex OAuth, Copilot device-code flow). - A shared event adapter translates each SDK's stream into the app's normalized
AgentEventtype; Claude and Pi have separate adapters but produce the same output shape.
Example
// Configure Claude SDK to talk to OpenRouter:
const env = {
...process.env,
ANTHROPIC_BASE_URL: 'https://openrouter.ai/api/v1',
ANTHROPIC_AUTH_TOKEN: userOpenRouterKey,
};
const q = query({ prompt, options: { ...base, model: 'anthropic/claude-opus-4.7' } });
// Shared dispatch
function createAgent(conn: LlmConnection): AgentBackend {
const driver = DRIVER_REGISTRY[getProvider(conn.providerType)];
return driver.create(conn);
}
Gotchas
- OpenRouter uses
provider/model-nameslugs, not bare model names - surface that in the UI. - Ollama has no auth; pass an empty string for
ANTHROPIC_AUTH_TOKENbut the env var must exist or the SDK will complain. - The Pi SDK is ESM-only; your build pipeline needs
bun build --target=bun --format=esmor it breaks at runtime. - Don't leak provider-specific fields through the event adapter - keep
AgentEventcanonical so UI code doesn't sproutif (provider === …).
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.