Skip to main content
Welcome to Hicap. Our guided onboarding will walk you through everything you need to start leveraging your network and making the most of your resources.

Install the OpenAI SDK and Run an API Call

To use the Hicap API in server-side JavaScript environments like Node.js, Deno, or Bun, you can use the official OpenAI SDK for TypeScript and JavaScript. Get started by installing the SDK using npm or your preferred package manager:
Install the OpenAI SDK with npm
npm install openai
With the OpenAI SDK installed, create a file called example.mjs and copy the example code into it:
example.mjs
import OpenAI from "openai";

const apiKey = "YOUR-API-KEY";

const client = new OpenAI({
  baseURL: "https://api.hicap.ai/v2/openai",
  apiKey: apiKey,
  defaultHeaders: { "api-key": apiKey },
});

const response = await client.chat.completions.create({
  model: "gpt-5",
  messages: [{
    role: "user",
    content: "Hello World",
    name: "developer"
  }],
});

console.log(response.choices[0].message.content);
Execute the code with node example.mjs (or the equivalent command for Deno or Bun). In a few moments, you should see the output of your API request.