UniterRouter

Authentication

Complete guide to UniterRouter API authentication. Learn how to generate API keys, implement secure Bearer token auth, and protect your LLM API requests with best practices.

Authentication

All API requests to UniterRouter require authentication using an API key. This guide covers how to obtain and use your API key securely.

Obtaining an API Key

  1. Sign in to the UniterRouter Dashboard
  2. Navigate to your Project → API Keys
  3. Click Create API Key
  4. Copy the key immediately — it will only be shown once

Security Note: Your API key is a secret credential. Never expose it in client-side code, public repositories, or share it with others.

Using Your API Key

Include your API key in the Authorization header of every request using the Bearer token format:

Authorization: Bearer YOUR_API_KEY

Example Request

curl https://api.uniterouter.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $UNITEROUTER_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.uniterouter.ai/v1",
    api_key=os.environ.get("UNITEROUTER_API_KEY"),
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.uniterouter.ai/v1",
  apiKey: process.env.UNITEROUTER_API_KEY,
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
});
package main

import (
    "context"
    "os"
    openai "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig(os.Getenv("UNITEROUTER_API_KEY"))
    config.BaseURL = "https://api.uniterouter.ai/v1"
    client := openai.NewClientWithConfig(config)

    resp, _ := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "gpt-4o",
            Messages: []openai.ChatCompletionMessage{
                {Role: "user", Content: "Hello!"},
            },
        },
    )
}

Environment Variables

We recommend storing your API key in environment variables:

# Add to your shell profile (.bashrc, .zshrc, etc.)
export UNITEROUTER_API_KEY="sk_..."

For production applications, use a secrets manager or environment configuration provided by your deployment platform.

API Key Formats

UniterRouter API keys follow this format:

PrefixDescription
sk_Standard API key
sk_test_Test environment key (if applicable)

Authentication Errors

If authentication fails, the API returns a 401 Unauthorized response:

{
  "error": {
    "message": "Incorrect API key provided. You can find your API key at https://uniterouter.ai/dashboard.",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

Common authentication issues:

IssueSolution
Missing Authorization headerAdd the header with your API key
Invalid key formatEnsure the key starts with the correct prefix
Expired or revoked keyGenerate a new key in the dashboard
Key belongs to disabled projectRe-enable the project or use a different key

Security Best Practices

Recommended Security Practices

  1. Never hardcode API keys — Use environment variables or secrets managers
  2. Rotate keys periodically — Create new keys and deprecate old ones
  3. Use separate keys per environment — Different keys for development, staging, and production
  4. Set usage limits — Configure spending limits on each API key
  5. Monitor usage — Regularly review API key activity in the dashboard
  6. Revoke compromised keys immediately — If a key is exposed, disable it and create a new one

Organization & Project Structure

UniterRouter uses a hierarchical structure for access management:

Organization
└── Project
    └── API Keys
  • Organization: Your top-level account
  • Project: A logical grouping of API keys and settings
  • API Key: Credentials scoped to a specific project

Each API key inherits the permissions and settings of its parent project.

Next Steps

How is this guide?