TypeScript API

The Hyperbolic API provides compatibility for the OpenAI API standard, allowing easier integrations into existing applications.

Requirements

Install OpenAI's TypeScript SDK:

npm install openai

Example code

Simply replace the api_key and base_url to the Hyperbolic ones in your project.

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: HYPERBOLIC_API_KEY,
  baseURL: 'https://api.hyperbolic.xyz/v1',
});

async function main() {
  const response = await client.chat.completions.create({
    messages: [
      {
        role: 'system',
        content: 'You are an expert travel guide.',
      },
      {
        role: 'user',
        content: 'Tell me fun things to do in San Francisco.',
      },
    ],
    model: 'meta-llama/Meta-Llama-3-70B-Instruct',
  });

  const output = response.choices[0].message.content;
  console.log(output);
}

main();