Get started with the Memcode Router.
Use the official openai SDK and point its baseURL at the gateway. Requests use your Memcode Router key, and metered usage is tracked against its budget.
Three steps to your first token.
No new SDK, no new mental model. Change two fields in the client you already use and every request is metered, budgeted, and rate limited.
Point the SDK at the gateway
Set this value as the SDK's baseURL. Server-side only: never ship a router key in frontend JavaScript.
https://api.memcode.in/v1Call the Responses API
Authenticate with your sm-* router key and set an explicit output cap. Without one, the router reserves budget for 4,096 output tokens.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.MEMCODE_API_KEY,
baseURL: "https://api.memcode.in/v1",
});
const response = await client.responses.create({
model: "gpt-5.6-terra",
input: "Explain quantum computing in simple terms.",
max_output_tokens: 256,
});
console.log(response.output_text);Pick a model
Choose a supported model ID from your key's provider. Featured models are listed below with base ledger rates per 1M text tokens; cache-write and long-context premiums are detailed in the docs.
gpt-5.6-terraOpenAIBalancedgpt-5.6-lunaOpenAIFastgemini-3.1-pro-previewGeminiFlagshipgemini-3.7-flashGeminiBalancedgemini-3.1-flash-liteGeminiBudgetclaude-opus-4-8AnthropicFlagshipclaude-sonnet-4-6AnthropicBalancedCache-write and long-context multipliers apply to some models. See the pricing details.
Every token is accounted for.
Before a request reaches OpenAI, the router atomically reserves its worst-case cost against your key's budget, then settles the real charge from returned usage. Check the used and remaining balance any time.