Errors & limits
Every error shape the API returns, the codes you'll see and what to do about them, and the limits that apply to requests.
For developers
This page collects the API's error responses and limits in one place. Most inference errors use OpenAI's envelope, but a few routes answer in other shapes, so check the status code first and read the body second. The engine log (Settings → Logs, or midium logs --errors) has the details of any failure.
Error shapes#
OpenAI envelope — chat completions, embeddings, rerank and audio:
{
"error": {
"message": "Model 'qwen9' not found. Available models: ['Gemma 4 26B A4B', 'Qwen3.8 27B']",
"type": "invalid_request_error",
"code": "model_not_found"
}
}
FastAPI detail — authentication errors on every route, unknown routes and body validation:
{"detail": "API key does not exist"}
A body that doesn't match the schema returns 422 with a list: {"detail": [{"loc": ["body", "model"], "msg": "Field required", "type": "missing"}]}.
Plain error — model management routes, and a prompt that's too long:
{"error": "Prompt too long: 140213. Max tokens: 131072"}
Anthropic shape — everything on /v1/messages and /v1/messages/count_tokens:
{"type": "error", "error": {"type": "not_found_error", "message": "Model 'claude-sonnet' not found. …"}}
During a stream the status is already 200, so errors arrive in the stream: a chat chunk with an error object and empty choices, followed by data: [DONE]; an error event on Anthropic Messages.
Status codes#
| Status | Meaning | What to do |
|---|---|---|
400 | The request can't be run as sent: a bad tool choice, a model of the wrong kind, an unsupported option, a prompt longer than the context window. | Read message and code; fix the request. |
401 | No key, or a key this Mac doesn't know (Missing API key, API key does not exist). | Copy the key from Settings → API or midium key --reveal. See Authentication. |
403 | The key's account is turned off (Account suspended), or a team member's key on a Hub-only surface. | — |
404 | No model by that name (model_not_found; the message lists the ones you can use), an unknown route ({"detail": "Not Found"}), or an unknown download job. | Check the name against GET /v1/models. |
409 | Model management: deleting files of a model that's still one of yours, or a new file_path that won't load. | Remove the model first; check the path. |
422 | The body doesn't match the schema: a missing field, a wrong type, an empty input. | Read detail. |
429 | Tier credit limit reached for this period. — the key's plan quota is used up. | Wait for the reset or change plan. |
500 | Generation or a model load failed. | Check the engine log; retry. |
Error codes#
code | Status | Where | Cause |
|---|---|---|---|
model_not_found | 404 | Chat, embeddings, rerank, audio | No model by that name, or (audio) no speech model installed. |
model_not_chat | 400 | Chat completions | The model is an embedder, reranker, image or video model. The message names the right endpoint. |
unsupported_model_type | 400 | Embeddings, rerank | The model isn't an embedding model / reranker. |
invalid_tool_choice | 400 | Chat completions | tool_choice names a tool that isn't in tools. |
invalid_tool_call | 400 | Chat completions | The model's tool-call arguments couldn't be turned into valid JSON. Retrying usually works. |
invalid_audio | 400 | Audio, chat with audio | Unsupported file extension, an unreadable upload, or a bad input_audio part. |
invalid_response_format | 400 | Audio | response_format isn't json, text, srt, vtt or verbose_json. |
invalid_request_error | 400 | Audio | File over 25 MB, or timestamp_granularities without verbose_json or with a value other than segment / word. |
unsupported_streaming | 400 | Chat completions | Streaming asked of a transcription model. |
unsupported_tools | 400 | Chat completions | Tools sent to a transcription model. |
embedding_error, rerank_error | 400 / 500 | Embeddings, rerank | The model failed, for example dimensions larger than the model's vectors. |
invalid_response | 500 | Embeddings, rerank | The model returned something unusable. |
A 500 from chat completions has a type but no code.
Limits#
| Limit | Value | Notes |
|---|---|---|
| Where requests come from | 127.0.0.1 only | Desktop installs listen on loopback. See Remote access. |
Smallest max_tokens | 8192 | Smaller caps are raised to 8192. Send "strict_max_tokens": true, or set UCE_HONOR_MAX_TOKENS=1 in ~/Midium/.env, to honor them exactly. |
max_tokens left out | The model's default, else 32,768 | UCE_DEFAULT_MAX_TOKENS in ~/Midium/.env changes the 32,768. |
| Reply length | The context the prompt leaves free | Every cap is cut to fit the model's context window. A reply that hits its cap ends with finish_reason: "length". |
| Prompt length | The model's context window | Longer prompts fail with 400 "Prompt too long". Raise the context on Settings → Models. |
| Choices per request | 1 | n is accepted; one choice comes back. |
| Audio upload | 25 MB | .mp3, .mp4, .mpeg, .mpga, .m4a, .wav, .webm. |
| Image links | http(s), public hosts only, 30 s download | localhost, .local names and private, loopback, link-local, reserved or multicast addresses are refused. A refused or failed image is dropped without an error — send base64 instead. See Images & vision. |
| Web search | 3 rounds per request | Needs a Brave Search key. See Tool calling. |
Model copies (instances) | 1–8 | Per model. |
Requests per copy (batch_size) | 1–32 | Per model. |
| Vault MCP reads | 80,000 characters per call | Page with offset. Listing returns up to 500 files; writes up to 1 MiB. |
Troubleshooting#
- The first request is slow. The model is loading. Keep it loaded from Settings → Models.
- A reply ignores an image. The image was dropped — see the warning on Images & vision.
- A reasoning model's answer is empty but
finish_reasonislength. It spent its budget thinking. Leavemax_tokensout, raise it, or turn thinking off withreasoning_effort: "none". - More fixes: Troubleshooting.
Something here wrong or out of date? Tell us.
