Building a Chat Assistant on an OpenAI-Compatible API
Connect an existing OpenAI SDK to the Orux AI endpoint, select a chat model, and handle common API errors.
Models available now
Browse full catalogWhat you'll build
Send a chat completion request from the OpenAI SDK to the Orux AI OpenAI-compatible API. The model alias and optional request fields must match a model available in the live catalog.
1. Choose a chat model and create a key
Browse chat models, open a model detail page to confirm supported fields and current prices, then create an API key from Keys.
2. Send a completion request
import OpenAI from "openai"
const client = new OpenAI({
baseURL: "https://orux.top/api/v1",
apiKey: process.env.ORUX_API_KEY,
})
const response = await client.chat.completions.create({
model: "YOUR_CHAT_MODEL_ALIAS",
messages: [{ role: "user", content: "Explain database indexes to a junior developer." }],
})
console.log(response.choices[0].message.content)Replace the placeholder with a configured chat model alias. Some models may support additional options; check their detail pages before using them.
Common API responses
- HTTP 401 — check that the API key is present, valid, and sent as a Bearer token.
- HTTP 402 — the account balance is insufficient; review the balance page.
- HTTP 429 — slow down requests and retry with exponential backoff and jitter.
Usage and cost
Review request history and charges in the usage page. Check the pricing page for current model rates and unit definitions.
Next steps
Try a chat model in its detail page, compare current prices in the catalog, and review the API quickstart.