Image Generation
HPP Router supports image generation via OpenAI's gpt-image-1 model through an OpenAI-compatible endpoint.
POST https://router.hpp.io/v1/images/generations
Request
Wallet
Include both the payment rail header and your API key:
- curl
curl -X POST https://router.hpp.io/v1/images/generations \
-H "apikey: $HPPROUTER_API_KEY" \
-H "X-Payment-Rail: wallet" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A serene mountain landscape at sunset",
"size": "1024x1024",
"quality": "auto",
"n": 1
}'
Parameters
| Parameter | Values | Default |
|---|---|---|
model | gpt-image-1 | required |
prompt | string | required |
size | 1024x1024, 1024x1536, 1536x1024 | 1024x1024 |
quality | low, medium, high, auto | auto |
n | 1–4 | 1 |
background | string | — |
output_format | string | — |
Response
{
"created": 1732700000,
"data": [
{ "b64_json": "..." }
],
"usage": {
"input_tokens": 14,
"output_tokens": 4160,
"total_tokens": 4174
}
}
The image is returned as base64 (b64_json). The usage block reports the token counts used for billing.
Pricing (token-based)
Image generation is billed per token, like chat. For openai/gpt-image-1:
- Input (text tokens): $5 per 1M tokens (
0.000005/ token) - Output (image tokens): $40 per 1M tokens (
0.00004/ token)
Confirm live rates with GET /llm/v1/models.
Higher quality settings consume more output tokens — for example, auto can use roughly 15× the output tokens of low. Choose the lowest quality that meets your needs to control cost.
Wallet payments
All image generation requests require authentication with an API key.
- Quota (default): omit
X-Payment-Railand bill against prepaid credit when applicable. - Wallet: include
X-Payment-Rail: wallet. For billable image models, a missing payment signature returns402 PAYMENT REQUIREDwith aPAYMENT-REQUIREDchallenge — sign and retry withPAYMENT-SIGNATURE(see Errors and Chat Completions — wallet). - After a successful authorized request, usage is logged and wallet settlement proceeds on-chain. Settlement failures are distinct from the initial 402 challenge.