Stability first
TrexAPI performs authentication, rate, quota, and account-state checks before routing. The platform protects stability instead of allowing unbounded traffic by default.
TrexAPI provides an OpenAI-compatible API, model routing, multi-provider fallback, API key management, basic logs, and subscription-state controls. The goal is to give your app a stable AI fallback interface.
Complexity moves into the platform layer: authentication, rate limits, quota, routing, fallback, billing, and risk controls are handled by Trex.
TrexAPI performs authentication, rate, quota, and account-state checks before routing. The platform protects stability instead of allowing unbounded traffic by default.
Clients call one OpenAI-compatible endpoint while provider choice, model catalog, and fallback plans stay in the Trex control plane.
Smart Auto uses daily quota. Premium, pinned providers, long context, and high concurrency use Compute Credits.
Works with the OpenAI SDK, compatible clients, and direct HTTP calls.
Create a Trex API key.
Set the OpenAI-compatible client `baseURL` to `https://api.trexapi.com/v1`.
Replace `apiKey` with the Trex key.
Bind provider keys in the dashboard, or use the managed route configured for your account.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TREX_API_KEY,
baseURL: "https://api.trexapi.com/v1",
});
const response = await client.chat.completions.create({
model: "smart-auto",
messages: [
{ role: "user", content: "Summarize today's incident handoff." }
],
});
console.log(response.choices[0].message.content);from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["TREX_API_KEY"],
base_url="https://api.trexapi.com/v1",
)
response = client.chat.completions.create(
model="smart-auto",
messages=[
{"role": "user", "content": "Summarize today's incident handoff."}
],
)
print(response.choices[0].message.content)`GET /v1/models` returns the model catalog available to the current Trex key. Non-streaming requests can declare fallbacks; Trex retries fallback paths on retryable failures such as network errors, 429, 502, 503, and 504.
curl https://api.trexapi.com/v1/models \
-H "Authorization: Bearer $TREX_API_KEY"const response = await fetch("https://api.trexapi.com/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TREX_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Write a short status update." }],
trex: {
routing: {
fallbacks: [
{ provider: "openrouter", model: "openai/gpt-4o-mini" }
]
}
}
}),
});
console.log(response.headers.get("X-Trex-Upstream-Provider"));Use the dashboard to manage API keys, provider bindings, subscriptions, quota, and basic logs.