Documentation
Everything you need to integrate the Tuori Cloud API, from your first request to production-grade retries, streaming, tools, and monitoring.
Introduction
Tuori Cloud provides a unified, OpenAI-compatible API for model inference. One endpoint and one API key can be used across supported commercial and open models.
https://api.tuori.cloud/v1Use familiar chat completions, streaming, messages, and tool-calling formats.
Manage scoped keys, budgets, and environments from one account.
Configure timeouts, retries, rate limits, and fallback behavior.
Quickstart
- Create an API key.
Generate a development key and store it as
TUORI_API_KEY. Never expose secret keys in browser code. - Install the SDK.
pip install openai - Send your first request.Python
from openai import OpenAI import os client = OpenAI( api_key=os.environ["TUORI_API_KEY"], base_url="https://api.tuori.cloud/v1", timeout=30.0, max_retries=2, ) response = client.chat.completions.create( model="your-model-id", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain vector databases in one paragraph."} ], ) print(response.choices[0].message.content) - Inspect usage and request IDs.
Record token usage, latency, status code, and the response request ID for support and debugging.
Authentication
Send your secret key as a Bearer token. Use separate keys for development and production, apply least-privilege scopes, and rotate keys regularly.
Authorization: Bearer $TUORI_API_KEY
Content-Type: application/jsonAPI keys must only be used from trusted server-side environments. A client-side form or website should call your own backend, which then calls Tuori Cloud.
SDKs
openai package with base_url configured.
openai package with baseURL configured.
Direct HTTPS requests from any server-side language.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TUORI_API_KEY,
baseURL: "https://api.tuori.cloud/v1",
timeout: 30_000,
maxRetries: 2,
});
const response = await client.chat.completions.create({
model: "your-model-id",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);Streaming
Enable streaming for lower perceived latency. Accumulate content deltas and handle disconnects gracefully.
stream = client.chat.completions.create(
model="your-model-id",
messages=[{"role": "user", "content": "Write a short launch announcement."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)Tool Calling
Declare tools with JSON Schema, execute validated tool calls in your application, then return tool results to the model. Never execute untrusted arguments without validation.
Retries and Timeouts
Retry rate-limit and transient server errors with exponential backoff and jitter. Do not retry invalid authentication or malformed requests.
| Status | Action |
|---|---|
| 408 / 429 | Retry with backoff and respect Retry-After. |
| 500 / 502 / 503 / 504 | Retry a limited number of times. |
| 400 / 401 / 403 / 404 | Fix the request or credentials; do not blindly retry. |
cURL Example
curl https://api.tuori.cloud/v1/chat/completions \
-H "Authorization: Bearer $TUORI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model-id",
"messages": [{"role": "user", "content": "Hello"}],
"temperature": 0.2
}'Error Codes
| Code | Meaning | Recommended response |
|---|---|---|
| 400 | Invalid request | Validate parameters and JSON. |
| 401 | Authentication failed | Check or rotate the API key. |
| 403 | Permission denied | Review key scopes and account access. |
| 404 | Model or endpoint not found | Check the model ID and path. |
| 429 | Rate or budget limit reached | Back off or increase limits. |
| 5xx | Temporary service error | Retry with backoff and capture the request ID. |
Rate Limits
Limits may be enforced by requests per minute, tokens per minute, concurrent requests, or budget. Keep concurrency bounded and use a queue for bursty workloads.
