Credits API

Manage credits, track usage, and understand pricing for all API operations.

How Credits Work
Every API operation consumes credits based on computational cost
Pay As You Go
Only pay for what you use
Volume Discounts
Save more with larger packages
No Expiration
Credits never expire
Credit Pricing
Credits consumed per operation

Script Generation

GPT-4 (OpenRouter)30 credits / 1K tokens
GPT-3.5 Turbo5 credits / 1K tokens
Claude 3 (Anthropic)25 credits / 1K tokens

Typical Usage

• 60-second script: ~100-150 credits

• Title generation: ~10-20 credits

• Scene breakdown: ~50-80 credits

Credit Management Endpoints
APIs for managing and tracking credit usage
GET/api/credits/balance

Get current credit balance and usage statistics

"text-blue-400 font-semibold">curl https://api.videopilot.app/api/credits/balance \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "balance": 1500,
  "totalUsed": 500,
  "totalEarned": 2000,
  "freeCreditsGiven": "text-blue-400 font-semibold">true,
  "lastUpdated": "2024-01-15T10:00:00Z"
}
GET/api/credits/history

Get credit transaction history

"text-blue-400 font-semibold">curl "https://api.videopilot.app/api/credits/history?limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"
{
  "transactions": [
    {
      "id": "tx_abc123",
      "type": "used",
      "amount": -50,
      "balance": 1450,
      "service": "image_generation",
      "description": "Generated 5 images for video",
      "metadata": {
        "videoId": "video_123",
        "images": 5
      },
      "createdAt": "2024-01-15T09:30:00Z"
    }
  ],
  "hasMore": "text-blue-400 font-semibold">true
}
GET/api/credits/summary

Get aggregated usage summary

"text-blue-400 font-semibold">curl "https://api.videopilot.app/api/credits/summary?period=daily" \
  -H "Authorization: Bearer YOUR_API_KEY"
Credit Headers
Credit information included in API responses

All credit-consuming API calls include these headers in the response:

HTTP/1.1 200 OK
X-Credits-Used: 50
X-Credits-Remaining: 1450
X-Credits-Service: image_generation
X-Credits-Operation: flux-1-dev
Error Responses
Credit-related error handling
{
  "error": "INSUFFICIENT_CREDITS",
  "message": "Insufficient credits for this operation",
  "details": {
    "required": 100,
    "available": 50,
    "service": "script_generation"
  }
}

Best Practices:

  • Always check balance before expensive operations
  • Implement retry logic with exponential backoff
  • Set up webhooks for low balance alerts
  • Cache results when possible to avoid redundant API calls
Admin Credit APIs
Administrative endpoints for credit management (requires admin role)
POST/api/admin/credits/grant

Grant credits to a user

POST/api/admin/credits/revoke

Revoke credits from a user

GET/api/admin/stats

Get system-wide credit statistics