Lain OS exposes an OpenAI-compatible API. Point any OpenAI SDK at it — just change the base URL and API key.
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
GET https://lain-os.com/v1/models
curl https://lain-os.com/v1/chat/completions \
-H "Authorization: Bearer lain_xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "lain-free",
"messages": [
{"role": "user", "content": "Hello"}
]
}'
from openai import OpenAI
client = OpenAI(
api_key="lain_xxx",
base_url="https://lain-os.com/v1",
)
response = client.chat.completions.create(
model="lain-free",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
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: "lain-free",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);
Run lain and paste your API key when it asks — it's saved for next time. To set it by hand instead, put this in the TUI's .env:
LAINOS_MODEL_PROVIDER=lain LAIN_API_KEY=lain_xxx