Browse all docs & guides
On this page
OPERATION & PLATFORM GUIDE

Generate images from text prompts

OpenGen routes text-to-image prompts across 25 exact model variants through one canonical request schema. Discover models with GET /v1/models?operation=text-to-image, inspect exact pricing and resolution tiers via GET /v1/models/{provider}/{model}, verify spend with POST /v1/pricing/estimate, and submit once with a persisted Idempotency-Key. All generated outputs stay private to your workspace and download through short-lived first-party capability URLs.

operation: text-to-imageReviewed 2026-12-02
AGENT PROMPT · PASTE INTO YOUR AGENT OR AUTO-READ
Walk me through a text-to-image generation on OpenGen (https://opengen.dev):
1. Discover image models with GET https://opengen.dev/v1/models?operation=text-to-image (or MCP find_models with operation="text-to-image").
2. Inspect the selected exact model's schema, regional routes, privacy disclosures, and published pricing in one call via GET https://opengen.dev/v1/models/{provider}/{model}?operation=text-to-image (or MCP get_model, e.g. id="openai/gpt-image-2", operation="text-to-image").
3. Run a stateless dry-run estimate with POST https://opengen.dev/v1/pricing/estimate (or MCP estimate_cost) using the exact canonical payload.
4. Show me the selected route, published unit pricing, workspaceEligibility, and recommendedMaxCostMicros, and wait for my confirmation of the route and maxCostMicros cap before spending.
5. After I confirm, persist a unique Idempotency-Key and submit once via POST https://opengen.dev/v1/generations (with Prefer: wait=20) or MCP generate (with waitMs=20000).
6. If still pending, poll GET https://opengen.dev/v1/generations/{id}/status or MCP job_get without ever creating a second Idempotency-Key. When delivered, return clickable private output links alongside the job ID and expiresAt.
View raw .md ↗

OpenGen lets you generate private images across official and partner routes using a single canonical payload (modelId, operation: "text-to-image", and typed input). Rather than rewriting SDK calls for every vendor, you inspect one model schema, verify exact pricing with a stateless dry run, and submit once under a persisted Idempotency-Key.

Prerequisites

  • An OpenGen workspace API key with read and generate scopes (OPENGEN_API_KEY), an OAuth MCP connection to https://opengen.dev/mcp, or a logged-in @opengen-dev/cli session (see Authentication and Client Setup).
  • Prepaid workspace credit for billing: "managed" or an encrypted workspace provider connection for billing: "byok".
  • Zero authentication is needed for Steps 1 and 2 (GET /v1/models, GET /v1/models/{provider}/{model}, and https://opengen.dev/mcp/readonly).

1. Choose an exact image model and inspect its schema

Start by listing models registered for text-to-image, then inspect the exact variant you plan to call. Never merge derivatives by marketing name—each variant exposes its own resolutions, quality tiers, and output formats.

For a fast, live-verified baseline, this walkthrough uses GPT Image 2 (openai/gpt-image-2, official route openai-undisclosed/openai-gpt-image-2, live-verified for text-to-image at 1K). If you want low flat per-image pricing, compare FLUX 3 Klein (bfl/flux-3-klein, published $0.008 at 768sq and $0.009 at 1K; live-verified for text-to-image at 768sq, with 1K also exercised in hosted comparison smoke) or Seedream 5.0 Flash (bytedance/seedream-5.0-flash, flat $0.018 across 1K–2K on BytePlus ModelArk Singapore; live-verified for text-to-image at 1K).

# Compact model list filtered by operation (unauthenticated)
curl --fail-with-body \
  "https://opengen.dev/v1/models?operation=text-to-image"

# Single-call schema, regional routes, privacy disclosures, and published pricing
curl --fail-with-body \
  "https://opengen.dev/v1/models/openai/gpt-image-2?operation=text-to-image"

Canonical text-to-image input fields

FieldRequiredNotes
promptYesNon-empty description (up to 32,000 chars on openai/gpt-image-2).
resolutionOptionalModel-specific tier (1K, 2K, 4K on openai/gpt-image-2; default 1K). Mutually exclusive with size.
aspectRatioOptionalCommon ratios such as 1:1, 16:9, 9:16, 3:2, 4:5 (default 1:1). Mutually exclusive with size.
sizeOptionalExplicit { width, height } object on models that support custom dimensions (multiples of 16 on GPT Image).
qualityOptionalauto, low, medium, or high on openai/gpt-image-2 (default medium).
outputFormatOptionalpng, jpeg, or webp (bfl/flux-3-image supports png and jpeg only).
backgroundOptionalauto, opaque, or transparent (requires png or webp when transparent).
countOptionalNumber of images (1–10 on openai/gpt-image-2; varies by variant).

2. Estimate cost and verify route eligibility

Before reserving credits or invoking an upstream provider, pass your exact payload to POST /v1/pricing/estimate (or MCP estimate_cost). When authenticated with a read-scoped credential, the response includes per-route estimatedCostMicros, recommendedMaxCostMicros, and workspaceEligibility.

set -eu
umask 077
if [ -e t2i-submission.key ]; then
  echo "Existing t2i-submission.key found; recover read-only via GET /v1/generations/lookup before replacing request.json." >&2
  exit 1
fi
rm -f request.json
cat <<'JSON' > request.json
{
  "modelId": "openai/gpt-image-2",
  "operation": "text-to-image",
  "input": {
    "prompt": "A brushed brass maritime compass resting on natural oatmeal linen, soft morning window light, shallow depth of field.",
    "resolution": "1K",
    "aspectRatio": "1:1",
    "quality": "low",
    "outputFormat": "png"
  },
  "routeId": "openai-undisclosed/openai-gpt-image-2",
  "billing": "managed",
  "maxCostMicros": 50000
}
JSON
chmod 600 request.json

curl --fail-with-body \
  -X POST "https://opengen.dev/v1/pricing/estimate" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  --data @request.json

maxCostMicros is an integer micro-USD spend ceiling (50000 micro-USD = $0.05). For token-billed models such as openai/gpt-image-2, OpenGen reserves a conservative upper bound at admission and settles the exact reported upstream usage once the provider finishes, releasing any unused hold back to your workspace balance.

3. Submit once with an Idempotency-Key

Persist the request body and a freshly generated Idempotency-Key before submitting. For fast image models, send the standard RFC 7240 Prefer: wait=20 header (clamped to 0–25 seconds) on REST, waitMs: 20000 on MCP, or --wait 20 on the CLI so completed renders return 200 OK with private output URLs in a single round trip. If the render takes longer than the wait window, OpenGen returns 202 Accepted with the durable job ID and Location header.

set -eu
umask 077
if [ -e t2i-submission.key ]; then
  echo "Existing t2i-submission.key found; recover read-only via GET /v1/generations/lookup before creating a new submission." >&2
  exit 1
fi
RAW_UUID="$(uuidgen)"
[ -n "$RAW_UUID" ] || { echo "uuidgen failed" >&2; exit 1; }
IDEMPOTENCY_KEY="t2i-$(printf '%s' "$RAW_UUID" | tr '[:upper:]' '[:lower:]')"
(set -C; printf '%s\n' "$IDEMPOTENCY_KEY" > t2i-submission.key)

curl --fail-with-body \
  -X POST "https://opengen.dev/v1/generations" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Prefer: wait=20" \
  --data @request.json > generation-receipt.json

4. Poll, recover, and download private outputs

If the submission returned 202 Accepted (or deliveryStatus: "pending"), follow the existing job ID with GET /v1/generations/{id}/status?waitMs=25000 (passing the returned revision as afterRevision on subsequent polls), then fetch fresh signed output links with GET /v1/generations/{id}.

# Check status and wait up to 25s for changes
curl --fail-with-body \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  "https://opengen.dev/v1/generations/$JOB_ID/status?waitMs=25000"

# Fetch fresh first-party /media/... capability URLs and settled cost
curl --fail-with-body \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  "https://opengen.dev/v1/generations/$JOB_ID"

Next steps

Supported Models

Live catalog inventory for text-to-image (24 documented variants). Click any model to compare exact regional routes, privacy disclosures, and source-linked tariffs, or inspect its canonical schema directly via the single-call model endpoint.

ModelCreatorRoutesLowest published priceSingle-call API
bytedance/seedream-5.0-pro
ByteDance5 routes$0.03825 / imageGET /v1/models/bytedance/seedream-5.0-pro?operation=text-to-image
openai/gpt-image-2
OpenAI5 routes≈$0.0044 / imageGET /v1/models/openai/gpt-image-2?operation=text-to-image
bfl/flux-3-image
Black Forest Labs2 routes≈$0.0283 / imageGET /v1/models/bfl/flux-3-image?operation=text-to-image
FLUX 3 KleinOpen weights
bfl/flux-3-klein
Black Forest Labs2 routes$0.008 / imageGET /v1/models/bfl/flux-3-klein?operation=text-to-image
bytedance/seedream-5.0-flash
ByteDance2 routes$0.018 / imageGET /v1/models/bytedance/seedream-5.0-flash?operation=text-to-image
google/nano-banana-2-lite
Google2 routes≈$0.0336 / imageGET /v1/models/google/nano-banana-2-lite?operation=text-to-image
minimax/h3-image-highspeed
MiniMax2 routes≈$0.0156 / imageGET /v1/models/minimax/h3-image-highspeed?operation=text-to-image
fal/qwen-image-3
fal1 route$0.04 / imageGET /v1/models/fal/qwen-image-3?operation=text-to-image
alibaba/qwen-image-3.0-pro
Alibaba7 routes$0.03438 / imageGET /v1/models/alibaba/qwen-image-3.0-pro?operation=text-to-image
alibaba/qwen-image-2.1-pro
Alibaba6 routes$0.035333 / imageGET /v1/models/alibaba/qwen-image-2.1-pro?operation=text-to-image
qwen/image-2.1-turbo
Qwen6 routes$0.014133 / imageGET /v1/models/qwen/image-2.1-turbo?operation=text-to-image
google/nano-banana-2.1
Google5 routes$0.0336 / imageGET /v1/models/google/nano-banana-2.1?operation=text-to-image
openai/gpt-image-2.5-flare
OpenAI5 routes≈$0.0056 / imageGET /v1/models/openai/gpt-image-2.5-flare?operation=text-to-image
openai/gpt-image-2.5-sunburst
OpenAI5 routes≈$0.0056 / imageGET /v1/models/openai/gpt-image-2.5-sunburst?operation=text-to-image
xai/grok-imagine-image-2.0
xAI5 routes$0.04 / imageGET /v1/models/xai/grok-imagine-image-2.0?operation=text-to-image
bytedance/seedream-4.0
ByteDance2 routes$0.03 / imageGET /v1/models/bytedance/seedream-4.0?operation=text-to-image
bytedance/seedream-4.5
ByteDance2 routes$0.04 / imageGET /v1/models/bytedance/seedream-4.5?operation=text-to-image
bytedance/seedream-5.0-lite
ByteDance2 routes$0.035 / imageGET /v1/models/bytedance/seedream-5.0-lite?operation=text-to-image
bytedance/seedream-5.5
ByteDance2 routes$0.02 / imageGET /v1/models/bytedance/seedream-5.5?operation=text-to-image
google/nano-banana-2
Google2 routes≈$0.0448 / imageGET /v1/models/google/nano-banana-2?operation=text-to-image
google/nano-banana-pro
Google2 routes≈$0.1344 / imageGET /v1/models/google/nano-banana-pro?operation=text-to-image
minimax/h3-image
MiniMax2 routes≈$0.0078 / imageGET /v1/models/minimax/h3-image?operation=text-to-image
openai/gpt-image-2.6-flare
OpenAI2 routes≈$0.0247 / imageGET /v1/models/openai/gpt-image-2.6-flare?operation=text-to-image
openai/gpt-image-2.6-sunburst
OpenAI2 routes≈$0.0247 / imageGET /v1/models/openai/gpt-image-2.6-sunburst?operation=text-to-image