Image generation
POST /v1/images/generations takes the OpenAI image request shape and returns the OpenAI image response shape, so the openai SDK works against it with the base URL swapped.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.inferray.com/v1",
apiKey: process.env.INFERRAY_API_KEY,
});
const result = await client.images.generate({
model: "gemini-3-pro-image-preview",
prompt: "a quartz crystal on a workbench, studio lighting",
n: 1,
});
console.log(result.data[0].b64_json);
curl https://api.inferray.com/v1/images/generations \
-H "Authorization: Bearer $INFERRAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-pro-image-preview",
"prompt": "a quartz crystal on a workbench, studio lighting",
"n": 1
}'
Image models are their own thing
Image models answer on this endpoint only. Sending one to /v1/chat/completions, /v1/responses, or /v1/messages returns a 404 naming the models that endpoint does serve, and the same is true in reverse: a text model on this endpoint is refused rather than forwarded.
The models page marks which models generate images, and GET /v1/models lists them alongside the text models.
Pay-as-you-go keys only
Image generation is billed per picture rather than per token, so it is not covered by a Token Plan. A key from a Token Plan workspace gets a 403 here, and GET /v1/models on that key lists the text models only. Send image requests with a key from a pay-as-you-go project instead.
How image pricing works
Text models are quoted per 1M tokens. Image models are not, and providers do not agree on a single unit:
| Model | Billed | What you see |
|---|---|---|
gemini-3-pro-image-preview | Per generated image, by resolution | $0.10 / image at 1K and 2K, more at 4K |
gpt-image-2 | Per 1M image-output tokens | A per-token price, since no per-image figure is published |
gemini-2.5-flash-image | Per token, like a text model | Standard input and output token prices |
Each model's page shows the unit that model actually bills in, at the rate you pay. No gateway fee is added on top of it, the same as everywhere else.
What you are charged
Your bill is the cost the request actually incurred, at the rate shown for the model. Nothing is estimated from the prompt, and nothing is rounded up to a per-image figure when the provider billed per token. That is why the resolution you ask for changes the price on models that price by resolution: a 4K image genuinely costs more to produce than a 1K one.
Streaming
There is no streaming form of this endpoint. An image request returns once, with the finished image.