PiAPI
HomeWorkspace
HomeWorkspace
Join Discord
  1. GPT image
  • Get Started
    • Overview
    • Quickstart
    • Make Instruction: How to Use PiAPI to Build a Workflow on Make?
  • Endpoints
    • 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
        • Kontext
      • Get task
    • Gemini
      • Gemini-2.5-flash-image
      • Nano Banana Pro
      • Nano Banana 2
      • Get task
    • Qwen Image
      • Text to Image
      • Image Edit
      • Get task
    • Z-Image
      • Text to Image
      • Get task
    • Seedream
      • Seedream 5 Lite
      • Get Task
    • Faceswap
      • Multi Faceswap
      • Image Faceswap
      • Video Faceswap
      • Get Task
    • 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 Task
        • Cancel Tasks
      • Get Task
      • Create Task
      • Kling Virtual Try-On
      • Kling Effects
      • Kling Sound
      • Kling Avatar
      • Kling Motion Control
      • Kling Turbo
      • Kling 3.0
    • Kling omni
      • Kling o1
      • Kling 3.0 omni
      • Get Task
    • Omni Human
      • OmniHuman 1.5
      • Get task
    • Seedance
      • Moderation and Penalty
      • Model Comparison
      • Seedance 2 preview
      • Seedance 2
      • Video Watermark Remover
      • Get task
    • Veo3
      • Veo3 Text to Video
      • Veo3 Image to Video
      • Veo3.1 Text to Video
      • Veo3.1 Image to Video
      • Get task
    • Sora2
      • Sora2-preview Text to Video
      • Sora2 Text to Video
      • Sora2-Pro Text to Video
      • Sora2 Remove Watermark
      • 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
    • Wan
      • Wan2.6 Text to Video
      • Wan2.6 Image to Video
      • Get task
    • Hailuo
      • Generate Video
      • Get Task
    • Skyreels
      • Create Task
      • Get Task
    • Framepack
      • Create Task
      • Get Task
    • Hunyuan Video
      • How to Make a Hunyuan API Call
      • Available Hunyuan Lora models
      • Get Task
      • Generate Video
    • Luma Dream Machine
      • Create Task
      • Get Task
    • LLM
      • How To Avoid Timeouts in Completion API
      • LLM API | Basic Completions
    • Suno(service stopped)
      • Music(service stopped)
      • Lyrics(service stopped)
      • Get task
    • Song(Udio)
      • Song API Task Creation Examples
      • [Udio] Song Extend
      • Get Task
      • Create Task
      • [Udio] Generate Lyrics
    • Mmaudio
      • Get Task
      • Generate Audio
    • DiffRhythm
      • Generate Audio
      • Get Task
    • Ace Step
      • Create Task
        • Text to Audio
        • Audio to Audio
        • Audio Edit
        • Audio Extend
      • Get Task
    • TTS
      • Zeroshot Text-to-Speech F5-TTS
      • Get Task
    • Trellis
      • Trellis Create Task
      • Trellis2 Create Task
      • Get Task
    • Joycaption
      • Image Caption
      • Get Task
    • 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
    • AI Hug
      • Get Task
      • Create Task
    • Tools
      • File Upload API
      • 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
      • Video Upscale
      • Video Upscale-Get Task
      • Video Remove Background
      • Video Remove Background-Get task
    • PiAPI Account Management
      • PiAPI Account Info
      • Task List Info
      • User Task History
    • GPT image
      • GPT-image API
    • Claude Code
      • Claude Code Usage Guide
  • 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
      • The discontinued support for midjourney
      • Sunsetting Suno
  • Schemas
    • Schemas
      • motion brush
      • Create Task
      • camera control
      • Cancel Params
      • Float2 Point
      • Control Points
      • txt2video-1.3b
      • txt2video-14b
      • txt2video-14b-lora
      • img2video-14b
      • img2video-14b-lora
      • img2video-14b-keyframe
      • img2video-14b-control-camera
      • wan22-txt2video-14b
      • wan22-img2video-14b
      • hunyuan-txt2video-lora
      • Trellis API/text-to-3D
      • Trellis API/image-to-3D
      • Trellis2 API/image-to-3D
      • Kling omni multi shot
      • VideoGenerationRequest
      • TaskRequest
      • VideoGenerationResponse
      • TaskConfig
      • TaskInput
      • TaskResponse
      • ErrorResponse
    • Response
      • Unified-Task-Response
    • RequestBodies
      • Unified-Task-Request-Body
    • config
    • control_net_setting
    • lora_setting
  1. GPT image

GPT-image API

Overview

We provide gpt-image-1, gpt-image-1.5, gpt-image-2 and gpt-image-2-preview API.

Usage & Pricing

gpt-image-2-preview

This is a preview version model, each generation costs $0.10 / image (flat per-call fee — independent of size, quality, or token count).

Token-Based Models (gpt-image-1, gpt-image-1.5, gpt-image-2)

All three share the same text-token rate; image input and image output rates differ per model.

ModelText inputText cached inputImage inputImage cached inputImage output
gpt-image-1$5.00 / 1M$1.25 / 1M$10.00 / 1M$1.25 / 1M*$40.00 / 1M
gpt-image-1.5$5.00 / 1M$1.25 / 1M$8.00 / 1M$1.25 / 1M*$32.00 / 1M
gpt-image-2$5.00 / 1M$1.25 / 1M$8.00 / 1M$1.25 / 1M*$30.00 / 1M

* Image cached input is billed at the same rate as text cached input because our billing system uses a single cached-token rate per model. In practice this only affects repeated image-edit calls that reuse the same reference image within the cache window.

Estimated Cost per Image

These are estimates for output images at common resolutions and quality settings. Input prompt cost is negligible for typical short prompts.

gpt-image-1 ($40 / 1M output)

ResolutionLow QualityMedium QualityHigh Quality
1024×1024~$0.011~$0.042~$0.167
1024×1536~$0.016~$0.063~$0.250
1536×1024~$0.016~$0.063~$0.250

gpt-image-1.5 ($32 / 1M output)

ResolutionLow QualityMedium QualityHigh Quality
1024×1024~$0.009~$0.034~$0.133
1024×1536~$0.013~$0.051~$0.200
1536×1024~$0.013~$0.051~$0.200

gpt-image-2 ($30 / 1M output)

ResolutionLow QualityMedium QualityHigh Quality
1024×1024~$0.008~$0.032~$0.125
1024×1536~$0.012~$0.048~$0.188
1536×1024~$0.012~$0.048~$0.188

Key Points

  • Higher resolutions and quality settings consume more output tokens and cost more per image.
  • Processing an image you provide (as input) is billed at the image-input rate (per model above), which is significantly cheaper than generating one from scratch.
  • gpt-image-2-preview is the only flat-rate model — all others scale with actual token usage.
  • These are estimates; the exact token count for a specific image may vary.

Default Parameter Values

When a parameter is omitted in the request, the following defaults apply:

ParameterDefaultNote
size1024x1024
n1
qualityauto (token-billed models)Upstream may return a higher-than-standard token count under auto. Pass quality=standard explicitly to match the per-image estimates in the tables above. Omitting quality can result in ~2× the standard cost.
qualitystandard (gpt-image-2-preview)Flat-rate; quality choice does not affect price.
response_formatb64_jsonPass response_format=url to get a hosted URL instead.
output_formatpng

Simple Example

curl --location 'https://api.piapi.ai/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
    "model": "gpt-image-2",
    "prompt": "A cute baby sea otter",
    "n": 1,
    "size": "1024x1024",
    "quality": "low",
    "output_format": "jpeg"
}'

Image Edit with Reference Image

Use the /v1/images/edits endpoint to transform an existing image with a natural-language prompt. The request must be multipart/form-data — the reference image is uploaded as a file field named image.

Example (gpt-image-2-preview)

# 1. Prepare a reference image (either download one or use your own local file)
curl -sS -o /tmp/ref.png \
  "https://oss.filenest.top/uploads/1776b813-28cb-4ca7-a82f-6096f4e7c5b7.png"

# 2. Submit the edit request
curl --location 'https://api.piapi.ai/v1/images/edits' \
  --header 'Authorization: Bearer {your-api-key}' \
  --form 'model=gpt-image-2-preview' \
  --form 'prompt=Add a warm sunset background with soft bokeh lights, keep the character unchanged' \
  --form 'n=1' \
  --form 'size=1024x1024' \
  --form 'quality=standard' \
  --form 'response_format=url' \
  --form 'image=@/tmp/ref.png'

Sample Response (HTTP 200)

{
  "data": [
    {
      "url": "https://imagefil.scdn.app/assets/codex/d69c5648-f0d0-4cd3-8860-0d7b1733d274.png"
    }
  ],
  "created": 1776956146,
  "usage": {
    "total_tokens": 1889,
    "input_tokens": 1124,
    "output_tokens": 765,
    "input_tokens_details": {
      "text_tokens": 19,
      "image_tokens": 1105
    }
  }
}

Verified sample roundtrip (~100 s end-to-end):

  • Reference image: https://oss.filenest.top/uploads/1776b813-28cb-4ca7-a82f-6096f4e7c5b7.png
  • Edited output: https://imagefil.scdn.app/assets/codex/d69c5648-f0d0-4cd3-8860-0d7b1733d274.png

Tips

  • If response_format is omitted, the response comes back as b64_json. Pass response_format=url when you want a hosted link instead of inline base64.
  • Processing a reference image you provide is billed at the input-image token rate (per-model table above), which is significantly cheaper than generating one from scratch.
  • Typical latency is 40–100 s depending on input image size and prompt complexity.
Modified at 2026-05-26 05:54:03
Previous
User Task History
Next
Claude Code Usage Guide