JavaScript / TypeScript

Use the standard OpenAI Node.js SDK with aihubspot — just set baseURL to our endpoint.

Installation

aihubspot is fully OpenAI-compatible. Use the official OpenAI SDK — no new package needed.

npm install openai

Setup

import OpenAI from 'openai';
 
const client = new OpenAI({
  apiKey: process.env.AH_API_KEY,
  baseURL: 'https://api.aihubspot.app/v1',
});

Quick start

const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello' }],
});
 
console.log(response.choices[0].message.content);

Streaming

const stream = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});
 
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}

Any code that already uses the OpenAI SDK works without changes — just add baseURL: 'https://api.aihubspot.app/v1' and use your aihubspot key.