Integrations

Node.js and TypeScript

Call the Apertis API from Node.js or TypeScript with the OpenAI SDK.

Updated
Reading time
1 min

On this page

Send a chat completion to Apertis from a Node.js script, using the OpenAI Node SDK.

Install

npm install openai
npm install -D tsx typescript

Set your API key

Create a key in Settings → API Keys, then export it:

export APERTIS_API_KEY="sk-your-api-key"

Minimal script

index.mts:

import OpenAI from "openai";

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

const completion = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [{ role: "user", content: "Hello! What can you do?" }],
});

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

The .mts extension makes the file an ES module, which the top-level await needs; a .ts file in a project without "type": "module" fails to run. For plain JavaScript, save the same code as index.mjs and run it with node index.mjs.

Run

npx tsx index.mts

The SDK sends Authorization: Bearer with your key to https://api.apertis.ai/v1. Pick any model ID from the Models page.

Next steps