SDKs and clients
There is no Multigrid SDK. Point an OpenAI client at our base URL instead.
There is no SDK
Deliberately. The gateway speaks the OpenAI wire format, so every client that already exists — official SDKs, LangChain, the Vercel AI SDK, a hand-rolled fetch — works against it with a base URL and a key. A thin wrapper of ours would be one more thing to keep in step with five languages, and it would be strictly less capable than what you already have installed.
Two things change and nothing else: baseURL becomes https://api.multigrid.ai/v1, and the key becomes a Multigrid key. Model ids change too, because ours are namespaced by vendor — openai/gpt-4o rather than gpt-4o.
/api/openapi.json, unauthenticated. Feed it to openapi-generator, oazapfts, kiota or whatever your language uses; import it into Postman, Bruno or Insomnia; or point Prism at it for a mock server to build against before you have a key. It covers every route including the ones an OpenAI SDK has no method for — batches, keys, usage, generation and the OAuth surface.TypeScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.multigrid.ai/v1",
apiKey: process.env.MULTIGRID_API_KEY,
});
const res = await client.chat.completions.create({
model: "anthropic/claude-sonnet-5",
messages: [{ role: "user", content: "Summarise this contract." }],
// Multigrid-only. The OpenAI types do not declare these, so the object is
// cast — the client serialises whatever it is handed.
models: ["openai/gpt-5.1"],
provider: { sort: "price" },
} as Parameters<typeof client.chat.completions.create>[0]);
console.log(res.choices[0].message.content);
// res.multigrid.cost_usd — what this exact call cost. Also on the
// X-Multigrid-Cost-Usd response header, which needs no cast.Python
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.multigrid.ai/v1",
api_key=os.environ["MULTIGRID_API_KEY"],
)
res = client.chat.completions.create(
model="anthropic/claude-sonnet-5",
messages=[{"role": "user", "content": "Summarise this contract."}],
# Fields the SDK does not model go here and are sent verbatim.
extra_body={
"models": ["openai/gpt-5.1"],
"provider": {"sort": "price"},
},
)Reaching our extra fields
Everything Multigrid adds lives in optional top-level fields: models, provider, metadata, plugins, cache and retry. The OpenAI SDKs do not have types for them, so:
- Python: put them in
extra_body. They are merged into the request body untouched. - TypeScript: add them to the object and silence the type error.
openai-nodeserialises whatever you hand it. - Anything else: they are ordinary JSON keys. If you can add a key to the body, you can use them.
Those six are stripped before the request goes upstream, along with transforms, route and multigrid, so a provider never sees a parameter it would reject. The full list is in chat completions.
Something here disagrees with what the API actually did? That is a bug in this page, and worth reporting.
Report it