SDK

Node.js SDK

Drop-in compatible with the OpenAI Node.js SDK. Streaming, function calling, and tool use with zero provider lock-in.

Installation

Use the official OpenAI SDK pointed at the Meridian API endpoint.

npm i openai

Configuration

Set your API key as an environment variable. Get one from the dashboard.

MERIDIAN_API_KEY=sk-nimbus-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Streaming Chat

Real-time token streaming with async iteration.

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.MERIDIAN_API_KEY,
  baseURL: 'https://api.getnimbus.net/v1',
});

async function main() {
  const stream = await client.chat.completions.create({
    model: 'meridian-4',
    messages: [{ role: 'user', content: 'Explain quantum entanglement in one paragraph.' }],
    stream: true,
  });

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

main().catch(console.error);

Function Calling & Tools

Define tools, let the model decide when to call them, and stream the final response.

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.MERIDIAN_API_KEY,
  baseURL: 'https://api.getnimbus.net/v1',
});

async function getWeather(location: string, unit: 'celsius' | 'fahrenheit' = 'celsius') {
  // Your actual weather lookup logic here
  return { location, temperature: 22, unit, condition: 'sunny' };
}

const tools = [
  {
    type: 'function' as const,
    function: {
      name: 'get_weather',
      description: 'Get current weather for a location',
      parameters: {
        type: 'object',
        properties: {
          location: { type: 'string', description: 'City name' },
          unit: { type: 'string', enum: ['celsius', 'fahrenheit'] },
        },
        required: ['location'],
      },
    },
  },
];

async function main() {
  const messages: OpenAI.Chat.Completions.ChatCompletionMessageParam[] = [
    { role: 'user', content: "What's the weather in Tokyo?" },
  ];

  const response = await client.chat.completions.create({
    model: 'meridian-4',
    messages,
    tools,
    tool_choice: 'auto',
  });

  const msg = response.choices[0].message;

  if (msg.tool_calls) {
    for (const toolCall of msg.tool_calls) {
      if (toolCall.function.name === 'get_weather') {
        const args = JSON.parse(toolCall.function.arguments);
        const result = await getWeather(args.location, args.unit);

        messages.push(msg);
        messages.push({
          role: 'tool',
          tool_call_id: toolCall.id,
          content: JSON.stringify(result),
        });
      }
    }

    const secondResponse = await client.chat.completions.create({
      model: 'meridian-4',
      messages,
      stream: true,
    });

    for await (const chunk of secondResponse) {
      process.stdout.write(chunk.choices[0]?.delta?.content || '');
    }
  } else {
    console.log(msg.content);
  }
}

main().catch(console.error);

Full API Reference

Every parameter, model, and endpoint documented.

Browse API Reference