Skip to main content

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 -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​

ParameterValuesDefault
modelgpt-image-1required
promptstringrequired
size1024x1024, 1024x1536, 1536x10241024x1024
qualitylow, medium, high, autoauto
n1–41
backgroundstring—
output_formatstring—

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-Rail and bill against prepaid credit when applicable.
  • Wallet: include X-Payment-Rail: wallet. For billable image models, a missing payment signature returns 402 PAYMENT REQUIRED with a PAYMENT-REQUIRED challenge — sign and retry with PAYMENT-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.