Prerequisite Our SDK @undrstnd/ai-engine is still in beta.

Setting up Your Development Environment

Install Dependencies

To begin, ensure you have the required dependencies installed:

  • Node.js (v18 or higher)
  • npm (v7 or higher) or Yarn (v1.22 or higher) or pnpm (v6 or higher) for package management
  • AI Engine SDK (v3.0.0 or higher) for AI models

API Key Configuration

You get 3 EUR free credit when you sign up. You can use this credit to test our AI models.

Before making any API calls, you need an API key.

  1. Sign up for an account.
  2. Go to the API key page and create a new API key.
  3. Copy the API key and save it in a secure location. Store the API key securely in your environment variables. Here’s an example for Node.js:
.env.local
UNDRSTND_API_KEY='your_api_key_here'

API Usage for Specific Frameworks

Next.js users can make use of API routes:

async function callAI() {
  const response = await
  fetch(`https://dev.undrstnd-labs.com/api/v1/chat/completions`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer api_key_here",
    },
    body: JSON.stringify({
      stream: false,
      modelId: "mixtral-8x7b-32768",
      max_tokens: 2500,
      messages: [
        {
          name: "system",
          content: "Hello, how can I help you?",
          role: "system",
        },
        {
          name: "user",
          content: "Say a song name",
          role: "user",
        },
      ],
    }),
  })

  if (!response.ok) {
  return { error: response.statusText }
  }

  return response.json()
}

Authorization

Authorization
string
required

The API key to authenticate the request.

Response fields

stream
boolean
required

A boolean value that indicates whether the response is a stream.

modelId
string
required

The model ID to use for the AI model.

max_tokens
integer

The max_tokens field specifies the maximum number of tokens that the AI model can generate in a single response. This helps control the length of the output. If not provided, the model will default to 512 tokens. Adjust this value based on the desired length of the response or the constraints of your application.

messages
array
required

An array of messages to send to the AI model.