Skip to content
API Reference

Error Handling

Understand error codes and how to handle them gracefully.

Error Response Format

All errors return a consistent JSON structure:

JSON
{
"error": {
"message": "Human-readable error description",
"type": "error_type",
"code": "specific_error_code"
}
}

Error Codes

400invalid_request_error

The request body is malformed or missing required fields.

Examples: Invalid JSON, missing 'messages' field, invalid parameters

401invalid_api_key

The API key is missing, invalid, or revoked.

Examples: Missing Authorization header, malformed key, disabled key

402payment_required

Account has insufficient credits or no active subscription.

Examples: Zero balance, expired subscription

403forbidden

Your plan doesn't have access to the requested resource.

Examples: Free tier attempting to use infe-titan model

404model_not_found

The requested model does not exist.

Examples: Typo in model name, deprecated model

429rate_limit_exceeded

You've exceeded your rate limit for requests or tokens.

Examples: Too many requests per minute

500api_error

An unexpected error occurred on our servers.

Examples: Internal server error, temporary outage

502api_error

The upstream inference provider returned an error.

Examples: Provider timeout, service unavailable

Handling Errors

Best practices for error handling:

from openai import OpenAI, APIError, RateLimitError, AuthenticationError
client = OpenAI(
api_key="your-infe-api-key",
base_url="https://api.infe.io/v1"
)
try:
response = client.chat.completions.create(
model="infe-pulse",
messages=[{"role": "user", "content": "Hello!"}]
)
except AuthenticationError:
print("Invalid API key. Check your credentials.")
except RateLimitError:
print("Rate limit exceeded. Wait and retry.")
except APIError as e:
print(f"API error: {e.message}")

Retry Strategy

For transient errors (429, 500, 502), implement exponential backoff:

CodeShould Retry?Recommendation
400NoFix the request
401NoCheck API key
402NoTop up credits
403NoUpgrade plan
429YesWait 1s, then 2s, then 4s...
500YesRetry up to 3 times
502YesRetry with backoff

Troubleshooting

"Invalid API key"

  • Ensure the Authorization header is Bearer YOUR_KEY
  • Check for extra spaces or newlines in the key
  • Verify the key hasn't been revoked in your dashboard

"Insufficient credits"

  • Check your balance in the dashboard
  • Top up or upgrade your plan
  • Reduce token usage with shorter prompts

"Model not found"

  • Use exact model IDs: infe-pulse, infe-titan
  • Check available models with GET /v1/models
  • Some models require higher tiers

Need Help?

If you're encountering persistent errors, include the x-request-id header from the response when contacting support.

Contact Support →