SDKs
Use the vendor’s own SDK and change two things: the base URL and the key. The base URL differs by SDK because each SDK appends its own path:
| SDK | Base URL | Appended by the SDK |
|---|---|---|
| OpenAI (Python, Node, Go, …) | https://api.test.whocare.xyz/v1 |
/chat/completions, /responses, /embeddings, … |
| Anthropic | https://api.test.whocare.xyz |
/v1/messages |
| Google Gen AI | https://api.test.whocare.xyz |
/v1beta/models/... |
Any model works with any SDK: the Anthropic SDK can call a GPT model and the OpenAI SDK can call a Claude model, because the gateway converts between dialects (Endpoints). Model names are the catalog’s, as listed by GET /v1/models.
Keep the key in an environment variable (GATEWAY_API_KEY here) and read it at run time.
Python
Section titled “Python”pip install openai anthropic google-genaiOpenAI SDK
Section titled “OpenAI SDK”import osfrom openai import OpenAI
client = OpenAI(base_url="https://api.test.whocare.xyz/v1", api_key=os.environ["GATEWAY_API_KEY"])
resp = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Say hello in one word."}],)print(resp.choices[0].message.content)print("cost (USD):", resp.usage.model_extra["cost"])Gateway-only request fields (provider, models) go in extra_body, because the SDK would otherwise reject unknown keyword arguments:
import osfrom openai import OpenAI
client = OpenAI(base_url="https://api.test.whocare.xyz/v1", api_key=os.environ["GATEWAY_API_KEY"])
raw = client.chat.completions.with_raw_response.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Say hello in one word."}], extra_body={"provider": {"order": ["azure"], "allow_fallbacks": False}},)print("served by:", raw.headers["x-gateway-provider"])# expect: served by: azureprint(raw.parse().choices[0].message.content)The Responses API:
import osfrom openai import OpenAI
client = OpenAI(base_url="https://api.test.whocare.xyz/v1", api_key=os.environ["GATEWAY_API_KEY"])
resp = client.responses.create(model="gpt-4o-mini", input="Say hello in one word.")print(resp.output_text)Anthropic SDK
Section titled “Anthropic SDK”import osimport anthropic
client = anthropic.Anthropic(base_url="https://api.test.whocare.xyz", api_key=os.environ["GATEWAY_API_KEY"])
msg = client.messages.create( model="claude-sonnet-5-5", max_tokens=64, messages=[{"role": "user", "content": "Say hello in one word."}],)print(msg.content[0].text)print("cost (USD):", msg.usage.model_extra["cost"])Google Gen AI SDK
Section titled “Google Gen AI SDK”import osfrom google import genaifrom google.genai import types
client = genai.Client( api_key=os.environ["GATEWAY_API_KEY"], http_options=types.HttpOptions(base_url="https://api.test.whocare.xyz", api_version="v1beta"),)resp = client.models.generate_content(model="gemini-2.5-flash", contents="Say hello in one word.")print(resp.text)The Gen AI SDK does not expose usageMetadata.cost; read the cost from /v1/generation with the id in the X-Request-Id header, or call the endpoint over plain HTTP.
Node.js
Section titled “Node.js”npm install openai @anthropic-ai/sdkOpenAI SDK
Section titled “OpenAI SDK”import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.test.whocare.xyz/v1", apiKey: process.env.GATEWAY_API_KEY,});
// Gateway-only fields can be passed as extra body properties; the SDK sends them as given.const { data, response } = await client.chat.completions .create({ model: "gpt-4o-mini", messages: [{ role: "user", content: "Say hello in one word." }], provider: { order: ["azure"], allow_fallbacks: false }, }) .withResponse();console.log("served by:", response.headers.get("x-gateway-provider"));// expect: served by: azureconsole.log(data.choices[0].message.content);console.log("cost (USD):", data.usage.cost);Anthropic SDK
Section titled “Anthropic SDK”import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.test.whocare.xyz", apiKey: process.env.GATEWAY_API_KEY,});
const msg = await client.messages.create({ model: "claude-sonnet-5-5", max_tokens: 64, messages: [{ role: "user", content: "Say hello in one word." }],});console.log(msg.content[0].text);console.log("cost (USD):", msg.usage.cost);Google Gen AI SDK
Section titled “Google Gen AI SDK”import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: process.env.GATEWAY_API_KEY, httpOptions: { baseUrl: "https://api.test.whocare.xyz" },});const resp = await ai.models.generateContent({ model: "gemini-2.5-flash", contents: "Say hello in one word.",});console.log(resp.text);go get github.com/openai/openai-gopackage main
import ( "context" "fmt" "os"
"github.com/openai/openai-go" "github.com/openai/openai-go/option")
func main() { client := openai.NewClient( option.WithBaseURL("https://api.test.whocare.xyz/v1/"), option.WithAPIKey(os.Getenv("GATEWAY_API_KEY")), ) resp, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{ Model: "gpt-4o-mini", Messages: []openai.ChatCompletionMessageParamUnion{openai.UserMessage("Say hello in one word.")}, }) if err != nil { panic(err) } fmt.Println(resp.Choices[0].Message.Content)}The Go example is not run automatically with the other examples. The import path of OpenAI’s Go SDK depends on its major version (for example it carries /v2 in later releases); use the one of the version you install.
Other languages and frameworks
Section titled “Other languages and frameworks”Anything that lets you set the base URL of an OpenAI-compatible, Anthropic or Gemini endpoint works the same way: set the base URL as in the table at the top and use the gateway key as the API key. That covers the Java, .NET, Ruby and PHP SDKs of the vendors, and frameworks built on them (LangChain, LlamaIndex, Vercel AI SDK, and so on).
If a library insists on a model list or fixed model names, call GET /v1/models for the names the gateway serves, or use the model field of the library’s “custom model” setting.