$LLMZone Docs

Node.js / TypeScript

Use the OpenAI Node.js SDK or plain fetch with our API

Installation

npm install openai
index.ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://api.llmzone.net/v1",
});

async function main() {
  const response = await client.chat.completions.create({
    model: "claude-opus-4-6",
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "Hello!" },
    ],
  });

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

main();

Streaming (Node.js)

stream.ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://api.llmzone.net/v1",
});

async function main() {
  const stream = await client.chat.completions.create({
    model: "claude-opus-4-6",
    messages: [{ role: "user", content: "Hello!" }],
    stream: true,
  });

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

main();

Plain fetch (No SDK)

fetch.ts
const response = await fetch("https://api.llmzone.net/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-opus-4-6",
    messages: [{ role: "user", content: "Hello!" }],
  }),
});

const data = await response.json();
console.log(data.choices[0].message.content);

On this page