# GetAPI

Common errors, limits and billing. Find the cause of a problem and how to resolve it. To connect an app, open the [setup guide](https://getapi.trade/docs).

## API errors

Check HTTP status and the structured error code first. The human-readable `message` can change. Stream errors also require handling, even when the HTTP status is 200.

**Example error envelope**

```json
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded",
    "request_id": "example-request-id",
    "retryable": true
  }
}
```

| HTTP | `code` | Cause | Action |
| --- | --- | --- | --- |
| 400 | `VALIDATION_ERROR` | Invalid JSON, parameters or context size. | Fix the request body before retrying. |
| 400 | `context_length_exceeded` | Input and maximum output do not fit the model context. | Shorten history or start a new conversation. Input plus maximum output must fit in context. |
| 400 | `invalid_output_tokens` | The output limit is invalid or conflicts with another parameter. | Use one compatible positive output limit for the selected protocol. |
| 400 | `conflicting_output_tokens` | The output limit is invalid or conflicts with another parameter. | Use one compatible positive output limit for the selected protocol. |
| 400 | `unsupported_output_tokens` | This endpoint does not support the supplied output limit. | Fix the request body before retrying. |
| 400 | `request_too_complex` | The JSON structure is too deep or complex. | Reduce history or attachments. |
| 400 | `tool_declarations_missing` | Tool history is present without the required tool definitions. | Refresh client configuration and send current tool declarations with call history. |
| 400 | `safeguards_unsupported` | The model route does not support the safeguards check. | Update Claude Code and follow its built-in safety-check flow. |
| 400 | `invalid_media` | An attachment has an unsupported format or URL. | Reduce history or attachments. |
| 400 | `too_many_media_parts` | The request contains too many attachments. | Reduce history or attachments. |
| 400 | `media_too_large` | Attachments exceed the supported size. | Reduce history or attachments. |
| 401 | `UNAUTHORIZED` | Missing, invalid or expired key. | Check the key and its expiry in [API Keys](https://getapi.trade/dashboard?tab=keys). |
| 401 | `api_key_expired` | Missing, invalid or expired key. | Check the key and its expiry in [API Keys](https://getapi.trade/dashboard?tab=keys). |
| 402 | `INSUFFICIENT_BALANCE` | Insufficient balance or key budget. | Top up your [wallet](https://getapi.trade/account/wallet) or choose a cheaper model. |
| 402 | `spend_cap_exceeded` | The key’s own spending cap has been reached. | Increase the cap in [API Keys](https://getapi.trade/dashboard?tab=keys) or use another permitted key. |
| 402 | `SPEND_CAP_EXCEEDED` | The key’s own spending cap has been reached. | Increase the cap in [API Keys](https://getapi.trade/dashboard?tab=keys) or use another permitted key. |
| 403 | `FORBIDDEN` | Access denied. | Check key permissions and model access. |
| 400 / 404 | `invalid_model` | Incorrect path or unavailable model. | Check Base URL and the exact model ID. |
| 404 | `NOT_FOUND` | Incorrect path or unavailable model. | Check Base URL and the exact model ID. |
| 409 | `CONFLICT` | The request ID was already used or the operation conflicts with the current state. | Check the result and billing status in [request history](https://getapi.trade/dashboard?tab=history) before resending. |
| 413 | `body_too_large` | Request too large. | Reduce history or attachments. |
| 413 / 415 | `REQUEST_FAILED` | The request body exceeds a limit or uses an unsupported format. | Fix the request body before retrying. |
| 400 / 404 / 409 / 413 / 422 | `request_rejected` | The model request was rejected; provider-specific error codes are not exposed. | Fix the request body before retrying. |
| 429 | `request_rate_limited` | The request rate limit for the current time window was reached. | Respect Retry-After and reduce concurrency. |
| 429 | `RATE_LIMITED` | Request, token or concurrency limit. | Respect Retry-After and reduce concurrency. |
| 429 | `concurrent_request_limit` | Too many requests are running at once. | Respect Retry-After and reduce concurrency. |
| 429 | `token_rate_limited` | The token allowance for the current time window is exhausted. | Respect Retry-After and reduce concurrency. |
| 429 | `context_upload_busy` | Too many large requests are being uploaded at once. | Respect Retry-After and reduce concurrency. |
| 429 | `request_capacity_busy` | Other running requests temporarily reserve the available balance. | Respect Retry-After and reduce concurrency. |
| 503 | `billing_unavailable` | The rate or billing service is temporarily unavailable. | Retry with backoff and a bounded number of attempts. |
| 503 | `billing_pending` | Usage is being reconciled; the reservation is not a final charge. | Check the result and billing status in [request history](https://getapi.trade/dashboard?tab=history) before resending. |
| 502 / 503 | `provider_unavailable` | Temporary service error. | Retry with backoff and a bounded number of attempts. |
| 503 | `SERVICE_UNAVAILABLE` | Temporary service error. | Retry with backoff and a bounded number of attempts. |
| 500 | `INTERNAL_SERVER_ERROR` | Temporary service error. | Retry with backoff and a bounded number of attempts. |

These are GetAPI codes. Provider messages and codes are not passed through unchanged. For another code, save the HTTP status and request ID for support.

## Common problems

| Symptom or code | Solution |
| --- | --- |
| `context_length_exceeded` | Shorten history or start a new conversation. Input plus maximum output must fit in context. |
| `invalid_output_tokens` / `conflicting_output_tokens` | Use one compatible positive output limit for the selected protocol. |
| `invalid_model` | Fetch available IDs through GET /v1/models. |
| `api_key_expired` | Check the key’s expiry in the dashboard. |
| `spend_cap_exceeded` / `SPEND_CAP_EXCEEDED` | Check the key’s own budget; a positive account balance does not override it. |
| `tool_declarations_missing` | Refresh client configuration and send current tool declarations with call history. |
| 404 in an app | Check whether the app expects a Base URL or a full endpoint. Do not add /v1 twice. |
| Timeout or reset | Check the network, client timeout and direct Base URL. Save any request ID already received. |

## Rate limits and retries

| Result | Retry policy |
| --- | --- |
| 429 | Wait for Retry-After when present. Otherwise increase backoff and reduce concurrency. |
| 5xx | Bounded retries with increasing backoff and jitter. |
| Other 4xx | Fix the request, access or balance first. |
| Disconnect after text or tool delta | Do not replay the entire request automatically. Preserve the partial result and handle the failure. |

Account for SDK retries: do not combine unbounded application loops with automatic client retries. Configure a finite timeout for your task. A new request can become a separate billable generation.

## Usage and billing

| Protocol | Usage fields |
| --- | --- |
| Chat Completions | `prompt_tokens`, `completion_tokens`, `total_tokens` |
| Responses | `input_tokens`, `output_tokens`, `total_tokens` |
| Messages | `input_tokens`, `output_tokens` |

Cache read and write usage can appear in separate protocol-specific fields. Check final charges in [request history](https://getapi.trade/dashboard?tab=history) and current rates on the [pricing page](https://getapi.trade/pricing).

Part of the available balance is reserved before generation. After actual usage is calculated, unused reservation is returned. A failure before billable generation does not imply token usage; for partial responses, check the actual result and settlement status in history.

## What is charged

- Completed requests are billed for input, cache and output at the selected model’s rate. A reservation is not a final charge.
- A confirmed failure before billable generation is not charged, and its reservation is released. Uncertain outcomes are verified first.
- Missing text alone does not mean an empty response: the model may return reasoning or a tool call. An empty result without confirmed usage is not charged.
- Internal routing attempts do not create separate customer charges. A retry sent by your app is a new request and may be billed separately.
- If a stream disconnects after generation starts, completed usage may be charged. Check final usage in request history.
- A model refusal may be billed as a response when usage is confirmed. A rejection before generation is handled as a failed request.
- `billing_pending` means settlement is still being verified. The reservation is released or settled after verification.

## Service limitations

- Availability. Response times, uninterrupted operation and constant model availability are not guaranteed. See current checks on the [status page](https://getapi.trade/service-status).
- Models. The catalog can change as models are added or retired. `GET /v1/models` returns the current models for your key.
- Pricing. Rates can change. Current public rates are on the [pricing page](https://getapi.trade/pricing); an individual key rate may differ.
- Notices. We do not promise advance notice of every price, model or API change. Check current terms before integrating.
- Compatibility. GetAPI supports OpenAI-compatible and Anthropic-compatible protocols. Features depend on the model; support for every parameter is not guaranteed.

## For AI agents

Markdown versions of this help: [Russian](https://getapi.trade/reference/api.ru.md) and [English](https://getapi.trade/reference/api.md). Site index: [llms.txt](https://getapi.trade/llms.txt).

- Read keys from environment variables or a secret store. Never print them or include them in logs, prompts, URLs, commits or client-side code.
- Discover model IDs with `GET /v1/models`. Never guess identifiers.
- Use HTTP status and `error.code`, not the wording of `message`. Handle stream errors even after HTTP 200.
- On 429, wait for `Retry-After`. For 5xx, use increasing backoff and bounded retries. Do not retry an unchanged failing 4xx request.
- After text or tool arguments arrive, do not automatically replay the entire request. Preserve the partial result.
- Model calls cost money. Run loops, load tests or large batches only when the operator explicitly requests them.
- For support, report the GetAPI ID from `X-Request-Id` or `error.request_id`, the model, time and time zone. Do not include keys or private request content.
