Integration

OpenAI TypeScript SDK with Meridian

The official openai Node SDK works as-is. Change two things: the baseURL and apiKey. Everything else (streaming, tools, JSON mode, vision) behaves identically.

Install

npm install openai

Basic call

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "nim_live_***",
  baseURL: "https://meridian.getnimbus.net/api/v1",
});

const resp = await client.chat.completions.create({
  model: "azure-swc/gpt-4.1",
  messages: [{ role: "user", content: "hello" }],
});

console.log(resp.choices[0].message.content);

Streaming

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

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

Tool calling

const resp = await client.chat.completions.create({
  model: "azure-swc/gpt-4.1",
  messages: [{ role: "user", content: "Weather in SF?" }],
  tools: [{
    type: "function",
    function: {
      name: "get_weather",
      description: "Get current weather",
      parameters: {
        type: "object",
        properties: { city: { type: "string" } },
        required: ["city"],
      },
    },
  }],
});

JSON mode

const resp = await client.chat.completions.create({
  model: "azure-swc/gpt-4.1",
  response_format: { type: "json_object" },
  messages: [
    { role: "system", content: "Output strict JSON." },
    { role: "user", content: "List 3 colors." },
  ],
});

const data = JSON.parse(resp.choices[0].message.content!);