gemini-3.1-flash-image
google/gemini-3.1-flash-imageGenerate an image from a written description.
- token
- Price: $0.5Price: $3.00Price: $60.00
- 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.
| Field | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | What to draw, in plain language. Maximum: 1000 |
| aspect_ratio | string | No | Shape 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. |
| resolution | string | No | Size 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.
| Meter | USD per million tokens |
|---|---|
| Text input | Price: $0.5 |
| Text output | Price: $3.00 |
| Image output | Price: $60.00 |
