跳转到主要内容

Endpoints

MethodEndpointDescription
POST/api/v1/generateTask/nano-banana-2Create generation task
GET/api/v1/statusTask/nano-banana-2Query task status

Authentication

All requests require an API Key in the header:
Authorization: Bearer YOUR_API_KEY

Request Body

{
  "request_type": "async",
  "callback_url": "https://...",
  "provider": "auto",
  "input": {
    "mode": "text-to-image",
    "prompt": "...",
    "aspect_ratio": "16:9",
    "resolution": "2K",
    "image_urls": ["..."],
    "output_format": "png",
    "google_search": false
  }
}

Parameters

request_type
string
默认值:"async"
async (polling) or callback (webhook)
callback_url
string
Callback URL, required when request_type=callback (conditional)
provider
string
默认值:"auto"
Routing strategy: auto, value, or official
input
object
必填
Model input parameters
Mode Options:
  • text-to-image — Generate from text description
  • image-to-image — Generate with reference images (up to 14)

Example

Text-to-Image
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",
    "provider": "value",
    "input": {
      "mode": "text-to-image",
      "prompt": "a cozy cyberpunk cafe with neon lights and rain-soaked streets",
      "aspect_ratio": "3:2",
      "resolution": "2K",
      "output_format": "png"
    }
  }'
Image-to-Image
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/callback",
    "provider": "official",
    "input": {
      "mode": "image-to-image",
      "prompt": "make this scene look like sunrise with warm golden light",
      "aspect_ratio": "4:5",
      "resolution": "4K",
      "image_urls": ["https://example.com/ref1.jpg"],
      "output_format": "jpeg"
    }
  }'

Response

POST /api/v1/generateTask/nano-banana-2

Returns taskId on success for subsequent status queries. Success:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Error:
{
  "code": 400,
  "message": "Insufficient credits",
  "data": null
}

GET /api/v1/statusTask/nano-banana-2

Query task execution status and results via taskId.
curl -X GET "https://api.apixo.ai/api/v1/statusTask/nano-banana-2?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Success:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/image.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
Failed:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content does not meet safety guidelines"
  }
}

Status Response Fields

taskId
string
Unique task identifier.
state
string
Current task state: pending, processing, success, or failed.
resultJson
string
JSON string containing resultUrls array. Only present on success. Parse with JSON.parse().
failCode
string
Error code. Only present when state is failed. See Error Codes.
failMsg
string
Human-readable error message. Only present when state is failed.
createTime
integer
Task creation timestamp (Unix milliseconds).
completeTime
integer
Task completion timestamp (Unix milliseconds).
costTime
integer
Processing duration in milliseconds.

Error Codes

CodeDescription
400Invalid parameters or request error
401Invalid or missing API Key
429Rate limit exceeded
Fail CodeDescription
CONTENT_VIOLATIONContent violates safety guidelines
INVALID_IMAGE_URLCannot access provided image URL

Rate Limits

LimitValue
Requests10000 / minute
Concurrent tasks1000
Exceeding limits returns 429 error. Wait and retry.

Tips

  • Prompt length: Nano Banana 2 supports up to 20,000 characters (vs 5,000 in Nano Banana), suitable for detailed descriptions.
  • Resolution: Choose 1K, 2K, or 4K for output resolution; parameter is case-insensitive (e.g. 2k or 2K both valid).
  • Aspect ratio: Full set includes 1:1, 1:4, 1:8, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9, and auto. Some providers may not support all ratios; unsupported values are omitted for that provider.
  • Output format: Use png for lossless/transparency, or jpeg/jpg for smaller files (jpg is normalized to jpeg).
  • Image-to-image: Up to 14 reference image URLs when mode is image-to-image.
  • Callback mode: For high-concurrency scenarios, use callback mode to avoid frequent polling.
  • Image expiration: Result URLs are valid for 15 days. Download and store important outputs promptly.
  • Content moderation: Prompts must comply with content safety guidelines. Violations return CONTENT_VIOLATION.
  • google_search: Optional boolean; when supported by the provider, enables Google search for context. Default false.

Result URLs expire after 15 days. Download and store important outputs promptly. For high-concurrency scenarios, use callback mode to avoid frequent polling.