Skip to main content

API Documentation

Welcome to the 4oImageApi.io API documentation. This guide will help you understand how to use our API services effectively.

API Services Overview​

We currently offer the following API services:

  1. 4o Image - Create detailed and creative AI-generated images using the advanced GPT-4o multimodal model

    • Text-to-image generation
    • Image-based creation with up to 5 reference images
    • Customizable image dimensions (1:1, 3:2, 2:3)
    • Asynchronous processing with callbacks
    • Task status tracking and progress monitoring
  2. Account Management - Monitor and manage your account information, credit balance, usage quotas, and API access settings

    • Credit balance checking
    • Usage tracking
    • API access management

Basic Information​

Authentication​

All APIs require Bearer Token authentication:

Authorization: Bearer YOUR_API_KEY

To get your API key:

  1. Visit API Key Management Page
  2. Generate your personal API key
  3. Use it in all API requests

Important:

  • Keep your API key secure
  • Never share your API key
  • Reset immediately if compromised

API Services​

4o Image Generation​

The 4o Image API provides AI-powered image generation capabilities:

  • Create AI-generated images via /api/v1/gpt4o-image/generate
  • Support for both prompt-based and image-based creation
  • Reference up to 5 images as inspiration
  • Customize image dimensions with three aspect ratios (1:1, 3:2, 2:3)
  • Query generation task details via /api/v1/gpt4o-image/record-info

Key features:

  • Generated images are stored for 14 days
  • Asynchronous processing with callback notifications
  • Multiple generation statuses for tracking progress:
    • GENERATING: Generation in progress
    • SUCCESS: Generation successful
    • CREATE_TASK_FAILED: Failed to create task
    • GENERATE_FAILED: Generation failed
  • Flexible image creation from text or reference images
  • Maximum query rate of 3 times per second per task

Learn more about 4o Image API →

Error Handling​

Our APIs use standard HTTP status codes along with detailed error messages:

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

Best Practices​

  1. Authentication

    • Store your API key securely
    • Rotate keys periodically for enhanced security
    • Implement proper error handling for authentication failures
  2. 4o Image Generation

    • Provide clear, descriptive prompts for better image generation results
    • When using reference images, consider using multiple for more creative control
    • Specify appropriate aspect ratio based on your application needs
    • Implement proper error handling for different generation statuses
    • Respect the maximum query rate of 3 times per second per task
  3. Account Management

    • Monitor credit usage regularly
    • Implement fallback mechanisms for depleted credits
    • Consider caching responses where appropriate

Need Help?​

If you encounter any issues or have questions, please contact us through:

Language Support

This documentation is available in both English and Chinese. You can switch languages using the language selector in the navigation bar.