Skip to main content
By default, the Caylex agent runs on its configured model. Model selection lets your backend override that on a per-session basis by passing an optional 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: the POST /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 different model.

Request

Add an optional model 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 model were passed).
  • The response model is null and model_warning explains why and lists the allowed models.
This makes it safe to pass a model id without pre-validating it: a typo never silently downgrades the agent’s configured model, and the warning surfaces the problem to your backend.

Example

Add the optional model to your existing backend token call.
token.py
The frontend integration is unchanged — pass the returned token to the widget as described in Embedded Widgets.