OpenAI: GPT Image 2
piapi.image-gen.gpt-image-2Generate images with GPT Image 2 (medium quality only) through PiAPI's OpenAI-shaped async route.
- Price
- $0.169/successAt provider cost
- Success rate
- 99.9%Last 30 days · 1,041 calls
- Latency p50
- 528 msp95 778 ms
- Last verified
- Sep 14, 2026Verified working
POSThttps://toolswitch.dev/v1/tools/piapi.image-gen.gpt-image-2Preview- Uses platform quota
- Asynchronous response
- Reads public data
Parameters
This tool has no parameters. See provider docs ↗ Provider docs
Code samples
Replace $TOOLSWITCH_KEY with the key you created in the console.
Preview
curl -X POST 'https://toolswitch.dev/v1/tools/piapi.image-gen.gpt-image-2' \
-H "X-Toolswitch-Key: $TOOLSWITCH_KEY" \
-H "Content-Type: application/json" \
--data-raw '{"n":1,"size":"1024x1024","model":"gpt-image-2","prompt":"A clean editorial illustration of a paper airplane.","quality":"medium"}'import os
import json
import requests
response = requests.request(
"POST",
"https://toolswitch.dev/v1/tools/piapi.image-gen.gpt-image-2",
headers={"X-Toolswitch-Key": os.environ["TOOLSWITCH_KEY"]},
json=json.loads("{\"n\":1,\"size\":\"1024x1024\",\"model\":\"gpt-image-2\",\"prompt\":\"A clean editorial illustration of a paper airplane.\",\"quality\":\"medium\"}"),
)
response.raise_for_status()
print(response.text)const response = await fetch("https://toolswitch.dev/v1/tools/piapi.image-gen.gpt-image-2", {
method: "POST",
headers: {
"X-Toolswitch-Key": process.env.TOOLSWITCH_KEY ?? "",
"Content-Type": "application/json",
},
body: JSON.stringify(JSON.parse("{\"n\":1,\"size\":\"1024x1024\",\"model\":\"gpt-image-2\",\"prompt\":\"A clean editorial illustration of a paper airplane.\",\"quality\":\"medium\"}")),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
console.log(await response.text());This gateway API is in preview; its URL and authentication may change. The example parameters are sample data. Calls are billed at $0.169/success, including the service fee.