Chat completions
Chat completions are the core of SAGEA Studio — send a list of messages, get back a model reply you can render, speak, or pipe into tools.
In this guide
- Use
system,user,assistant, andtoolroles to steer behavior - Choose between
sage-2-4-actus,sage-2-5-celer, andsage-oss - Tune
temperatureandmax_tokensfor factual vs creative tasks - Trim multi-turn history without losing context
Shape conversations with roles
Every request is a list of messages. The system message sets the persona and ground rules, user messages carry new input, assistant messages preserve history, and tool messages return function results.
Use a Nepali-first system prompt for support bots so the model defaults to ne-NP while still handling English or Nepali-English code-switching.
Keep the system prompt stable across turns. Put per-request facts — order IDs, branch names, user locale — in the latest user message or a tool message instead.
For full field schemas, see the Chat Completions reference.
Pick the right model
All three chat models share the same API shape, so you can switch with one string change.
| Model | Best for | Context window |
|---|---|---|
sage-2-4-actus | Reasoned support, Nepali nuance, tool use | 128k tokens |
sage-2-5-celer | Low-latency chat, classification, drafts | 32k tokens |
sage-oss | Private or offline-friendly workloads | 16k tokens |
Start with sage-2-4-actus for customer-facing Nepali bots. Move high-volume, simple turns to sage-2-5-celer once prompts are stable. Reach for sage-oss when you need a self-hostable fallback with the same message format.
Compare trade-offs in Choosing a model.
Tune temperature for the task
temperature controls randomness. Low values stick to the source material; high values explore phrasing and ideas.
| Temperature | Use it when | Example |
|---|---|---|
0.2 | Order status, policy answers, retrieval | "TRK-48291 भोलि 11 बजे आइपुग्छ।" |
0.5 | Everyday support with a friendly tone | Rephrased delivery options |
0.9 | Slogans, stories, brainstorming | Dashain campaign ideas in Nepali |
Pair low temperature with retrieved context for RAG. Raise it only for explicitly creative endpoints or UI modes labeled "creative".
Budget tokens and trim history
max_tokens caps the reply, not the whole request. Input history plus max_tokens must fit the context window above. A Kathmandu support turn averages 400–800 tokens; set max_tokens to 300–600 for chat bubbles and higher only for summaries or letters.
Never grow messages forever. Keep the system prompt plus a sliding window of recent turns, and summarize anything evicted.
Count tokens client-side before sending, and fall back from sage-2-4-actus to a summary call on sage-2-5-celer when a session runs long.
Best practices
- Write the
systemprompt in the language you want answered — Nepali in, Nepali out. - Pin
temperatureto0.2for money, dates, and NPR amounts; use0.9only for creative modes. - Set explicit
max_tokensper surface: 300 for chat, 800 for email-length replies. - Persist
messagesserver-side so refreshes and retries keep continuity. - Log model ID, token usage, and latency per turn to guide Actus vs Celer splits.
