Skip to content

Service limits and status codes

The limits that apply to services and every status and code a caller or a client of the service API can get, with what to do about it.

On this page

Errors from a service come as application/problem+json with a stable code and a request_id. Branch on code, not on the text. Quote the request_id when you contact support.

Limits

Limits
LimitValue
Autoscaled services per organization10 (services on a rental follow rentals)
Active keys per service10
Replicas per service10, and 20 across the organization (ask support to raise them)
Services created20 an hour for an organization
Keys created60 an hour for an organization
Request body10 MiB
Request headers32 KiB
Requests waiting when every replica is busy64 per service, for at most 30 seconds
X-Legion-WaitAt most 300 seconds
Request timeout600 seconds by default, at most 3600
Silence while streamingA connection that sends nothing for 60 seconds is closed
Failed key checks20 a minute from one address, then 5 minutes of 429
Service kindsopenai and http

A service's own key can also have a requests-per-minute limit that you set.

What a caller can get

These come from the Service URL.

What a caller can get
StatusCodeWhat it meansWhat to do
401unauthorizedThe key is missing, unknown, expired, revoked, or for another service. The answer is the same for all of them.Check the key and the URL. Create a new key if it expired or was revoked.
402spend_cap_reachedThis month's spend reached the cap.The owner raises the cap or waits for the next month (UTC). Don't retry in a loop.
402insufficient_creditThe organization is out of credit.An owner adds credit.
403service_disabledLegion took the service down.Contact support.
403org_suspendedThe organization is suspended.Contact support.
404service_not_foundNo service has this name, or the URL is not a service.Check the URL.
413request_too_largeThe request body is over 10 MiB.Send less.
429rate_limitedThe key went over its requests-per-minute limit, or too many wrong keys came from one address. Retry-After says when.Wait that long, then retry with a growing delay.
503service_startingNo replica is ready yet. One is starting. Retry-After is the usual start time.Retry after it, or send X-Legion-Wait to be held until one is ready. See Call a service.
503service_busyEvery replica is at its limit and the queue is full or the wait ended. Retry-After is 5 seconds.Retry with a growing delay. If it is common, raise the maximum replicas.
503service_pausedThe service is paused.Resume it.
503router_unavailableLegion's router can't read its settings right now.Retry after a moment.

Requests the router refuses to forward (a path with .., an absolute-form target or TRACE) are 400, and a path outside /v1/ on an openai service is refused. Anything else comes from your model: its status and body pass through unchanged, and a 3xx is never followed. A request that runs past the request timeout is ended.

When a replica fails before it answers, Legion retries the request once on another replica. It never retries after the first byte of the response.

What the service API can answer

These come from the Legion API (/v1/services), for the app, the CLI, agents and your own code.

What the service API can answer
StatusCodeWhat it meansWhat to do
400invalid_requestA field is missing or malformed.Fix the request.
400invalid_serveThe serve port, kind or model name is not valid.Fix it. The kind is openai or http.
400service_kind_unsupportedThe kind isn't supported yet, for example WebSocket services.Use openai or http.
400invalid_scalingA scaling setting breaks a rule: the maximum is below the minimum, warm replicas are above the minimum, or a value is out of range.Fix the values.
400invalid_hardwareThe hardware settings are not valid: for example a GPU count the model can't use, or no memory for your own image.Fix them.
400image_private, registry_sign_in_rejectedYour own image is private, or the registry sign-in for it was refused.Fix the registry sign-in in the app.
400invalid_sourceAn allowed address range isn't valid, or is private or reserved.Fix the list (up to 16 CIDR ranges).
400invalid_service_nameThe name isn't lower case letters, numbers and hyphens, 3 to 40 characters starting with a letter, or it is reserved.Choose another.
400invalid_spend_capThe cap is missing, zero or not valid.Set a positive amount.
400host_visibility_not_acknowledgedThe first service of an organization needs acknowledge_host_visibility: true.Read What a host can see, then send it.
402insufficient_creditCreating a service that keeps replicas running needs credit.An owner adds credit.
403service_unavailableExposing a port is switched off for your organization, or paused by Legion.An organization owner can switch it back on in the app, or contact support.
403custom_images_disabledYour organization can't use its own images.Choose a premade model.
403step_up_requiredThe change needs a fresh sign-in: a key with no expiry, a new or rotated key in the app, or deleting a service.Sign in again and retry.
403api_key_scopeThe key can't use this operation.Use a key with the right scope.
404not_foundThe service, key or replica doesn't exist, or belongs to another organization.Check the id.
409service_name_takenAnother service of yours has this name.To change that service's model, hardware or price ceiling, use its Settings tab instead: it keeps its name and URL. Or delete it first: once it is deleted, the name is free. Or choose another name.
409rule_existsThat port of the rental is already exposed.Use the service that exists.
409too_many_rulesThe rental or the organization is at its limit of exposed ports.Delete one you don't need.
409rental_not_liveThe rental must be starting or running to expose a port.Wait for it, or start it.
409rental_unnamedThe rental has no name to build an address from.Choose a name for the service.
409host_unsupportedThe rental's host can't expose ports yet.Rent on another host.
409too_many_servicesThe organization has 10 services.Delete one you don't use.
409too_many_keysThe service has 10 active keys.Revoke one.
409no_matching_offersNo hardware that fits the model is available at your price ceiling right now.Raise the price ceiling, remove GPU models from your allow-list, or set an offer alert.
409catalog_entry_incompatibleThe GPUs can't run the model.Choose at least the GPUs the model needs.
409replica_limit_exceededThe maximum replicas is over your organization's limit (10 per service, 20 in all).Lower it, or ask support to raise the limit.
409service_not_autoscaledThe call needs autoscaling on, for example resume or scaling settings on a service on a rental.Turn autoscaling on first.
409invalid_mode_switchThe switch between one rental and autoscaling isn't possible as asked.Choose the strategy or the replica to keep, and retry.
409service_deletingThe service is being deleted.Nothing to do.
409service_cappedThe service is at its monthly cap and can't resume.Raise the cap first.
409service_disabledLegion took the service down.Contact support.
409revision_mismatchSomeone changed the service after you read it.Read it again and retry.
409key_revokedThe key to rotate is already revoked.Create a new key.
409rental_managed_by_serviceYou tried to stop, start, delete or expose a replica of an autoscaled service.Change the service's scaling instead.
422idempotency_key_reusedThe Idempotency-Key was used for a different request.Use a new key for a new action, and the same one only to retry the same request.
429rate_limitedToo many creates in the last hour. Retry-After says when.Wait.

Every other code of the Legion API is in Errors.