GPT-4o Image GenerationAPI Documentation
Everything you need to integrate GPT-4o image generation into your applications. Simple API with powerful features.
Getting Started
Quick Start Guide
Follow these simple steps to start using the 4o Image Generation API.
Create an API Key
Create a Generation Task
Retrieve the Results
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
https://open-api.4oimagegen.app/gpt4o-image/generate
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
prompt | string | Yes | The text prompt for the image generation |
filesUrl | array | No | Array of image URLs for reference or transformation |
size | string | No | Image aspect ratio (default: "1:1"). Supported values: "1:1", "2:3", "3:2" |
callBackUrl | string | No | URL 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 |
---|---|---|
Starter | 30 | 1 |
Pro | 50 | 2 |
Business | 60 | 5 |
Enterprise | Custom | Custom |
Rate Limit Headers
API responses include rate limit headers to help you track your usage:
Header | Description |
---|---|
X-RateLimit-Limit | Maximum number of requests allowed per minute |
X-RateLimit-Remaining | Number of requests remaining in the current rate limit window |
X-RateLimit-Reset | Unix 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