Image Generation API — POST /v1/images/generations with provider routing and cost tracking
2026-03-21
What We Built
OpenAI-compatible image generation endpoint at POST /v1/images/generations. Routes to DALL-E (OpenAI) as primary provider with Stability AI as fallback. Full Guardian cost tracking with per-image pricing based on model, size, and quality.
Why It Matters
Closes a competitive gap — every major AI gateway (Portkey, OpenRouter, Helicone) supports image generation. BrainstormRouter now offers the same with added value: intelligent provider routing, per-image cost tracking, BYOK support, and budget enforcement.
How It Works
curl -X POST https://api.brainstormrouter.com/v1/images/generations \
-H "Authorization: Bearer br-key-xxx" \
-d '{"prompt": "a cat", "model": "dall-e-3", "size": "1024x1024"}'
Response includes X-BR-Estimated-Cost and X-BR-Actual-Cost headers.
Lockstep Checklist
- [x] API Routes:
src/api/routes/images.ts+ mount inserver.ts - [x] TS SDK:
packages/sdk-ts/src/resources/images.ts—images.generate() - [x] Python SDK:
packages/sdk-py/src/brainstormrouter/resources/images.py—images.generate() - [x] MCP Schemas: N/A — not agent-facing
- [x] Master Record: N/A — auto-updated by llms-full.txt generation