New to Animus? If you’re building a JavaScript/TypeScript browser application, consider our SDK Quickstart for a faster, easier integration experience with built-in conversation management.

Create and export an API key

Create an API key in the dashboard, which you’ll use to securely access the API. Store the key in a safe location, like a .zshrc file or another text file on your computer. Once you’ve generated an API key, export it as an environment variable in your terminal.

export ANIMUS_API_KEY="your_api_key_here"

Make your first API request

With your Animus API key exported as an environment variable, you’re ready to make your first API request. You can either use the REST API directly with the HTTP client of your choice, or use the OpenAI SDK as shown below.

Install the OpenAI SDK

To use the Animus 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:

npm install openai

Create a conversational request

With the OpenAI SDK installed, create a file called example.mjs and copy the following example into it:

import OpenAI from "openai";

const openai = new OpenAI({
  baseURL: "https://api.animusai.co/v2",
  apiKey: process.env.ANIMUS_API_KEY,
});

const completion = await openai.chat.completions.create({
  model: "vivian-llama3.1-70b-1.0-fp8",
  messages: [
    { role: "system", content: "You are a warm and empathetic companion." },
    {
      role: "user",
      content: "Hey there! I've had a really long day and could use someone to talk to.",
    },
  ],
});

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

Run your example

Run the example using Node.js:

node example.mjs

You should see a response like:

{
  role: 'assistant',
  content: 'I'm so glad you reached out! I'm here for you. Long days can be really draining - would you like to tell me what made today particularly challenging? Sometimes just talking through it can help lighten the load a bit.'
}

Direct HTTP Requests

You can also make requests directly using any HTTP client. Here are examples in different languages:

curl https://api.animusai.co/v2/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ANIMUS_API_KEY" \
  -d '{
    "model": "vivian-llama3.1-70b-1.0-fp8",
    "messages": [
      {"role": "system", "content": "You are a caring and supportive friend."},
      {"role": "user", "content": "I'\''ve been feeling a bit overwhelmed lately. Can we talk?"}
    ]
  }'

Next steps

Congratulations, you’ve made your first API request! Here are some next steps to explore:

Compare with SDK

Building a JavaScript application? Consider using our SDK for automatic authentication, conversation history, streaming, and event handling with just a few lines of code.