PiAPI
HomeWorkspace
HomeWorkspace
Join Discord
  1. LLM
  • Get Started
    • Overview
    • Quickstart
    • Make Instruction: How to Use PiAPI to Build a Workflow on Make?
  • Endpoints
    • Song(Udio)
      • Song API Task Creation Examples
      • [Udio] Song Extend
      • Get Task
      • Create Task
      • [Udio] Generate Lyrics
    • Kling
      • Lipsync With PiAPI Kling API Examples
      • Motion Brush With PiAPI Kling API Example
      • Kling Elements Video Generation API
      • Kling Effects Video Generation
      • Cancel Task
        • Cancel Tasks
        • Cancel Task
      • Get Task
      • Create Task
      • Kling Virtual Try-On
    • Hailuo
      • Hailuo Director Mode Example
      • Generate Video
      • Get Task
    • Flux
      • Flux with LoRA and Controlnet
      • Available LoRA and Controlnet
      • Flux API with Redux Variation, Fill, Inpaint and Outpaint
      • Create Task
        • Text to Image
        • Image to Image
      • Get task
    • AI Hug
      • Get Task
      • Create Task
    • LLM
      • Use Cases for GPT-4o Image API
      • How To Avoid Timeouts in Completion API
      • GPT-4o Image Generation API
      • LLM API | Basic Completions
        POST
      • Get Task
        GET
    • Midjourney
      • PiAPI Penalties on Midjourney Usage
      • Detailed Explaination on Midjourney Task Result
      • Midjourney V7 API Instructions
      • Create Task
        • Imagine
        • Upscale
        • Variation
        • Reroll
        • Describe
        • Seed
        • Blend
        • Inpaint
        • Outpaint
        • Pan
      • Cancel Task
        • Cancel Task
        • Cancel Tasks
      • Get Task
    • Faceswap
      • Multi Faceswap
      • Image Faceswap
      • Video Faceswap
      • Get Task
    • TTS
      • Zeroshot Text-to-Speech F5-TTS
      • Get Task
    • Trellis
      • Create Task
      • Get Task
    • Luma Dream Machine
      • Cancel Task
        • Cancel Tasks
        • Cancel Task
      • Create Task
      • Get Task
    • WanX
      • Generate WanX Task with LoRA Using PiAPI
      • Available LoRA Types for Wanx
      • Use Cases for Wanx LoRA
      • Use Cases for Wanx Control Camera
      • Create Task
      • Get Task
    • Skyreels
      • Create Task
      • Get Task
    • Framepack
      • Create Task
      • Get Task
    • Hunyuan Video
      • How to Make a Hunyuan API Call
      • Get Task
      • Generate Video
    • Mmaudio
      • Get Task
      • Generate Audio
    • DiffRhythm
      • Generate Audio
      • Get Task
    • Tools
      • File Upload API
      • Video Upscale
      • Video Upscale-Get Task
      • Remove Background API
      • Remove Background-Get Task
      • Segment With Prompt API
      • Segment With Prompt API-Get Task
      • Image Upscale(Super Resolution) API
      • Image Upscale-Get Task
    • PiAPI Account Management
      • PiAPI Account Info
      • Task List Info
      • User Task History
  • Resources
    • Change Log
    • Output Storage
    • Unified API Schema
    • Webhook
    • Bulk Generation Service
    • Billings
    • PiAPI MCP Server
    • Workspace Manual
      • Host-your-account (HYA) | Back-up Account
      • Host-your-account (HYA) | Debug Checklist
      • Host-your-account (HYA) | Connected Account Status
    • Announcements
      • PiAPI 2025 January 1st Pricing Update
  • Legacy Documentation
    • Midjourney
      • Midjourney Webhook
      • Imagine
      • Reroll
      • Upscale
      • Variation
      • Inpaint
      • Outpaint
      • Pan
      • Describe
      • Blend
      • Seed
      • Fetch
      • Multi Fetch
      • Cancel
    • Face Swap
      • Video Faceswap
      • Multi-face-swap
      • Fetch
    • Dream Machine
      • Video Generation
      • Video Extend
      • Get Video Generation
    • Kling
      • Video Generation
      • Video Extend
      • Get Video Generation
  1. LLM

GPT-4o Image Generation API

Use Cases#

gpt-4o native image generation for text-to-image, image-to-image and conversational-image-editing!!
Far more advanced text rendering than Midjourney or Dalle-3

Two Image Generation Models That We Provide#

Model Namegpt-4o-imagegpt-image-1
API TypeThis is a reverse engineered version of ChatGPT image generation feature. It uses LLM APIThis is a relayed version of openai gpt-image-1, it uses Images API and just alter the domain name and auth key
Stream ModeCan only be used in stream modeCan only be used in stream mode
Pricing• $0.02 per successful generation
• $0 for 4xx or 5xx errors
• $0.00066 if response contains no image
Low Quality:
• 1024×1024: $0.011
• 1024×1536: $0.016
• 1536×1024: $0.016
Medium Quality:
• 1024×1024: $0.042
• 1024×1536: $0.063
• 1536×1024: $0.063
High Quality:
• 1024×1024: $0.167
• 1024×1536: $0.25
• 1536×1024: $0.25
ImplementationStream handling required and read below for code examplesStream handling required, with altered domain name and keys
NotesNo image response may indicate content policy violation or downgrade to DALLE-3Refer to OpenAI official pricing for complete details

Important Notes#

For gpt-4o-image: Image generation failures that return 4xx or 5xx errors are not charged
For gpt-image-1: Implementation follows the same pattern as the standard OpenAI Images API with modified domain and auth headers

Request Examples For gpt-4o-image Model#

Here are the examples for gpt-4o-image model, if you are looking for examples around gpt-image-1 model, go to openai offical guid Images API

Simple Text to Image#

curl --location 'https://api.piapi.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
    "model": "gpt-4o-image",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "draw a cyberpunk city"
                }
            ]
        }
    ],
    "stream": true
}'

Simple Image to Image#

curl --location 'https://api.piapi.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
    "model": "gpt-4o-image",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://images.ctfassets.net/kftzwdyauwt9/21orfxKx8HXXGKH8cTOq60/1eb34535ddce9c9e91fab0fad77bc158/minnias_cat_input.png?w=640&q=90&fm=webp"
                    }
                },
                {
                    "type": "text",
                    "text": "Give this cat a detective hat and a monocle"
                }
            ]
        }
    ],
    "stream": true
}'

Multiple Images Input#

curl --location 'https://api.piapi.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
    "model": "gpt-4o-image",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://img.moegirl.org.cn/common/thumb/5/53/Rei_Ayanami.jpg/280px-Rei_Ayanami.jpg"
                    }
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://moegirl.uk/images/e/ef/OP_C057_asuka.jpg"
                    }
                },
                {
                    "type": "text",
                    "text": "merge two image"
                }
            ]
        }
    ],
    "stream": true
}'

Multiple Rounds Conversation#

Different from legacy gpt-4o-image-preview, gpt-4o-image does not have multi rounds feature. It's a WIP feature for gpt-4o-image.
Previous
How To Avoid Timeouts in Completion API
Next
LLM API | Basic Completions