Appearance
Errors
ArtAPI uses standard OpenAI-compatible error responses.
Error Format
All errors follow this structure:
json
{
"error": {
"message": "Human-readable description of the error.",
"type": "error_type",
"code": "error_code"
}
}HTTP Status Codes
| Status | Type | Description |
|---|---|---|
400 | invalid_request_error | Bad request — missing or invalid parameters. |
401 | authentication_error | Invalid or missing API key. |
402 | billing_error | Insufficient credits. Top up at app.artapi.ai. |
429 | rate_limit_error | Too many requests. Slow down or upgrade your plan. |
500 | api_error | Upstream or internal server error. Retry after a delay. |
Common Error Codes
| Code | Cause | Fix |
|---|---|---|
invalid_api_key | Key is malformed, revoked, or belongs to another account | Check Settings → API Keys |
model_not_found | Model ID doesn't exist or isn't available on your plan | See Models |
invalid_size | Requested size not supported by the model | Use a supported size |
prompt_too_long | Prompt exceeds maximum character limit | Shorten your prompt |
content_policy_violation | Prompt or output violates usage policy | Revise the prompt |
insufficient_quota | Not enough credits | Top up at dashboard |
upstream_error | Provider (fal.ai, OpenAI, etc.) returned an error | Retry with backoff |
Handling Errors
python
from openai import OpenAI, APIError, AuthenticationError, RateLimitError
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://app.artapi.ai/v1",
)
try:
response = client.images.generate(
model="flux-dev",
prompt="...",
)
except AuthenticationError:
print("Invalid API key")
except RateLimitError:
print("Rate limit hit — back off and retry")
except APIError as e:
print(f"API error {e.status_code}: {e.message}")Retry strategy
For 500 and 429 errors, implement exponential backoff: wait 1s, 2s, 4s, 8s between retries. Give up after 4–5 attempts.