AI API Gateway Webhook Support

Implement real-time event notifications for AI operations. Configure webhooks to receive async updates on model completions, streaming events, rate limits, and error conditions with automatic retry logic.

1
API Request Received
Gateway receives AI API request from client
Complete
2
Processing Initiated
Request forwarded to AI provider, webhook registered
Complete
3
AI Processing
Model generating response, progress updates available
Processing
4
Webhook Delivery
POST notification sent to your endpoint
Pending

Webhook Features

Comprehensive webhook support for AI API integrations.

🔔

Event Notifications

Receive real-time notifications for all API events including completions, errors, and rate limit warnings.

🔄

Automatic Retries

Configurable retry logic with exponential backoff ensures reliable delivery even during temporary outages.

🔐

Signature Verification

HMAC signatures allow you to verify webhook authenticity and prevent fraudulent notifications.

📊

Delivery Analytics

Track webhook delivery success rates, latency metrics, and failure reasons in real-time dashboard.

Streaming Events

Subscribe to streaming token events for real-time progress updates on long-running completions.

🎯

Event Filtering

Configure which events trigger webhooks to reduce noise and focus on relevant notifications.

Event Types

Supported webhook event types and their payloads.

completion

Request Completed

Triggered when an AI request completes successfully.

{ "event": "completion", "request_id": "req_abc123", "model": "gpt-4", "tokens_used": 1250, "latency_ms": 2340, "timestamp": "2024-01-15T10:30:00Z" }
error

Error Occurred

Triggered when a request fails or encounters an error.

{ "event": "error", "request_id": "req_def456", "error_type": "rate_limit", "error_message": "Rate limit exceeded", "retry_after": 60, "timestamp": "2024-01-15T10:35:00Z" }
streaming

Token Streamed

Real-time updates during streaming completions.

{ "event": "streaming", "request_id": "req_ghi789", "token_index": 42, "content": "Hello", "finish_reason": null, "timestamp": "2024-01-15T10:40:00Z" }
budget

Budget Warning

Triggered when spending approaches configured limits.

{ "event": "budget", "org_id": "org_123", "usage_percent": 85, "limit_type": "monthly", "current_spend": 8500, "budget_limit": 10000, "timestamp": "2024-01-15T10:45:00Z" }

Configuration Guide

Configure webhooks for your AI gateway.

webhook_config.yaml Production Ready
# Webhook configuration for AI API Gateway
webhooks:
  # Primary endpoint
  primary:
    url: "https://api.yoursite.com/webhooks/ai"
    secret: "${WEBHOOK_SECRET}"
    enabled: true
    
  # Backup endpoint for redundancy
  backup:
    url: "https://backup.yoursite.com/hooks"
    secret: "${BACKUP_WEBHOOK_SECRET}"
    enabled: true

# Event subscriptions
events:
  subscribe:
    - "completion"
    - "error"
    - "streaming"
    - "budget"
    - "rate_limit"
    
  # Filter rules
  filters:
    completion:
      models: ["gpt-4", "gpt-4-turbo"]
      min_tokens: 100
    error:
      severity: ["warning", "error", "critical"]

# Retry configuration
retry:
  max_attempts: 5
  backoff_multiplier: 2.0
  initial_delay_ms: 1000
  max_delay_ms: 60000
  retryable_status_codes: [408, 429, 500, 502, 503]

# Security settings
security:
  signature_algorithm: "sha256"
  signature_header: "X-Webhook-Signature"
  timestamp_tolerance_ms: 300000  # 5 minutes
  require_https: true

# Delivery settings
delivery:
  timeout_ms: 30000
  concurrent_deliveries: 10
  queue_size: 10000
  retention_hours: 168  # 7 days

Partner Resources