Error codes reference
Every searchSDK SearchError code: what it means, whether it is retried, falls back or may be billed, and what to do.
Every failure throws SearchError with one fixed code. Messages are fixed per code and never include keys or response bodies. Retries need maxRetries; fallback needs fallback.
Codes
| Code | HTTP status | Retried | Falls back | Meaning and what to do |
|---|---|---|---|---|
invalid_request | – | no | no | Fix the input: field names the option or query. Nothing was sent. |
configuration | – | no | no | Fix the client: a missing or unusable key (field: "keys"), no or an unknown provider, or a bad setting. |
unsupported | – | no | yes | The provider cannot express this request (field says which option). A fallback skips it; otherwise drop the option or pick another provider. |
auth | 401 | no | no | The provider rejected the key. Check the key variable. |
forbidden | 403 | no | no | The key is valid but not allowed this call (plan or permission). |
quota | 402 | no | yes | Out of credits or over a plan limit. Top up, or fall back. |
rate_limit | 429 | yes | yes | Too many requests. Set maxRetries to honour Retry-After, or fall back. |
unavailable | 408, other 500–599 | yes | yes | A 5xx or 408. Retry, or fall back. |
provider_error | other 400–499 | no | no | Any other 4xx: the provider refused the request as sent. providerCode and the attempt status help. |
network | – | yes | yes | No answer: the connection failed or broke off. It may have been billed. |
attempt_timeout | – | yes | yes | One attempt passed attemptTimeoutMs. Retried and falls back. |
timeout | – | no | no | The whole call passed timeoutMs. Raise it or lower retries. |
aborted | – | no | no | Your signal aborted the call. |
invalid_response | – | no | no | A 2xx that is not a UTF-8 JSON object, or a status searchSDK cannot map (3xx). Billed for a 2xx, never retried. |
spec_mismatch | – | no | no | A 2xx JSON object without the list the spec reads; path names it and raw keeps the body. Our spec and the provider disagree: report it. |
response_too_large | – | no | no | A 2xx over maxResponseBytes. Raise the limit or ask for fewer items. |
An attempt that got a 2xx is billed, so it is never retried; one that got an error status is not billed. With no status, network, attempt_timeout, timeout and aborted attempts are billed possible, and the rest were never sent. An empty result list is a success, never an error.
Provider status rules
Some providers signal a code with their own status or body. These rules run before the shared status table.
| Provider | Status | When | Code |
|---|---|---|---|
| Brave Search | 429 | error.code = "QUOTA_LIMITED" | quota |
| Perplexity | 401 | error.type = "insufficient_quota" | quota |
| Tavily | 432 | – | quota |
| Tavily | 433 | – | quota |
| Tavily | 434 | – | unavailable |
| TinyFish | 429 | error.details.reason = "free_allowance_exhausted" | quota |
SearchError fields
| Field | Type | Meaning |
|---|---|---|
code | ErrorCode | One of the codes above. |
provider? | AnyProviderId | The provider of the failing attempt. |
status? | number | HTTP status, when one arrived. |
providerCode? | string | The provider's own machine-readable code, when its spec says where to read it. |
retryAfterMs? | number | The provider's Retry-After, in milliseconds. |
field? | string | The option that failed validation or that the provider cannot honour. |
path? | string | For spec_mismatch: the spec path the body did not have. |
attempts | Attempt<AnyProviderId>[] | Every attempt made before the failure, with its cost and billing. |
raw? | unknown | The parsed body of a 2xx that could not be mapped. |
message is the fixed text for the code. Guides: Errors and troubleshooting.