gemini-3.1-flash-image

by Google

google/gemini-3.1-flash-image

Generate an image from a written description.

Billed per
token
Price
Text input / 1M tokensPrice: $0.5Text output / 1M tokensPrice: $3.00Image output / 1M tokensPrice: $60.00
Provider
Google
Timeout
5 min

Overview

Generate an image from a text prompt. The request may return RUNNING before the image is ready; poll GET /v1/runs/{runId} until COMPLETED. Returns image content.

After COMPLETED, find image parts in run.output.candidates[].content.parts[].inlineData. Decode each inlineData.data from base64 and use inlineData.mimeType for the file format; other parts may contain text.

Input

These go in the input object of the run request.

FieldTypeRequiredDescription
promptstringYesWhat to draw, in plain language.
Maximum: 1000
aspect_ratiostringNoShape of the image: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8 or 8:1. Square when omitted.
resolutionstringNoSize class of the image: 1K, 2K or 4K. 1K when omitted.

Requests up to 1 MB, prompt up to 1,000 characters.

Example

Use your own API key and a saved idempotency key for each new job. Replace image or media placeholders with your own publicly reachable HTTPS URLs. Keep the same key and request body when recovering a timeout.

# Set once per job; reuse this key and the identical body after a timeout.
: "${AGENTSKY_IDEMPOTENCY_KEY:?Set a unique, saved key for this job}"
curl --fail-with-body https://gateway.agentsky.dev/v1/run \
  -H "authorization: Bearer $AGENTSKY_API_KEY" \
  -H "content-type: application/json" \
  -H "Idempotency-Key: $AGENTSKY_IDEMPOTENCY_KEY" \
  -d '{"provider":"google","endpoint":"gemini-3.1-flash-image","input":{"prompt":"A paper airplane over a city at dusk, flat illustration"}}'
# If status is READY/RUNNING, poll GET /v1/runs/{runId} with the same API key.

Pricing

Prices per million tokens, using your plan when signed in. Read the final customer charge from price.amount.value after the run finishes. A RUNNING response is not the final bill.

MeterUSD per million tokens
Text inputPrice: $0.5
Text outputPrice: $3.00
Image outputPrice: $60.00

Questions