Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.llmgrid.ai/llms.txt

Use this file to discover all available pages before exploring further.

Node.js / TypeScript (OpenAI SDK pointed to LLMGrid)

The official OpenAI JavaScript/TypeScript SDK supports setting baseURL when creating the client.
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LLMGRID_API_KEY!,
  baseURL: "https://api.llmgrid.ai/v1",
});

const response = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [{ role: "user", content: "Hello from Node.js via LLMGrid" }],
});

console.log(response.choices[0].message.content);
``
Streaming
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.LLMGRID_API_KEY!,
  baseURL: "https://api.llmgrid.ai/v1",
});

const stream = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [{ role: "user", content: "Stream a short explanation of RAG." }],
  stream: true,
});

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