Skip to content
exoticrouter.com ↗

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

cURL
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"
}'
Python
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)
TypeScript
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);
  • model has to be an image model: one whose formats in the list of models has images.
  • n asks for more than one image. The rest of the body, size and quality for instance, goes to the model untouched; which of them a model acts on depends on the model.
{
"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.

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.

Python
result = client.images.generate(model="openai/gpt-image-2", prompt="...", timeout=600)
TypeScript
const result = await client.images.generate(
{ model: "openai/gpt-image-2", prompt: "..." },
{ timeout: 600_000 },
);

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
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"
Python
result = client.images.edit(
model="openai/gpt-image-2",
image=open("ribbon.png", "rb"),
prompt="Make the light warmer",
)
print(result.data[0].url)
TypeScript
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);

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.

  • Videos: Start a video, wait for it, fetch it.
  • Errors: Including the ones that arrive after a 200.