Skip to main content

Error Handling

This guide covers how to handle errors from the AgentGate API effectively.

Error Response Format

All API errors follow a consistent format:

Error Categories

Client Errors (4xx)

Errors caused by the request. Fix the request before retrying.

Server Errors (5xx)

Errors on AgentGate’s side. Safe to retry with backoff.

Handling Specific Errors

Authentication Errors (401)

Insufficient Credits (402)

Rate Limiting (429)

Validation Errors (400)

Server Errors (5xx)

SDK Error Types

The TypeScript SDK provides typed error classes:

Run Failures

Run failures are different from API errors. The API call succeeds, but the run itself fails.

Checking Run Status

Webhook Error Handling

Error Monitoring

Logging Best Practices

Metrics to Track

  • Error rate by type (4xx vs 5xx)
  • Rate limit hits
  • Run failure rate by error code
  • Retry success rate

Error Codes

Complete error code reference

Rate Limits

Rate limit details