Quickstart
Make your first API call to Unii in under five minutes.
Prerequisites
Before you begin, make sure you have the following:
- A Unii account and API key (see Authentication for details)
- Node.js 18+ for the TypeScript SDK, or Python 3.9+ for the Python SDK
Note
Check your runtime version with node --version or
python --version. Older versions may not support the latest SDK
features.
Get your API key
You need an API key to authenticate requests. Generate one from the Unii Developer Console by signing in, navigating to Settings, and creating a new key.
Store the key in an environment variable so you don't accidentally commit it to version control:
UNII_API_KEY=sk_unii_your_api_key_hereWarning
Never hardcode API keys in your source code. Use environment variables or a secrets manager to keep credentials secure.
Install the SDK
Install the Unii SDK using your preferred package manager:
npm install @unii/sdkTip
TypeScript types are included with the SDK — no additional @types
package is needed.
Make your first request
Send a chat completion request to the Unii API. The examples below use the
illustrative endpoint POST /v1/chat/completions.
import { Unii } from "@unii/sdk";const client = new Unii({apiKey: process.env.UNII_API_KEY,});const response = await client.chat.completions.create({model: "unii-latest",messages: [{ role: "user", content: "Explain RAG in one sentence." }],});console.log(response.choices[0].message.content);Sample response
A successful response returns a JSON object with the generated text:
{"id": "chatcmpl-abc123","object": "chat.completion","model": "unii-latest","choices": [ { "index": 0, "message": { "role": "assistant", "content": "RAG (Retrieval-Augmented Generation) combines a knowledge base lookup with an LLM to produce answers grounded in your own documents." }, "finish_reason": "stop" }],"usage": { "prompt_tokens": 15, "completion_tokens": 28, "total_tokens": 43}}Troubleshooting
If your request fails, check the following common issues:
- 401 Unauthorized — Your API key is missing, expired, or invalid. Verify
that
UNII_API_KEYis set correctly and try generating a new key from the console. - 429 Too Many Requests — You've exceeded the rate limit. Wait a moment and retry, or contact support to discuss higher limits.
- Invalid model — The model name you specified doesn't exist. Use
unii-latestor check the API Reference for available models.
Important
The API examples on this page are illustrative. Verify the actual request format, response structure, and available models against the latest API Reference before using them in production.
Next steps
- Learn how to authenticate your API requests in detail.
- Read the API Reference for complete endpoint documentation.
- Explore knowledge bases to ground responses in your own data.
- Try streaming for real-time responses.