model when it starts an agent session, so you can match the model to the use case (for example, a faster, cheaper model for lightweight chat, or a larger model for complex work).
Overview
The model is chosen server-side, at the same place you already start a session: thePOST /widget/agent-session-init call. Caylex validates the requested model against a curated allowlist, embeds the resolved model in the short-lived widget token, and the agent uses it for every turn of that session.
The model is selected by your backend when it mints the session token. The widget package (browser) does not choose the model. This keeps model choice under your control and out of the browser.
How It Works
The selected model is recorded on the chat session at initialization, so every subsequent turn in that session uses it. To change the model, start a new session with a differentmodel.
Request
Add an optionalmodel to the session-init body:
Response
Allowed Models
Model selection is restricted to a curated set of capable models across providers and sizes. This prevents accidentally selecting an under-powered model.
If
model is omitted, the session uses the Caylex agent’s configured model, falling back to the platform default anthropic/claude-sonnet-4.6 when none is set. Passing model only overrides that for the session when you explicitly request a supported one.
Fallback Behavior
Model selection never fails the session for an unsupported model. If you pass a model that is not on the allowed list:- The requested model is ignored — it does not override the agent’s configured model.
- The session is created using the agent’s configured model (the same as if no
modelwere passed). - The response
modelisnullandmodel_warningexplains why and lists the allowed models.
Example
Add the optionalmodel to your existing backend token call.
- Python
- TypeScript
token.py
token to the widget as described in Embedded Widgets.