> ## Documentation Index
> Fetch the complete documentation index at: https://docs.animusai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API Quickstart

> Get started with the Animus REST API in minutes. Learn how to authenticate and make your first API call.

<Tip>
  **New to Animus?** If you're building a JavaScript/TypeScript browser application, consider our [SDK Quickstart](/sdk-quickstart) for a faster, easier integration experience with built-in conversation management.
</Tip>

## Create and export an API key

Create an API key in the [dashboard](https://platform.animusai.co/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.

<CodeGroup>
  ```bash macOS/Linux theme={null}
  export ANIMUS_API_KEY="your_api_key_here"
  ```

  ```powershell Windows theme={null}
  $env:ANIMUS_API_KEY="your_api_key_here"
  ```
</CodeGroup>

## 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:

<CodeGroup>
  ```bash npm theme={null}
  npm install openai
  ```

  ```bash yarn theme={null}
  yarn add openai
  ```

  ```bash pnpm theme={null}
  pnpm add openai
  ```
</CodeGroup>

### Create a conversational request

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

```javascript theme={null}
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:

```bash theme={null}
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:

<CodeGroup>
  ```bash cURL theme={null}
  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?"}
      ]
    }'
  ```

  ```python Python theme={null}
  import requests
  import os

  url = "https://api.animusai.co/v2/chat/completions"
  headers = {
      "Content-Type": "application/json",
      "Authorization": f"Bearer {os.getenv('ANIMUS_API_KEY')}"
  }

  payload = {
      "model": "vivian-llama3.1-70b-1.0-fp8",
      "messages": [
          {"role": "system", "content": "You are a thoughtful and understanding companion."},
          {"role": "user", "content": "I'm going through some changes in my life and could use some perspective."}
      ]
  }

  response = requests.post(url, headers=headers, json=payload)
  data = response.json()
  print(data['choices'][0]['message']['content'])
  ```

  ```javascript JavaScript (Fetch) theme={null}
  const response = await fetch('https://api.animusai.co/v2/chat/completions', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${process.env.ANIMUS_API_KEY}`
    },
    body: JSON.stringify({
      model: "vivian-llama3.1-70b-1.0-fp8",
      messages: [
        { role: "system", content: "You are a warm and encouraging friend." },
        { role: "user", content: "I accomplished something today that I'm really proud of!" }
      ]
    })
  });

  const data = await response.json();
  console.log(data.choices[0].message.content);
  ```
</CodeGroup>

## Next steps

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

<CardGroup cols={2}>
  <Card title="Explore Our Models" icon="brain" href="/models/overview">
    Learn about the different models available and their capabilities
  </Card>

  <Card title="Text Generation" icon="message" href="/rest-api-integration/text-generation">
    Dive deeper into generating text with our models
  </Card>

  <Card title="Vision" icon="eye" href="/rest-api-integration/vision">
    Understand how to use our models for visual tasks
  </Card>

  <Card title="Image Generation" icon="image" href="/rest-api-integration/image-generation">
    Generate, edit, and manage visual assets with the media API
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore the complete API reference documentation
  </Card>
</CardGroup>

## Compare with SDK

<CardGroup cols={2}>
  <Card title="Try the SDK" icon="rocket" href="/sdk-quickstart">
    For JavaScript/TypeScript apps, our SDK provides automatic conversation management
  </Card>

  <Card title="Choose Your Path" icon="map" href="/choose-your-path">
    Compare SDK vs REST API approaches for your use case
  </Card>
</CardGroup>

<Tip>
  **Building a JavaScript application?** Consider using our [SDK](/sdk-quickstart) for automatic authentication, conversation history, streaming, and event handling with just a few lines of code.
</Tip>
