← Back to Setup

Build an app with the Chat Completions API

Understand the request shape, authentication, and model selection for a custom chat application.

Three connection values

Your backend needs the UnsavedAI base URL ending in /v1, an API key, and an available model ID. Send POST requests to the base URL plus /chat/completions, with Authorization: Bearer YOUR_KEY and Content-Type: application/json.

The request body

Send a model string, a messages array containing role and content objects, and a max_tokens output limit. Set stream to true for incremental output.

Supported settings

These sampler settings are passed to the model: temperature (0 or more), top_p (above 0, up to 1), top_k (-1 or 0 for off, or a whole number), min_p (0 to 1), repetition_penalty (above 0, where 1 is off), presence_penalty and frequency_penalty (-2 to 2), seed, and stop. max_tokens is capped at your lane's output limit. A value outside these ranges returns an error naming the setting. Other fields, such as logit_bias, are ignored rather than rejected, so SillyTavern and JanitorAI presets work without editing.

Keep keys on the backend

Never bundle the account key into a public website or mobile application. Authenticate your own users and call UnsavedAI from your backend. Give development and production separate named keys so you can revoke one without replacing the other.

Next step

Get your values on Setup, check the models, or make a key in your account.