Skip to main content

Chat UI

The Chat UI is a separate workspace at /ui/chat for people who use the gateway rather than administer it. A user signs in with the same account as the Admin UI, picks a model from those their key may use, and chats. The conversation runs through the gateway's Responses API, so every turn is authorised, costed, guarded and logged like any API call, and MCP servers the user has connected can be attached as tools.

A real-world scenario​

A legal team needs a chat tool for contract questions, and the security team wants every prompt to go through the gateway's guardrails and spend limits. The admin turns on the Chat UI, and the lawyers sign in with their existing accounts and chat only with the models their keys allow.

Steps​

  1. In the Admin UI open Settings, then Admin Settings, select the UI Settings tab, turn on [BETA] Enable Chat page (page will refresh) and save. The same with the API:

    curl -X PATCH http://localhost:4000/update/ui_settings \
    -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
    -d '{"enable_chat_ui": true}'
  2. The page reloads, and Chat appears in the sidebar and in the view switcher of the header.

  3. Click Chat, or open /ui/chat, pick a model and send a message.

  4. Check the turn on the Logs page of the Admin UI.

Expected result​

The chat answers with the chosen model, and each turn is a logged request that counts against the user's key budget and passes its guardrails.

Enabling it​

The page is off by default. Turn it on from the UI Settings tab of the Admin Settings page, or with the UI settings endpoint and the master key or a proxy admin's key. Any other key gets 403 Only proxy admins can update UI settings. The setting is stored in the database, so the gateway needs STORE_MODEL_IN_DB=True, and the change is written to the audit log as table Spanway_UISettings with the value before and after. Each chat message is a normal model request billed to the user's key and budget, so turning the page on adds spend only when people use it.

curl -X PATCH http://localhost:4000/update/ui_settings -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"enable_chat_ui": true}'

Once enabled, Chat appears in the Admin UI sidebar and in the view switcher of the dashboard header. With the setting off the route redirects back to the dashboard and the switcher entry is disabled.

What users can do​

PageWhat it is for
ChatConversations with a chosen model. Follow up turns chain on the previous response id, and the MCP picker attaches connected servers or toolsets as tools on the request.
IntegrationsStart the OAuth connection for MCP servers that need a per-user token, see per-user credentials.
CredentialsLists your OAuth connections and personal API keys for MCP servers and lets you revoke them. Personal API keys are entered from the Connect dialog on Integrations.
API keysThe user's own virtual keys.
UsageThe user's spend over time.
LogsThe user's request logs.

Conversation history is kept in the browser's local storage per user, not on the gateway. The messages themselves reach the gateway only as requests, and are kept in the spend logs only when store_prompts_in_spend_logs is on.

Admin UI location​

Chat sits in the AI Gateway group of the sidebar and the view switcher lists it next to AI Gateway and any UI plugins.

Errors​

What you seeWhat it meansFix
/ui/chat redirects to the dashboardenable_chat_ui is off, or the user has a view-only role.Turn it on as in step 1. View-only roles never see the page.
403 Only proxy admins can update UI settings. when turning it onThe key is not the master key or a proxy admin's key.Use the master key or a proxy admin's key.
500 Set `'STORE_MODEL_IN_DB='True'` in your env to enable this feature.The gateway does not store settings in the database.Set STORE_MODEL_IN_DB=True and restart.
The model list is emptyThe user's key may use no chat model.Give the key or its team a chat model.
A turn fails with a guardrail messageA guardrail on the key or team blocked the prompt or the answer.Rephrase, or ask an admin to check the guardrail on the Guardrails page.
A turn fails with budget_exceededThe key or team spent its budget.Ask an admin to raise it, see budgets.

Logs​

Every chat turn is an ordinary /v1/responses request made with the user's key, so it shows up on the Logs page of the Admin UI and on the user's own Logs page in Chat, with its model, tokens and cost. Turning the page on or off writes an audit row on table Spanway_UISettings. The Chat page writes no gateway log lines of its own, and the request lines it causes are in the log reference.