OpenAI: GPT Image 2
reapi.image-gen.gpt-image-2Generate or edit one image with GPT Image 2 at a flat per-resolution price.
- Prix
- $0.081/successAu prix catalogue
- Taux de réussite
- 100 %30 derniers jours · 12 465 appels
- Latence p50
- 346 msp95 622 ms
- Dernière vérification
- 14 sept. 2026Vérifié et opérationnel
POSThttps://toolswitch.dev/v1/tools/reapi.image-gen.gpt-image-2Beta- Utilise le quota de la plateforme
- Réponse asynchrone
- Lit des données publiques
Paramètres
| Paramètre | Type | Obligatoire | Description | Exemple |
|---|---|---|---|---|
| Corps (JSON) | ||||
size | chaîne | Facultatif | Aspect ratio. | 1:1 |
model | chaîne | Obligatoire | gpt-image-2 | |
prompt | chaîne | Obligatoire | A clean editorial illustration of a paper airplane. | |
image_urls | tableau | Facultatif | Up to 16 public image URLs for image-to-image. Each URL must answer a plain GET with the raw image bytes and an image/* content-type (signed cloud-storage or CDN links work; file-page hosts such as tmpfiles.org return HTML, and the task then fails unbilled with the vendor's generic upstream error). `treg host <file>` prints a URL that satisfies this. | |
resolution | chaîne | Facultatif | 1k | |
- Corps (JSON)
sizechaîneFacultatifAspect ratio.
Exemple :
1:1modelchaîneObligatoireExemple :
gpt-image-2promptchaîneObligatoireExemple :
A clean editorial illustration of a paper airplane.image_urlstableauFacultatifUp to 16 public image URLs for image-to-image. Each URL must answer a plain GET with the raw image bytes and an image/* content-type (signed cloud-storage or CDN links work; file-page hosts such as tmpfiles.org return HTML, and the task then fails unbilled with the vendor's generic upstream error). `treg host <file>` prints a URL that satisfies this.
resolutionchaîneFacultatifExemple :
1k
Exemples de code
Remplacez $TOOLSWITCH_KEY par la clé créée dans la console.
curl -X POST 'https://toolswitch.dev/v1/tools/reapi.image-gen.gpt-image-2' \
-H "X-Toolswitch-Key: $TOOLSWITCH_KEY" \
-H "Content-Type: application/json" \
--data-raw '{"size":"1:1","model":"gpt-image-2","prompt":"A clean editorial illustration of a paper airplane.","resolution":"1k"}'import os
import json
import requests
response = requests.request(
"POST",
"https://toolswitch.dev/v1/tools/reapi.image-gen.gpt-image-2",
headers={"X-Toolswitch-Key": os.environ["TOOLSWITCH_KEY"]},
json=json.loads("{\"size\":\"1:1\",\"model\":\"gpt-image-2\",\"prompt\":\"A clean editorial illustration of a paper airplane.\",\"resolution\":\"1k\"}"),
)
response.raise_for_status()
print(response.text)const response = await fetch("https://toolswitch.dev/v1/tools/reapi.image-gen.gpt-image-2", {
method: "POST",
headers: {
"X-Toolswitch-Key": process.env.TOOLSWITCH_KEY ?? "",
"Content-Type": "application/json",
},
body: JSON.stringify(JSON.parse("{\"size\":\"1:1\",\"model\":\"gpt-image-2\",\"prompt\":\"A clean editorial illustration of a paper airplane.\",\"resolution\":\"1k\"}")),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
console.log(await response.text());Cette API de passerelle est en version Beta ; son URL et son authentification peuvent changer. Les paramètres de l’exemple sont des données fictives. Les appels sont facturés à $0.081/success, frais de service inclus.