OpenAI SDK

Drop-in usage of the official OpenAI SDK with the gateway as the baseURL.

Integrations

The official openai package — both TypeScript and Python — works without modification. Set baseURL (or base_url) to the gateway, pass a gw_ key as the API key, and you're done. Streaming, non-streaming, function calling, and embeddings (for models that support them) all route through.

TypeScript

ts
import OpenAI from "openai";const client = new OpenAI({apiKey: process.env.GATEWAY_KEY,baseURL: "https://api.toygate.store/v1",});const response = await client.chat.completions.create({model: "gpt-5.5",messages: [{ role: "user", content: "Say hi" }],});console.log(response.choices[0]?.message?.content);

For streaming:

const stream = await client.chat.completions.create({
  model: "gpt-5.5",
  stream: true,
  messages: [{ role: "user", content: "Stream me a sentence." }],
});

for await (const chunk of stream) {
  const delta = chunk.choices[0]?.delta?.content;
  if (delta) process.stdout.write(delta);
}

Python

python
from openai import OpenAIclient = OpenAI(  api_key=os.environ["GATEWAY_KEY"],  base_url="https://api.toygate.store/v1",)response = client.chat.completions.create(  model="gpt-5.5",  messages=[{"role": "user", "content": "Say hi"}],)print(response.choices[0].message.content)

Function calling

Function calling round-trips end-to-end — the gateway translates OpenAI tool definitions into the upstream's tool shape, then maps tool_use responses back into OpenAI's tool_calls. The model must support tools (capabilities.tools = true on the catalog page).

const response = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [{ role: "user", content: "What time is it in Tokyo?" }],
  tools: [
    {
      type: "function",
      function: {
        name: "current_time",
        description: "Returns the current local time in the given timezone.",
        parameters: {
          type: "object",
          properties: { timezone: { type: "string" } },
          required: ["timezone"],
        },
      },
    },
  ],
});

What works, what doesn't

OpenAI featureStatus
chat.completions.create (sync)✅
chat.completions.create (stream)✅
Tool calls✅ when capabilities.tools = true
Vision (image_url parts)✅ forwarded when the model supports vision; otherwise 400 model_does_not_support_images
Structured output (response_format)❌ 400 response_format_not_supported
Embeddings➖ depends on operator config
Assistants API❌ not implemented
Realtime API❌ not implemented

Gateway URL: https://api.toygate.store