# Onchain Router Image Generation

> Onchain Router Image Generation is a paid API for AI agents from onchainrouter.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-15).

Generates images from text prompts using Gemini Flash Lite and returns a seven-day hosted URL or base64 JSON, paid per-call via x402

## Facts

- Endpoint: POST https://onchainrouter.dev/v1/images/generations
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/onchain-router-image-generation-6a51eedc
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_JnivsV4aO9sAYtUp7AExR

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability onchain-router-image-generation-6a51eedc -d '<json body>'
```

Example prompt: Generate a square image of a golden retriever running through a field of sunflowers at sunset, and give me back a hosted URL I can use for the next seven days.

## When to prefer this

Choose this endpoint when you need fast, per-call AI image generation billed via x402 crypto micropayments with no subscription, want a ready-to-use seven-day hosted URL without managing your own storage, and are comfortable with square 1:1 format images. It suits agentic workflows where images are generated on demand and the hosted URL lifespan is sufficient. Prefer alternatives if you need multiple images per call, non-square aspect ratios, or persistent long-term image storage.

## Known failure modes

- Prompt too long (exceeds 4000 characters) returns validation error
- Empty or missing prompt returns 400 bad request
- Invalid enum value for image_size or aspect_ratio returns schema validation error
- Payment failure via x402 protocol returns 402 Payment Required
- Hosted URL expires after seven days making previously returned links invalid
- Model unavailability returns 503 or equivalent upstream error

## How this service works

Give agents provider-neutral access to text, image, and speech models with USDC payments on Base, local spending controls, ambiguity-safe recovery, and verified receipts. Stable public npm clients and MIT agent integrations are available now.

## Output

Returns a JSON object containing a data array with the hosted image URL (valid for seven days) or base64 image data, the model name used, creation timestamp, image size, aspect ratio, and the price charged in USD.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "n": {
   "type": "integer",
   "const": 1
  },
  "model": {
   "type": "string",
   "const": "gemini-3.1-flash-lite-image"
  },
  "prompt": {
   "type": "string",
   "maxLength": 4000,
   "minLength": 1
  },
  "image_size": {
   "enum": [
    "1K"
   ],
   "type": "string",
   "default": "1K"
  },
  "aspect_ratio": {
   "enum": [
    "1:1"
   ],
   "type": "string",
   "default": "1:1"
  },
  "response_format": {
   "enum": [
    "url",
    "b64_json"
   ],
   "type": "string",
   "default": "url"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "data": [
   {
    "url": "https://onchainrouter.dev/v1/media/images/00000000-0000-4000-8000-000000000000?access=capability",
    "backed_up": true
   }
  ],
  "model": "gemini-3.1-flash-lite-image",
  "price": {
   "amount": "0.035",
   "currency": "USD"
  },
  "created": 0,
  "image_size": "1K",
  "aspect_ratio": "1:1"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/onchain-router-image-generation-6a51eedc/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from onchainrouter.dev](https://www.zero.xyz/host/onchainrouter.dev/llms.txt)
