Aize Platform LogoAize Platform Docs

Error Codes

Understanding API error codes and troubleshooting

Error Codes

This page explains the error codes you might encounter when using the Aize Platform API (https://api.aize.dev/v1) and how to resolve them.

HTTP Status Codes

200 OK

The request was successful.

400 Bad Request

The request was invalid or malformed.

Common causes:

  • Invalid JSON in request body
  • Missing required parameters
  • Invalid parameter values
  • Unsupported model name

Example:

{
  "error": {
    "message": "Invalid request: missing 'messages' field",
    "type": "invalid_request_error",
    "code": "invalid_request"
  }
}

401 Unauthorized

Authentication failed or API key is invalid.

Common causes:

  • Missing Authorization header
  • Invalid API key
  • Malformed API key format

Example:

{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

402 Payment Required

Billing issue or quota exceeded.

Common causes:

  • Insufficient credit or balance
  • Quota limit reached

403 Forbidden

You don't have permission to perform this action.

Common causes:

  • API key doesn't have access to the requested model
  • Key blocked or frozen

404 Not Found

The requested resource doesn't exist.

Common causes:

  • Invalid API endpoint
  • Model name not recognized

429 Too Many Requests

Rate limit exceeded.

Common causes:

  • Too many requests in a short time period
  • Exceeded per-minute request limit

Solution:

  • Implement exponential backoff
  • Reduce request rate

500 Internal Server Error

An error occurred on the server.

Common causes:

  • Temporary service disruption
  • Upstream provider issue

503 Service Unavailable

The service is temporarily unavailable.

Error Response Format

All errors follow this format:

{
  "error": {
    "message": "Human-readable error message",
    "type": "error_type",
    "code": "error_code",
    "param": "field_name"
  }
}

Best Practices

Implement Retry Logic

Retry Example
import time
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.aize.dev/v1"
)

def make_request_with_retry(max_retries=3):
    for attempt in range(max_retries):
        try:
            response = client.chat.completions.create(
                model="gpt-4o",
                messages=[{"role": "user", "content": "Hello!"}]
            )
            return response
        except Exception as e:
            if attempt == max_retries - 1:
                raise

            # Exponential backoff
            wait_time = 2 ** attempt
            print(f"Retry {attempt + 1}/{max_retries} in {wait_time}s")
            time.sleep(wait_time)

Handle Errors Gracefully

Error Handling
try:
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Hello!"}]
    )
except openai.AuthenticationError:
    print("Invalid API key")
except openai.RateLimitError:
    print("Rate limit exceeded, please wait")
except openai.APIError as e:
    print(f"API error: {e.message}")

On this page