API Documentation

Lain OS exposes an OpenAI-compatible API. Point any OpenAI SDK at it — just change the base URL and API key.

Base URL & Authentication

Every request needs your Lain API key (create one from your dashboard) as a Bearer token.

Base URL:      https://lain-os.com/v1
Authorization: Bearer lain_xxxxxxxxxxxxxxxxxxxx

List models

GET https://lain-os.com/v1/models

curl

curl https://lain-os.com/v1/chat/completions \
+  -H "Authorization: Bearer lain_xxx" \
+  -H "Content-Type: application/json" \
+  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="lain_xxx",
    base_url="https://lain-os.com/v1",
)

response = client.chat.completions.create(
    model="anthropic/claude-haiku-4.5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

JavaScript (openai SDK)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "lain_xxx",
  baseURL: "https://lain-os.com/v1",
});

const response = await client.chat.completions.create({
  model: "anthropic/claude-haiku-4.5",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);

Lain OS TUI

To point the Lain OS TUI at this API, set in its .env:

LAINOS_MODEL_PROVIDER=openrouter
OPENROUTER_API_KEY=lain_xxx
OPENROUTER_BASE_URL=https://lain-os.com/v1