Integration guide

Node.js integration with Plugsky

Plugsky is a plain HTTPS JSON API with an OpenAI-compatible shape, so Node works with the official openai package or fetch. No Plugsky-specific package is required.

Short answer. Call Plugsky from Node.js with the official openai package or fetch. Set baseURL to https://api.plugsky.com/v1 and use a plugsky-* model ID. Chat, streaming, tools and embeddings work.

What the Node.js integration covers

This page is for Node.js and TypeScript applications calling Plugsky directly. The recommended client is the official openai npm package, which provides typed responses, retries, streaming and ESM/CJS support. Raw fetch also works because the API is plain HTTPS JSON.

Install

Shell
npm install openai
# Node 18+ has fetch built in

OpenAI SDK (recommended)

TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.PLUGSKY_API_KEY,
  baseURL: "https://api.plugsky.com/v1",
});

const r = await client.chat.completions.create({
  model: "plugsky-pro",
  messages: [{ role: "user", content: "What is an OpenAI-compatible API?" }],
  temperature: 0.2,
  max_tokens: 512,
});
console.log(r.choices[0].message.content);

Streaming

TypeScript
const stream = await client.chat.completions.create({
  model: "plugsky-pro",
  messages: [{ role: "user", content: "Count to five." }],
  stream: true,
});
for await (const chunk of stream) {
  const text = chunk.choices[0]?.delta?.content;
  if (text) process.stdout.write(text);
}

Raw fetch

TypeScript
const r = await fetch("https://api.plugsky.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.PLUGSKY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ model: "plugsky-pro", messages: [{ role: "user", content: "Hi" }] }),
});
const data = await r.json();
console.log(data.choices[0].message.content);

Tool calling

TypeScript
const tools = [{
  type: "function",
  function: {
    name: "get_weather",
    description: "Get weather for a city",
    parameters: { type: "object", properties: { city: { type: "string" } }, required: ["city"] },
  },
}];
const r = await client.chat.completions.create({
  model: "plugsky-pro",
  messages: [{ role: "user", content: "Weather in Dubai?" }],
  tools,
});
console.log(r.choices[0].message.tool_calls);

Embeddings

TypeScript
const r = await client.embeddings.create({ model: "plugsky-embed", input: "hello world" });
console.log(r.data[0].embedding.length); // 2048

Limits and gotchas

Main text models: 262,144-token context; plugsky-mistral-medium and vision models: 131,072; plugsky-translate: 32,768; embeddings: 8,192 input. Builder: 256K input / 32K output per request; Scale: 512K input / 32K output. Concurrency: Builder 10 / 600 RPM, Scale 16 / 1,200 RPM, Hobby 4 / 120 RPM. Cap max_tokens at the plan output ceiling.

Common errors

  • 401: missing, revoked or wrong-host key.
  • 404: wrong base URL path or unknown model ID.
  • 400 (context): input plus reserved output exceeds the window.
  • 429: RPM, concurrency or daily quota exhausted.
  • 5xx: server or upstream failure; retry with backoff.

Production checklist

  • Pin SDK and model versions; read keys from environment or a secret manager.
  • Set explicit timeouts and retries; handle streaming errors.
  • Cap max_tokens; log request IDs, model ID, usage and latency.
  • Test 429 and context-overflow paths before launch.

What we did not verify

  • We did not benchmark latency or throughput.
  • We did not test every SDK helper.
  • We used https://api.plugsky.com/v1; confirm the host in your account docs.

Frequently asked questions

How do I call Plugsky from Node.js?

Install the openai package, create a client with apiKey and baseURL 'https://api.plugsky.com/v1', then call client.chat.completions.create with a plugsky-* model ID.

Does the SDK work with ESM and CommonJS?

Yes. The openai package supports both module systems in recent Node versions.

Does streaming work in Node?

Yes. Set stream: true and iterate with for await...of; empty text deltas are normal.

Does tool calling work?

Yes via the tools parameter with standard OpenAI function schemas.

What embedding dimensions should I expect?

2,048 dimensions with an 8,192-token input window.

How do I fix a 401 or 404?

Confirm the key and host api.plugsky.com; use https://api.plugsky.com/v1 and a model ID from GET /v1/models.

Can I use raw fetch instead?

Yes. The API is plain HTTPS JSON, so fetch with an Authorization header works without the SDK.

Related pages

Run your Node service on Plugsky

Start free, test your request path, then choose the plan that matches your concurrency.

Start Free → Read the docs

Sources

SDK behaviour was checked against the official OpenAI Node repository on 20 November 2026. Plugsky limits were checked against its docs on the same date.

Official pages used for this integration guide
SourcePage checkedChecked
OpenAIopenai/openai-node20 Nov 2026
Plugskyplugsky.com/docs and plugsky.com/pricing20 Nov 2026
Plugskyplugsky.com/models20 Nov 2026

Last checked 20 November 2026. Plugsky's canonical plan numbers live at /pricing; this page explains the integration and does not replace the plan terms.

Sources and dated checks

Checked 20 November 2026. Primary sources checked 20 November 2026: OpenAI API reference, Anthropic API getting started, Cloudflare Workers AI. Confirm current limits and pricing in the provider console before capacity planning.