Errors & Limits
Stable errors, retry rules, and authoritative limits.
Elektric returns stable error codes for failures your application can act on. Use the error code to decide what to fix or retry, and keep the Request ID when you need to trace a request.
Limits are enforced for the authenticated project. Your project may have stricter request or spend limits than the platform defaults.
#Error response
{
"error": {
"message": "Human-readable explanation",
"type": "invalid_request_error",
"code": "invalid_request",
"request_id": "req_..."
}
}Branch on error.code, not message text. request_id may also be returned in the x-elektric-request-id response header.
Streaming and Realtime errors use their respective stream or protocol error formats instead of this HTTP JSON envelope.
#Common errors
| HTTP | Code | What it means | Retry? |
|---|---|---|---|
| 401 | invalid_api_key | API key is missing, invalid, or revoked. | No |
| 403 | project_api_key_required | This operation requires a project API key. | No |
| 400 | invalid_request | The request is malformed or contains invalid fields. | No |
| 413 | request_too_large | The request exceeds the allowed body size. | No |
| 429 | rate_limit_exceeded | The project exceeded its request rate. | After Retry-After |
| 429 | concurrency_limit_exceeded | Too many requests are running at once. | After Retry-After |
| 429 | daily_request_quota_exceeded | The project reached its daily request quota. | After reset |
| 402 | insufficient_balance | The billing account does not have enough balance. | No |
| 400 | model_capability_mismatch | The selected model cannot handle the requested input or operation. | No |
| 400 | unsupported_parameter | This operation does not support the supplied parameter. | No |
| 400 | unsupported_parameter_for_model | The selected model does not support the supplied parameter. | No |
| 400 | max_output_tokens_exceeded | The requested output exceeds the allowed limit. | No |
| 400 | context_length_exceeded | The request exceeds the selected model's context window. | No |
| 503 | no_capable_model_available | Grid could not find an eligible model. | Conditional |
| 503 | no_healthy_model_available | Eligible Grid models are not currently healthy. | Conditional |
| 400 | grid_clarification_required | Grid needs a clearer request before choosing safely. | No |
| 400 | grid_unsupported_operation | The requested operation is not supported by Grid. | No |
| 502 | grid_research_failed | Required research failed before the final operation. | Conditional |
| 404 | file_not_found | The referenced file does not exist for this project. | No |
| 410 | file_expired | The temporary file expired; upload it again. | No |
| 413 | file_too_large | The uploaded file exceeds the allowed size. | No |
Grid may also return operation-specific availability errors such as grid_image_unavailable, grid_video_unavailable, grid_speech_unavailable, or grid_transcription_unavailable when an otherwise supported media operation cannot currently execute. Treat these as conditional retry cases.
More specific validation errors may be returned for files, images, video, speech, transcription, and Realtime. They use the same error.code pattern.
#Retry safely
Retry only when the request is safe to repeat.
| Response | What to do |
|---|---|
| 429 | Wait for Retry-After, then retry. |
| 408, 502, 503, 504 | Retry only if repeating the operation cannot create duplicate paid work. |
| 500 | Keep the Request ID and inspect the request before retrying paid work. |
| 400, 401, 402, 403 | Fix the request, authentication, or billing state first. |
Grid may try another eligible route before output begins. Wire does not silently switch models. Once streaming output has started, Elektric does not restart the request with another model.
#Idempotency
Use Idempotency-Key when creating asynchronous video jobs. Reusing the same key for the same project and operation returns the existing job instead of creating another one.
- Maximum length: 200 characters.
- Scope: project and operation.
- Empty keys and keys containing control characters are rejected.
Chat, image generation/editing, speech, transcription, and research do not currently provide the same public idempotent-create guarantee. Retrying those operations after an uncertain failure may repeat provider work and charges.
#Cancellation
Client cancellation stops the client from waiting. It does not necessarily stop upstream provider work.
AbortSignalstops the client request.- Ending a stream after work starts may still leave billable provider usage.
- Video jobs support explicit cancellation, but cancellation is best effort.
- Upstream work may still be in flight after cancellation.
#Platform limits
| Limit | Default |
|---|---|
| Requests | 60/minute |
| Burst | 20 requests / 10 seconds |
| Concurrent requests | 10 |
| Daily requests | 10,000 per project |
| Request body | 8 MiB |
| Messages per request | 256 |
| Serialized message size | 256 KiB |
| Default output ceiling | 32,768 tokens |
These are platform defaults. Limits are enforced for the authenticated project, and project or account policy may be stricter.
Model-specific context windows, output ceilings, and capabilities vary by model. Check authenticated GET /v1/models for current model information.
#File and media limits
| Input | Limit |
|---|---|
| Attachments per request | 4 |
| Inline image | 5 MiB |
| Inline audio | 5 MiB |
| Inline video | 5 MiB |
| Inline PDF/document | 10 MiB |
| Aggregate inline attachments | 12 MiB |
| Active temporary files | 100 per project |
| Temporary file lifetime | 1 hour |
| Uploaded file | Maximum |
|---|---|
| Image | 5 MiB |
| Video | 10 MiB |
| Transcription audio | 25 MiB |
| PDF/document | 10 MiB |
Inline attachments must appear in user messages. Supported inline formats currently include PNG/JPEG/WebP images, MP4 video, and WAV/MPEG/MP4/WebM/OGG/FLAC audio.
#Operation input limits
| Input | Maximum |
|---|---|
| Image prompt | 4,000 characters |
| Image edit instruction | 4,000 characters |
| Speech input | 4,000 characters |
Video generation duration, aspect ratio, resolution, and other capabilities depend on the selected product. Check Models and Media for current capabilities.
#Check your effective limits
GET /v1/limits returns the limits currently applied to your authenticated project.
{
"object": "limits",
"requests_per_minute": 60,
"burst": { "requests": 20, "window_seconds": 10 },
"concurrent_requests": 10,
"daily_request_limit": 10000,
"monthly_spend_limit_usd": null,
"current_monthly_spend_usd": "0.000000000"
}Daily request and monthly spend limits can vary by project.
/v1/limits does not currently include model capabilities, media limits, Realtime limits, file limits, or remaining request capacity.
Temporary uploaded files expire after 1 hour. Generated asset retention varies by operation.
See Models for model-specific capabilities and Grid routing for fallback behavior.
