OpenRouter With Punk
Punk routes OpenRouter models through the gateway. Your app keeps using an OpenAI-compatible client; the gateway resolves provider/model or openrouter:provider/model model ids to OpenRouter when an OpenRouter key is configured.
The SDK does not call OpenRouter directly. It gives you dependency-free config helpers and model-id helpers for sending requests to Punk.
Hosted Gateway Configuration
Add OpenRouter as a provider key in the Punk dashboard or tenant BYOK vault. App code continues to call Punk's hosted gateway:
PUNK_BASE_URL=https://app.punktechnologies.com
PUNK_API_KEY=pk_...
Punk's hosted gateway chooses the provider key at route time and records the key source in run evidence.
OpenAI SDK
import OpenAI from "openai";
import {
createPunkOpenRouterConfig,
openRouterModel,
} from "@punktechnologies/sdk/openrouter";
const client = new OpenAI(createPunkOpenRouterConfig({
app: "support",
agent: "triage-agent",
subject: "user-123",
}));
const completion = await client.chat.completions.create({
model: openRouterModel("google/gemini-2.5-flash"),
messages: [{ role: "user", content: "Classify this support ticket." }],
});
openRouterModel("google/gemini-2.5-flash") returns openrouter:google/gemini-2.5-flash. If you already have the prefix, the helper leaves it alone.
Native SDK Chat
import { Punk } from "@punktechnologies/sdk";
import { openRouterChat } from "@punktechnologies/sdk/openrouter";
const punk = new Punk({ app: "support", agent: "triage-agent", subject: "user-123" });
const result = await punk.chat(openRouterChat({
model: "anthropic/claude-sonnet-4",
messages: [{ role: "user", content: "Summarize this incident." }],
}));
console.log(result.route, result.provider, result.model, result.runId);
Model Ids
| Input | Routed as |
|---|---|
google/gemini-* | OpenRouter Google Gemini |
deepseek/deepseek-* | OpenRouter DeepSeek |
moonshotai/kimi-* | OpenRouter Kimi/Moonshot |
anthropic/claude-* | OpenRouter Anthropic |
openai/gpt-* | OpenRouter OpenAI |
openrouter:provider/model | Explicit OpenRouter route |
The gateway still records route explanations, provider/model metadata, cost, tokens, cache eligibility, failover, and BYOK key source in the run evidence.
Example
bun examples/openrouter-sdk.ts
The example requires Punk hosted gateway access. Configure provider keys in Punk before using OpenRouter slugs for production traffic.