Skip to main content

Documentation Index

Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Nano Banana 2 is a high-quality image generation model for text-to-image creation and reference-guided image generation. Use this page when you are ready to call the API after trying the model in the APIXO playground.
CapabilityValue
Model IDnano-banana-2
Modestext-to-image, image-to-image
Prompt length1-20000 characters
Reference imagesRequired for image-to-image; up to 14 URLs
Aspect ratiosauto, 1:1, 1:4, 4:1, 1:8, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9
Resolution tiers1k, 2k, 4k
Output formatspng, jpeg, jpg

Endpoint and authentication

Base URL:
https://api.apixo.ai/api/v1
MethodEndpointPurpose
POST/generateTask/nano-banana-2Submit a generation task
GET/statusTask/nano-banana-2?taskId={taskId}Poll task status and retrieve results
All requests require your APIXO API key:
Authorization: Bearer YOUR_API_KEY
Submit requests also require:
Content-Type: application/json

Copy-paste async quickstart

This minimal request submits a text-to-image task and returns a taskId.
curl -X POST "https://api.apixo.ai/api/v1/generateTask/nano-banana-2" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-image",
      "prompt": "a cozy cyberpunk cafe with neon lights and rain-soaked streets",
      "aspect_ratio": "3:2",
      "resolution": "2k"
    }
  }'
Successful response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Save the taskId; you need it to poll for the final result.

Poll for result

curl -X GET "https://api.apixo.ai/api/v1/statusTask/nano-banana-2?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Processing response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
Success response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/xxx.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
Failed response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates safety policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
Parse resultJson after state becomes success:
const payload = JSON.parse(data.resultJson);
const imageUrls = payload.resultUrls;

Request body

Text-to-image

{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "a fox in watercolor style",
    "aspect_ratio": "16:9",
    "resolution": "2k",
    "output_format": "png",
    "google_search": false
  }
}

Image-to-image

{
  "request_type": "async",
  "input": {
    "mode": "image-to-image",
    "prompt": "make this scene look like sunrise with warm golden light",
    "image_urls": [
      "https://example.com/source.png"
    ],
    "aspect_ratio": "4:5",
    "resolution": "4k",
    "output_format": "jpeg",
    "google_search": false
  }
}

Parameters

request_type
string
default:"async"
required
Result delivery mode. Use async for polling with statusTask, or callback for webhook delivery.
callback_url
string
Required when request_type is callback. Must be a public HTTPS URL that can receive the final task payload. See Webhooks.
input
object
required
Nano Banana 2 input parameters.
aspect_ratio and resolution are required. auto is accepted for aspect_ratio; on some routes it lets the upstream service choose the default framing.

Response format

Submit task response

POST /generateTask/nano-banana-2 returns a task ID when the task is accepted:
code
integer
API status code. 200 means the task was accepted.
message
string
Human-readable status message.
data.taskId
string
Unique task identifier used with the status endpoint.

Status response fields

taskId
string
Unique task identifier.
state
string
Current task state: processing, success, or failed.
resultJson
string
JSON string containing the generated image URLs. Present when state is success.
failCode
string
Machine-readable failure code. Present when state is failed.
failMsg
string
Human-readable failure message. Present when state is failed.
createTime
integer
Task creation timestamp in Unix milliseconds.
completeTime
integer
Task completion timestamp in Unix milliseconds. Present after completion.
costTime
integer
Processing duration in milliseconds. Present after successful completion when available.

Webhook callback mode

Use callback mode when your backend should receive the final result automatically instead of polling.
curl -X POST "https://api.apixo.ai/api/v1/generateTask/nano-banana-2" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "image-to-image",
      "prompt": "turn this product photo into a polished studio ad",
      "image_urls": [
        "https://example.com/product.png"
      ],
      "aspect_ratio": "1:1",
      "resolution": "2k",
      "output_format": "png"
    }
  }'
See Webhooks for delivery requirements and retry behavior.

Billing

Nano Banana 2 is billed per generated image. The selected resolution determines the unit price.
ResolutionAPIXO price
1k$0.05 / image
2k$0.08 / image
4k$0.12 / image
For current route and market comparison pricing, see Pricing.

Latency and polling

Actual latency may vary by prompt complexity, reference image accessibility, selected resolution, route health, and current queue load. The backend returns costTime in milliseconds after completion when timing data is available.
StageGuidance
First pollWait 10s-20s after task creation before the first status request
Poll intervalPoll every 10s while state is processing
Production deliveryUse callback mode for high-concurrency workloads
Result URLs are available for 15 days by default. Download and store important outputs promptly.
Rate limits and concurrency can vary by account, API key, and route. If you receive 429, slow down requests and retry with backoff. For account-level details, see System APIs.

Errors and troubleshooting

HTTP errors

CodeMeaningWhat to do
400Invalid request body, mode, parameter, or image URL shapeFix the request before retrying
401Missing or invalid API keyCheck the Authorization header
402Insufficient balance or quotaAdd balance or switch account/key
403Key or route cannot access the modelCheck permissions and route strategy
429Rate limit or concurrency limit reachedRetry with exponential backoff
500Server or unmapped upstream errorRetry with backoff
502Upstream service errorRetry with backoff
504Upstream timeoutRetry or use callback mode for long-running jobs

Task failure codes

Fail codeMeaningWhat to do
PromptInvalidPrompt was invalid or rejected upstreamRevise the prompt
SensitiveContentPrompt or output violated safety policyChange the prompt or reference image
ImageFormatIncorrectA reference image could not be accepted upstreamUse a public, direct image URL in a common image format
MissingParameterA required upstream parameter was missingCheck mode, prompt, aspect_ratio, resolution, and image_urls
RateLimitedUpstream rate limit was reachedRetry with backoff
TimeoutUpstream timeoutRetry, reduce input complexity, or use callback mode
Unknown errorUpstream failure did not match a known ruleRetry with backoff or contact support with the taskId
See Error Codes for the full error reference.