GPT-4o Image GenerationAPI Documentation

Everything you need to integrate GPT-4o image generation into your applications. Simple API with powerful features.

RESTful API
Webhook Support
API Key Authentication
High Rate Limits

Getting Started

Quick Start Guide

Follow these simple steps to start using the 4o Image Generation API.

1

Create an API Key

Purchase credits and create an API key from your 4o Image Generation account to start using the API.
2

Create a Generation Task

Send a request to the API with your prompt and options to create a new image generation task.
3

Retrieve the Results

Poll the task status or use webhooks to be notified when your image is ready, then download the result.

Authentication

API Authentication

All API requests require authentication using an API key.

Authentication Header

Include your API key in the Authorization header of all requests using the Bearer token format.

Authorization: Bearer YOUR_API_TOKEN

Example:

curl -X POST https://open-api.4oimagegen.app/gpt4o-image/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{"prompt": "A professional restaurant menu with elegant typography"}'

API Reference

API Endpoints

Comprehensive documentation for all available API endpoints.

Create Image Generation Task

Submit a new image generation task to the API.

Endpoint

POST https://open-api.4oimagegen.app/gpt4o-image/generate

Request Parameters

Parameter Type Required Description
promptstringYesThe text prompt for the image generation
filesUrlarrayNoArray of image URLs for reference or transformation
sizestringNoImage aspect ratio (default: "1:1"). Supported values: "1:1", "2:3", "3:2"
callBackUrlstringNoURL to receive webhook notification when the task completes

Code Example

const axios = require('axios');
let data = JSON.stringify({
  "filesUrl": [
    "https://example.com/image1.png",
    "https://example.com/image2.png"
  ],
  "prompt": "Convert the image to a studio ghibli style",
  "size": "1:1",
  "callBackUrl": "https://your-callback-url.com/callback"
});

let config = {
  method: 'post',
  url: 'https://open-api.4oimagegen.app/gpt4o-image/generate',
  headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
                          

Response Examples

Success Response
{
  "code": 200,
  "msg": null,
  "data": {
    "taskId": "1234567890"
  }
}
Error Response
{
  "code": 400,
  "msg": "Invalid request parameters",
  "data": null
}

Usage Limits

API Rate Limits

Understand the rate limits for the 4o Image Generation API.

Standard Rate Limits

The following rate limits apply to the 4o Image Generation API:

Plan Requests per Minute Concurrent Tasks
Starter301
Pro502
Business605
EnterpriseCustomCustom

Rate Limit Headers

API responses include rate limit headers to help you track your usage:

Header Description
X-RateLimit-LimitMaximum number of requests allowed per minute
X-RateLimit-Remaining Number of requests remaining in the current rate limit window
X-RateLimit-ResetUnix timestamp (in seconds) when the rate limit will reset

When rate limits are exceeded, the API will return a 429 Too Many Requests response. Implement proper rate limiting and retry logic in your application.

Frequently Asked Questions

Common API Questions

Answers to technical questions about the 4o Image Generation API.

Ready to start building?Get your API key today.

Have questions? Email us at hi@4oimagegen.app