Skip to documentation

JavaScript and TypeScript

Use the official OpenAI SDK from a server-side application.

Updated November 3, 2026

Before you begin

Open a fresh terminal, configure a scoped key and list the models available to your account before using the client. The shared setup includes Bash and PowerShell commands.

Install and configure

Install the official openai npm package. Run this example in Node.js, never a public browser bundle. Read credentials from the server environment and choose an alias returned by the authenticated model list.

Handle uncertain requests

Disable automatic transport retries unless you deliberately implement idempotency. Record HTTP status, error code and request ID without logging keys or prompts. A connection timeout does not prove that upstream work or billing stopped.

Client configuration

Select a published model to generate configuration. Confirm your account can use it with GET /v1/models before sending a request.

javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.NOTHOLY_API_KEY,
  baseURL: 'https://api.notholy.com/v1',
  maxRetries: 0,
});
const response = await client.chat.completions.create({
  model: "notholy-pulse",
  messages: [{role: 'user', content: 'Explain least privilege.'}],
  max_tokens: 2048,
});
console.log(response.choices[0].message.content);

Configuration reference: a generated snippet is not a full client certification. Check the compatibility notes above. Keep API keys in your private environment.