OpenAI SDK

The official OpenAI SDKs work against Nimbus with a single line changed — the base URL. No custom wrapper, no vendored fork, no waiting for a Nimbus SDK release.

Nimbus speaks the OpenAI wire format on /v1/chat/completions, /v1/embeddings, and /v1/models. If a library uses the OpenAI SDK under the hood — LangChain, LiteLLM, Vercel AI SDK, Instructor — it works against Nimbus for free.

Prerequisites

  • A Nimbus API key (starts with sk-nim-) — grab one from the dashboard.
  • Node.js 18+ or Python 3.9+ for the official SDKs.
  • Any prepaid balance on the key so requests don't 402.

Install

Node:

bash
npm i openai

Python:

bash
pip install openai

Configure

Point baseURL at Nimbus and read the key from an env var. Never hard-code the key in source.

typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://llm.nimbusapi.net/v1",
  apiKey: process.env.NIMBUS_API_KEY,
});
python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://llm.nimbusapi.net/v1",
    api_key=os.environ["NIMBUS_API_KEY"],
)

First call

Full working example against anthropic/claude-sonnet-4.6 with a tool definition — the Nimbus router will forward the request to Anthropic under the hood and translate the response back into OpenAI shape.

typescript
const res = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4.6",
  messages: [
    { role: "system", content: "You are a build assistant." },
    { role: "user", content: "What is the current price of BTC in USD?" },
  ],
  tools: [
    {
      type: "function",
      function: {
        name: "get_price",
        description: "Look up the current spot price for a ticker.",
        parameters: {
          type: "object",
          properties: { ticker: { type: "string" } },
          required: ["ticker"],
        },
      },
    },
  ],
});

console.log(res.choices[0].message);

The response follows the standard OpenAI shape: choices[0].message.tool_calls if the model wants to call a tool, choices[0].message.content for plain text.

Streaming

Pass stream: true and iterate the returned async iterator. Nimbus streams server-sent events in the exact OpenAI delta format, so the SDK's built-in stream parser handles them without any config.

typescript
const stream = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-4.6",
  messages: [{ role: "user", content: "Write a haiku about Ohio." }],
  stream: true,
});

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

Troubleshooting

  • 401 Unauthorized: the key doesn't start with sk-nim-, or you sent the OpenAI key by mistake. Print process.env.NIMBUS_API_KEY and confirm it's the right value.
  • 404 Not Found: baseURL is missing the /v1 suffix. The OpenAI SDK does not append it for you.
  • 400 "model not found": use the fully-qualified model name (anthropic/claude-sonnet-4.6, not claude-sonnet-4.6). See Models.
  • 402 Payment Required: the key hit its spend cap or the workspace balance is $0. Top up in the dashboard.
  • Streaming buffers everything: a proxy or CDN is holding the response until the end. Confirm you're hitting llm.nimbusapi.net directly, not a same-origin rewrite that strips SSE headers.