agentsclimarketplace

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

Install
npx -y skills add kjuhwa/skills-hub --skill claude-agent-sdk-multi-provider-bridge

Assembled 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 AgentBackend interface so session storage, tool dispatch, event adapters don't branch per provider.

How it works

  1. Define a common AgentBackend interface: start(options), query(messages), abort(), event stream, permission callbacks. Both ClaudeAgent and PiAgent implement it.
  2. Driver registry keyed by provider:
    const DRIVER_REGISTRY: Record<AgentProvider, ProviderDriver> = {
      anthropic: anthropicDriver,
      pi: piDriver,
    };
    
  3. Each LLM connection record carries providerType (anthropic, openai, google, openrouter, groq, mistral, xai, ...) and authType (apiKey, oauth, claudeMax, ...).
  4. For Anthropic-family providers, anthropicDriver resolves the API key / OAuth token and sets ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN (or ANTHROPIC_API_KEY) before instantiating the Claude SDK. That's ALL it takes to point at OpenRouter or Ollama.
  5. For Pi-family providers, piDriver configures @mariozechner/pi-ai with provider-specific auth (GOOGLE_API_KEY, Codex OAuth, Copilot device-code flow).
  6. A shared event adapter translates each SDK's stream into the app's normalized AgentEvent type; 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-name slugs, not bare model names - surface that in the UI.
  • Ollama has no auth; pass an empty string for ANTHROPIC_AUTH_TOKEN but 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=esm or it breaks at runtime.
  • Don't leak provider-specific fields through the event adapter - keep AgentEvent canonical so UI code doesn't sprout if (provider === …).

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,144. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.