Images
Make a picture from a prompt, or change one you have. The format is OpenAI’s Images API, whichever lab made the model.
POST https://api.exoticrouter.com/v1/images/generations
Make an image
Section titled “Make an image”curl https://api.exoticrouter.com/v1/images/generations \ -H "Authorization: Bearer $EXOTIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-image-2", "prompt": "A glass ribbon in violet and amber light, studio photograph" }'result = client.images.generate( model="openai/gpt-image-2", prompt="A glass ribbon in violet and amber light, studio photograph",)print(result.data[0].url)const result = await client.images.generate({ model: "openai/gpt-image-2", prompt: "A glass ribbon in violet and amber light, studio photograph",});console.log(result.data?.[0]?.url);modelhas to be an image model: one whoseformatsin the list of models hasimages.nasks for more than one image. The rest of the body,sizeandqualityfor instance, goes to the model untouched; which of them a model acts on depends on the model.
The answer
Section titled “The answer”{ "created": 1796169600, "data": [ { "url": "https://api.exoticrouter.com/v1/files/3fK9…" } ]}Each image comes as a link. Send "response_format": "b64_json" to get the picture itself instead, base64-encoded in b64_json.
- A link needs no key: whoever has it can fetch the image. Treat it as you would the picture.
- A link is not for keeping. It works for some days and then stops, so download what you want to keep.
Slow generations
Section titled “Slow generations”The request stays open until the image is done, which for some models takes minutes. Give your HTTP client a generous timeout.
When an image takes longer than about 80 seconds, the gateway starts the answer early to keep the connection alive: the status is 200 and blank space arrives until the JSON does. JSON parsers skip the space. It also means a failure after that point cannot change the status, so it comes as a 200 whose body is an error object. Check for error before reading data.
result = client.images.generate(model="openai/gpt-image-2", prompt="...", timeout=600)const result = await client.images.generate( { model: "openai/gpt-image-2", prompt: "..." }, { timeout: 600_000 },);Change an image
Section titled “Change an image”POST https://api.exoticrouter.com/v1/images/edits
Send the picture and a prompt as a form. The answer has the same shape as a generation’s. Not every image model edits: a model that does not will refuse the request.
curl https://api.exoticrouter.com/v1/images/edits \ -H "Authorization: Bearer $EXOTIC_API_KEY" \ -F model="openai/gpt-image-2" \ -F image="@ribbon.png" \ -F prompt="Make the light warmer"result = client.images.edit( model="openai/gpt-image-2", image=open("ribbon.png", "rb"), prompt="Make the light warmer",)print(result.data[0].url)import fs from "node:fs";
const result = await client.images.edit({ model: "openai/gpt-image-2", image: fs.createReadStream("ribbon.png"), prompt: "Make the light warmer",});console.log(result.data?.[0]?.url);What it costs
Section titled “What it costs”An image model’s per_request in the list of models is its price per image. You are charged when the image is made; a generation that fails costs nothing.