Agent gateway
- post
/v1/anthropic/v1/messages - post
/v1/anthropic/v1/messages/count_tokens - post
/v1/openai/v1/responses /v1/anthropic/v1/models/v1/openai/v1/models
Anthropic messages
post
/v1/anthropic/v1/messagesParameters
x-nexus-teamIdempotency-Key
Request body · application/json
Responses
200
400
401
402
403
404
408
409
413
422
426
429
502
503
504
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request_error | A field is missing or not valid; the message names it |
| 400 | The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | |
| 401 | authentication_error | No key, or a key Gateway does not accept |
| 402 | budget_exceeded | The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. Its `error.nexus` is a BudgetRefusal: each money figure with its exact decimal twin. |
| 403 | role_required | Your role does not have this permission |
| 403 | model_not_allowed | `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). `provider_disabled`: the organization has turned off every provider that serves the model. |
| 404 | `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). | |
| 408 | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | |
| 409 | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. | |
| 409 | idempotency_in_progress | A request with the same Idempotency-Key is still running |
| 409 | idempotency_interrupted | The first request with this Idempotency-Key was cut off and may have run in part |
| 413 | The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). | |
| 422 | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). | |
| 422 | idempotency_key_reused | The Idempotency-Key was used with a different request |
| 426 | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | |
| 429 | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | |
| 429 | rate_limit_error | Too many requests from this key in a minute |
| 502 | The provider could not be reached, or the connection to it failed (`api_error`). | |
| 503 | The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call answered (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). | |
| 504 | The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). |
Example
curl -X POST "$NEXUS_URL/v1/anthropic/v1/messages" \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'Anthropic count tokens
post
/v1/anthropic/v1/messages/count_tokensParameters
Idempotency-Key
Request body · application/json
Responses
200
400
401
402
403
404
408
409
413
422
426
429
502
503
504
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request_error | A field is missing or not valid; the message names it |
| 400 | The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | |
| 401 | authentication_error | No key, or a key Gateway does not accept |
| 402 | budget_exceeded | The call's maximum cost is more than the budget left. |
| 403 | role_required | Your role does not have this permission |
| 403 | model_not_allowed | `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). |
| 404 | `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). | |
| 408 | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | |
| 409 | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. | |
| 409 | idempotency_in_progress | A request with the same Idempotency-Key is still running |
| 409 | idempotency_interrupted | The first request with this Idempotency-Key was cut off and may have run in part |
| 413 | The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). | |
| 422 | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). | |
| 422 | idempotency_key_reused | The Idempotency-Key was used with a different request |
| 426 | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | |
| 429 | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | |
| 429 | rate_limit_error | Too many requests from this key in a minute |
| 502 | The provider could not be reached, or the connection to it failed (`api_error`). | |
| 503 | The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); or its database is busy (`database_busy`, retry shortly). A count is never `gateway_stopping`. | |
| 504 | The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). |
Example
curl -X POST "$NEXUS_URL/v1/anthropic/v1/messages/count_tokens" \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5-5",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'OpenAI responses
post
/v1/openai/v1/responsesParameters
x-nexus-teamIdempotency-Key
Request body · application/json
Responses
200
400
401
402
403
404
408
409
413
422
426
429
502
503
504
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_request_error | A field is missing or not valid; the message names it |
| 400 | The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | |
| 401 | authentication_error | No key, or a key Gateway does not accept |
| 402 | budget_exceeded | The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. Its `error.nexus` is a BudgetRefusal: each money figure with its exact decimal twin. |
| 403 | role_required | Your role does not have this permission |
| 403 | model_not_allowed | `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). `provider_disabled`: the organization has turned off every provider that serves the model. |
| 404 | `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). | |
| 408 | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | |
| 409 | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. | |
| 409 | idempotency_in_progress | A request with the same Idempotency-Key is still running |
| 409 | idempotency_interrupted | The first request with this Idempotency-Key was cut off and may have run in part |
| 413 | The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). | |
| 422 | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). | |
| 422 | idempotency_key_reused | The Idempotency-Key was used with a different request |
| 426 | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | |
| 429 | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | |
| 429 | rate_limit_error | Too many requests from this key in a minute |
| 502 | The provider could not be reached, or the connection to it failed (`api_error`). | |
| 503 | The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call answered (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). | |
| 504 | The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). |
Example
curl -X POST "$NEXUS_URL/v1/openai/v1/responses" \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"input": "Hello"
}'Anthropic models
/v1/anthropic/v1/modelsResponses
200
401
403
404
426
429
503
Errors
| Status | Code | When |
|---|---|---|
| 401 | authentication_error | No key, or a key Gateway does not accept |
| 403 | role_required | Your role does not have this permission |
| 404 | The team named in `x-nexus-team` does not exist (`unknown_team`). | |
| 426 | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | |
| 429 | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | |
| 429 | rate_limit_error | Too many requests from this key in a minute |
| 503 | Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. |
Example
curl "$NEXUS_URL/v1/anthropic/v1/models" \
-H "Authorization: Bearer $NEXUS_API_KEY" \
-H "anthropic-version: 2023-06-01"OpenAI models
/v1/openai/v1/modelsResponses
200
401
403
404
426
429
503
Errors
| Status | Code | When |
|---|---|---|
| 401 | authentication_error | No key, or a key Gateway does not accept |
| 403 | role_required | Your role does not have this permission |
| 404 | The team named in `x-nexus-team` does not exist (`unknown_team`). | |
| 426 | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | |
| 429 | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | |
| 429 | rate_limit_error | Too many requests from this key in a minute |
| 503 | Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. |
Example
curl "$NEXUS_URL/v1/openai/v1/models" \
-H "Authorization: Bearer $NEXUS_API_KEY"