> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sharemy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors and limits

> Status codes, error codes, the concurrency limit, and what happens while a job waits for a machine.

## Error format

Errors use OpenAI's shape:

```json theme={null}
{
  "error": {
    "message": "Choose a temperature from 0 to 2.",
    "type": "invalid_request_error",
    "param": "temperature",
    "code": "invalid_value"
  }
}
```

Use `code` to handle errors in your client. `param` names the field when known (for example, `messages[0].role`) and is `null` otherwise. A 402 has type `insufficient_quota`, other 4xx errors have type `invalid_request_error`, and 5xx errors have type `api_error`.

## Status and error codes

| Status | `error.code` | Meaning |
| - | - | - |
| 400 | `invalid_value` | A field failed validation. Check `param`. |
| 400 | `invalid_input` | The network could not process the job input. |
| 400 | `model_not_found` | Choose a model supported by this endpoint. |
| 400 | `unsupported_value` | The API cannot honor the option, such as JSON mode or word timestamps. |
| 400 | `null` | Send a JSON body, or upload audio as multipart form data in the `file` field. |
| 400 | `content_policy_violation` | The request or output failed a [content check](#refused-requests). |
| 401 | `invalid_api_key` | Check the [token or Authorization header](https://docs.sharemy.ai/authentication.md). |
| 402 | `insufficient_quota` | `error.price_credits` gives the job price and `error.balance_credits` gives your balance. |
| 403 | `account_suspended` | The account is suspended. |
| 404 | `not_found` | Unknown endpoint, unknown job id or a job owned by another account. A job lookup names `id` in `param`. |
| 404 | `job_expired` | Your image job finished at least one hour ago. Its result has expired. |
| 404 | `model_not_found` | No catalogue entry for the id in `GET /v1/models/{id}`. |
| 405 | `method_not_allowed` | Wrong method for a known path. The `Allow` header lists its methods. |
| 413 | `file_too_large` | The audio exceeds 25 MB, or an edit's `image` or `mask` exceeds 50 MB. |
| 413 | `image_too_large` | An edit's `image` or `mask` exceeds 4,096 pixels on a side. |
| 413 | `audio_too_long` | The recording exceeds 30 minutes. |
| 415 | `unsupported_image` | The file header is unrecognized, the format is unsupported, or the declared image type differs from the file. |
| 415 | `unsupported_audio` | The audio format is unsupported or the WAV file could not be decoded. |
| 429 | `rate_limit_exceeded` | Four calls are already in flight, or eligible machines stayed busy. |
| 499 | `cancelled` | The caller disconnected before the job finished. The job was cancelled and refunded. |
| 502 | `network_error` | The job failed on the network. |
| 503 | `no_provider` | No machine offers the model or can take this job. |
| 503 | `storage_unavailable` | The API cannot accept an async image job because result storage is unavailable. |

When you poll an [async image job](https://docs.sharemy.ai/api-reference/jobs.md), HTTP 200 can contain `status: "failed"`. Read the job's `error.code`. The code `interrupted` means the network restarted while the job was queued or running. You can submit it again. You aren't charged for the interrupted job.

The API checks the path and method before requiring a token. The bare `/v1` path also returns the API's 404.

## Errors in a stream

With `stream: true`, a refusal at submission still returns an HTTP error with a JSON body. This includes invalid input (400), insufficient credits (402), the account limit (429), and no online machine (503).

Once the API accepts the job and opens the stream with HTTP 200, a later failure arrives as one error event. Its `status` gives the equivalent HTTP status. The stream then closes without `data: [DONE]`. For example, if the machine leaves after sending part of its reply, the partial answer ends here and the job is refunded.

```text theme={null}
data: {"error":{"status":502,"type":"api_error","code":"network_error","param":null,"message":"The machine answering this left mid-reply. Try again; you weren't charged."}}
```

## Concurrency

An account can have **4 job calls in flight** across all its tokens. A submission takes a slot before the API reads the body. A synchronous call holds it until the call or stream ends. An async job holds it until the job finishes. A fifth submission gets `429 rate_limit_exceeded` immediately and costs nothing. Polling and cancellation do not take a slot. The `x-ratelimit-limit-concurrent` and `x-ratelimit-remaining-concurrent` headers give the limit and remaining slots. There is no per-minute call limit.

## No machine for a model

| Machine supply | What happens |
| - | - |
| No machine offers the model at submission | A synchronous call returns `503 no_provider`, with `Retry-After: 30` and `x-should-retry: false`. An async job reports `no_provider` when you poll. |
| An accepted job has no eligible machine | After about a minute with no eligible machine, the job fails with `503 no_provider`. The message identifies the reason. |
| Eligible machines stay busy | The job waits up to 10 minutes in the queue, then fails with `429 rate_limit_exceeded`. |

If the machines have already tried the job, the message can read "Every machine that runs this model tried and couldn't finish it." Check current supply with [the model catalogue](https://docs.sharemy.ai/api-reference/models.md).

If your account is pinned to specific machines and none offers the model, the `no_provider` message says "None of the machines this account may use is running this model right now."

The network hands out waiting jobs oldest first and prefers machines with the model already loaded. A running job can continue while its machine reports progress. If the machine leaves or goes silent for 3 minutes, the network can try another machine, up to 3 machines in all. Once a chat stream has sent part of the reply, a machine failure ends the stream.

## Retrying

* Skip automatic retries when `x-should-retry: false`. A 402 needs more credits, and a content policy error needs a different request. For `no_provider`, wait at least the 30 seconds in `Retry-After` and check for an eligible machine before sending a new job.
* For a 429, wait at least the 1 second in `Retry-After`. If all four account slots are in use, wait for a call to finish. For a transient `502 network_error`, back off before trying again.
* For other 4xx errors, fix the cause first. In an open stream, use the error event's `code` and `status` to decide whether to start a fresh call.
* Set a timeout for how long you can wait. Closing a synchronous call or stream cancels and refunds unfinished work. To stop an async job, use its [cancel endpoint](https://docs.sharemy.ai/api-reference/jobs.md#cancel-a-job).

## Refused requests

Prompts and text are checked before a job is priced or sent to a machine. Pictures are checked on the machine before they are sent back. Requests for sexual content are refused. Refused requests count against the account. Repeated refusals, or the most serious kind, suspend it until a person has reviewed it. See the [terms](https://sharemy.ai/terms).

## Limits

| Limit | Value |
| - | - |
| API calls in flight per account | 4 |
| API tokens per account | 10 |
| Chat messages per call | 1 to 100 |
| Chat text per call | 64,000 characters |
| Chat output token budget | Positive integer, capped at 4,096 |
| Image generation prompt | 1 to 2,000 characters |
| Pictures per call | 1 to 4 for generations, 1 for edits |
| Image edit uploads | 50 MB per file, 4,096 pixels per side |
| Async job retention | 1 hour from completion |
| Speech `input` | 1 to 4,096 characters |
| Audio upload | 25 MB (26,214,400 bytes) |
| Recording length | 30 minutes |
| Wait with no eligible machine after acceptance | About 1 minute |
| Wait for busy machines | Up to 10 minutes |
| Silence before a job moves to another machine | 3 minutes |
| Machines a job is tried on | 3 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.