Platform — settings here apply to all tenants

LLM proxy

Integration docs

Use the gateway as an OpenAI-compatible chat completions endpoint. Caller keys stay in your server environment. The requested model is a route model that selects one or more provider routes from Admin.

Endpoint

Production
https://sites.yuanzhixiang.com/api/ai/v1/chat/completions
Local dev
http://localhost:3000/api/ai/v1/chat/completions

Local requests should go through the frontend proxy so the tenant domain is injected before the API worker resolves tenant context.

Auth
Authorization: Bearer sk-...

Request body

messages
Required

Must be an OpenAI-compatible messages array.

stream
Supported

Set stream: true to receive upstream SSE.

model
Required

Must match a configured route model in LLM models.

curl

curl https://sites.yuanzhixiang.com/api/ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-..." \
  -d '{
    "model": "gemini-3-5-flash",
    "messages": [
      { "role": "user", "content": "Write a one-line product tagline." }
    ]
  }'

Node OpenAI SDK

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SITES_LLM_API_KEY,
  baseURL: "https://sites.yuanzhixiang.com/api/ai/v1",
});

const completion = await client.chat.completions.create({
  model: "gemini-3-5-flash",
  messages: [
    { role: "user", content: "Write a one-line product tagline." },
  ],
});

console.log(completion.choices[0]?.message?.content);

Python OpenAI SDK

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ["SITES_LLM_API_KEY"],
    base_url="https://sites.yuanzhixiang.com/api/ai/v1",
)

completion = client.chat.completions.create(
    model="gemini-3-5-flash",
    messages=[
        {"role": "user", "content": "Write a one-line product tagline."}
    ],
)

print(completion.choices[0].message.content)

Errors

OpenAI-style error shape

{
  "error": {
    "message": "Invalid API key.",
    "type": "authentication_error",
    "param": null,
    "code": "invalid_api_key"
  }
}
missing_api_keyinvalid_api_keyinvalid_jsoninvalid_messagesinvalid_modelmodel_not_configuredupstream_errorupstream_timeout