Skip to main content

Common API Quickstart

Essential utility APIs for account management and file operations

Welcome to Common API

The Common API provides essential utility services for managing your Apikley account and handling generated content. These APIs help you monitor credit usage and access generated files efficiently.

Get Account Credits

Check your current credit balance and monitor usage

Get Download URL

Generate temporary download links for generated files

Authentication

All API requests require authentication using Bearer tokens. Please obtain your API key from the API Key Management Page.
Please keep your API key secure and never share it publicly. If you suspect your key has been compromised, reset it immediately.

API Base URL

Authentication Header

Quick Start Guide

Step 1: Check Your Credit Balance

Monitor your account credits to ensure sufficient balance for continued service:
Response:

Step 2: Get Download URL for Generated Files

Convert generated file URLs to temporary downloadable links:
Response:
Download URLs are valid for 20 minutes only. Make sure to download or cache the content within this timeframe.

API Overview

Get Account Credits

GET /api/v1/chat/credit

Purpose: Monitor your account credit balanceFeatures:
  • Real-time credit balance retrieval
  • No parameters required
  • Instant response
  • Essential for usage monitoring
Use Cases:
  • Check credits before starting generation tasks
  • Monitor credit consumption patterns
  • Plan credit replenishment
  • Implement credit threshold alerts

Get Download URL

POST /api/v1/common/download-url

Purpose: Generate temporary download links for generated filesFeatures:
  • Supports all Apikley generated file types (images, videos, audio, etc.)
  • 20-minute validity period
  • Secure authenticated access
  • Only works with Apikley generated URLs
Use Cases:
  • Download generated content to local storage
  • Share temporary links with team members
  • Integrate with external systems
  • Build custom download workflows

Practical Examples

Credit Monitoring System

Implement an automated credit monitoring system:

Error Handling

Common errors and handling methods:

Best Practices

  • Monitor regularly: Check credits before starting large batch operations
  • Set up alerts: Implement automated alerts when credits fall below threshold
  • Budget planning: Track credit consumption patterns for better planning
  • Graceful degradation: Handle insufficient credit scenarios appropriately
  • Time-sensitive: Download URLs expire after 20 minutes
  • Cache appropriately: Save files immediately after getting download URLs
  • Batch downloads: Process multiple files efficiently within time limit
  • Error handling: Implement retry logic for failed downloads
  • Parallel processing: Download multiple files concurrently (respect rate limits)
  • Connection pooling: Reuse HTTP connections for multiple requests
  • Timeout settings: Set appropriate timeouts for download operations
  • Progress tracking: Implement progress indicators for long-running operations
  • API key protection: Never expose API keys in client-side code
  • HTTPS only: Always use HTTPS for API requests
  • Key rotation: Regularly rotate API keys for security
  • Access logging: Keep logs of API usage for auditing

Important Notes

Download URL Expiration: Temporary download URLs are valid for 20 minutes only. Make sure to:
  • Download files immediately after getting the URL
  • Implement error handling for expired URLs
  • Cache downloaded content for future use
Credit Balance: Service access will be restricted when credits are depleted. Always:
  • Monitor credit balance regularly
  • Set up low-credit alerts
  • Plan credit replenishment in advance
  • Implement graceful degradation when credits are low
Supported URLs: The download URL endpoint only supports files generated by Apikley services. External file URLs will result in a 422 validation error.

Status Codes

200
Success
Request processed successfully
401
Unauthorized
Authentication credentials are missing or invalid
402
Insufficient Credits
Account does not have enough credits to perform the operation
404
Not Found
The requested resource or endpoint does not exist
422
Validation Error
Invalid request parameters (e.g., external URL not supported)
429
Rate Limited
Request limit has been exceeded for this resource
455
Service Unavailable
System is currently undergoing maintenance
500
Server Error
An unexpected error occurred while processing the request
505
Feature Disabled
The requested feature is currently disabled

Next Steps

Get Account Credits

Learn how to check and monitor your credit balance

Get Download URL

Master file download URL generation

Integration Examples

Market APIs

Explore AI model marketplace APIs

File Upload API

Upload files for processing

Support

Need help? Our technical support team is here to assist you.

Ready to start? Get your API key and begin using Common API services immediately!
To find navigation and other pages in this documentation, fetch the llms.txt file at: https://docs.apikley.ru/llms.txt