Getting Started

This guide explains what MultiRoute is, how authentication works, and how to send your first chat completion request in minutes.

Prerequisites

Before you begin:

Authentication and base URL

All requests are made over HTTPS to:

https://api.multiroute.ai/v1

Authenticate with a bearer API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Keep your API key secret — store it in environment variables or a secret manager, not in source control. Use separate keys for development, staging, and production when possible.

For local development, export your key:

export MULTIROUTE_API_KEY="sk_your_api_key_here"

On Windows PowerShell:

$env:MULTIROUTE_API_KEY="sk_your_api_key_here"

In code, read the key from MULTIROUTE_API_KEY and send:

Authorization: Bearer $MULTIROUTE_API_KEY

Your first chat completion

The examples below call POST /v1/chat/completions with a minimal message body:

{
  "model": "gpt-4o",
  "messages": [
    { "role": "user", "content": "Say hello from MultiRoute." }
  ]
}

Supported models and capabilities are documented in the Models catalog.

import os
import requests

api_key = os.getenv("MULTIROUTE_API_KEY")
if not api_key:
  raise RuntimeError("MULTIROUTE_API_KEY is not set")

url = "https://api.multiroute.ai/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json",
}

payload = {
    "model": "gpt-4o",
    "messages": [
        {"role": "user", "content": "Say hello from MultiRoute."},
    ],
}

response = requests.post(url, headers=headers, json=payload, timeout=30)

response.raise_for_status()
print(response.json())
const apiKey = process.env.MULTIROUTE_API_KEY;

if (!apiKey) {
  throw new Error("MULTIROUTE_API_KEY is not set");
}

async function main() {
  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: "gpt-4o",
      messages: [
        { role: "user", content: "Say hello from MultiRoute." },
      ],
    }),
  });

  if (!response.ok) {
    console.error("Request failed:", response.status, await response.text());
    return;
  }

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
curl -X POST https://api.multiroute.ai/v1/chat/completions \
  -H "Authorization: Bearer $MULTIROUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      { "role": "user", "content": "Say hello from MultiRoute." }
    ]
  }'

Next steps