Authentication

Overview

All requests to the MultiRoute API must be authenticated. This page describes:

OAuth (e.g. sign-in with Google, Apple, or GitHub) is used for dashboard access and account management; for programmatic calls to the /v1 API, use API keys.

API key authentication

The most common way to access the MultiRoute API is with an API key. API keys are opaque strings issued by MultiRoute and should be treated like passwords.

Authorization: Bearer mrk_live_************************

Example: cURL

curl https://api.multiroute.ai/v1/chat/completions \
  -H "Authorization: Bearer $MULTIROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "multiroute-chat-latest",
    "messages": [
      { "role": "user", "content": "Hello from MultiRoute!" }
    ]
  }'

Example: Node / TypeScript

const apiKey = process.env.MULTIROUTE_API_KEY!;

const response = await fetch("https://api.multiroute.ai/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "multiroute-chat-latest",
    messages: [{ role: "user", content: "Hello from MultiRoute!" }],
  }),
});

Example: Python

import os
import requests

API_KEY = os.environ.get("MULTIROUTE_API_KEY")

resp = requests.post(
    "https://api.multiroute.ai/v1/chat/completions",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
    },
    json={
        "model": "multiroute-chat-latest",
        "messages": [{"role": "user", "content": "Hello from MultiRoute!"}],
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())

JWT-based authentication

In addition to API keys, some administrative and dashboard-related endpoints (such as /v1/config and /v1/api-keys) may accept JWT access tokens issued by MultiRoute.

These tokens are generally:

You pass a JWT in the same Authorization header:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

The exact flows for obtaining JWTs (e.g., OAuth2 device code, web login, or service account credentials) depend on how your MultiRoute deployment is configured.

Best practices

Troubleshooting authentication

If authentication fails, you will typically see:

Refer to Errors & retry guidance for more details on error formats and recommended handling.