Guides

Agnai

Chat with any MiniRouter model in Agnai.

Agnai is a multi-user character chat app, hosted at agnai.chat or on your own machine. Its Third-Party preset runs on any chat model in the catalog, or the curated roleplay list, from one balance. See Roleplay for data handling and accountless keys.

1. Open Agnai

2. Create a key

Create a key. Optionally test it before opening Agnai.

Terminal
export MINIROUTER_KEY=mr-live-YOUR-KEY-HERE
curl https://api.minirouter.sh/v1/chat/completions \
  -H "Authorization: Bearer $MINIROUTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"zai/glm-5.3-flash","messages":[{"role":"user","content":"ping"}]}'

3. Create the preset

Open Settings → AI Settings → Third-Party preset and fill in:

SettingValue
AI ServiceThird-Party
Third Party FormatOpenAI Compat (Chat)
Third Party URLhttps://api.minirouter.sh/v1Never append /chat/completions — Agnai adds the path itself.
Third Party Key/Passwordmr-live-… (your key)
OpenAI Model Overridezai/glm-5.3-flash

4. Send a message

Choose the preset from the chat menu's Preset and send a message. Open Request logs to see its model, tokens and exact cost.

Switch models

Open the model picker, type into Manual Model ID, then Confirm. Any model ID works.

Model IDAnswers with
minirouter/auto:roleplayA long-context, low-input-cost model Auto picks.
@preset/your-slugYour saved preset, with up to three models as fallbacks.

Two kinds of preset

PresetHolds
Agnai presetService, URL, key, model and samplers. Pick one per chat from the chat menu's Preset.
MiniRouter presetModels and fallbacks on our side. Create one in Presets, then send @preset/your-slug as the model.

Size each turn

SettingDoes
Context SizeMost Agnai sends as the prompt. Lower it to cut input cost.
Response LengthMost the model writes back.
Stream ResponseShows the reply as it arrives. See Streaming.

Keep Context Size below the window on the model's page in Models. A prompt over the window fails with context_too_long.

Keep spend in check

Every regenerate is a new, billed request.

Troubleshooting

404, HTML, or a parse error on every request

Almost always the base URL. Use https://api.minirouter.sh/v1 — the bare host without /v1 also works, but never append /chat/completions to the base URL field; the client adds that path itself.

Error: 400 invalid_request.

401 on every request

Wrong or rotated key. Keys start with mr-live-; after a rotation the old key keeps working for 24 hours, then dies.

Error: 401 invalid_api_key.

Works self-hosted, fails on the hosted instance

The hosted app makes the request from its own servers unless Use Local Requests is enabled. Nothing on our side distinguishes the two — check the preset is actually selected for the character you are chatting with, since Agnai stores a preset per character.

Response stops mid-sentence with a credits message

Balance hit $0 mid-stream. The stream ends with a terminal error naming the exact charge for tokens delivered — never a silent close.

Error: 402 insufficient_credits.

Every error code, with its fix: Errors.

Next steps