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.

This guide walks you through generating an image with Nano Banana using APIXO’s async task flow.

Prerequisites

Let your AI coding tool integrate APIXO for you

If you build with an AI coding tool — Cursor, Claude Code, Codex, Claude Desktop, Windsurf, or any other MCP-compatible client — the fastest way to add APIXO to your project is to install APIXO MCP. It exposes APIXO’s model catalog and schemas to your agent, so the agent can write correct, parameter-accurate integration code straight into your repo — instead of you reading the docs and copying curl examples. Once installed, try a prompt like:
Use the apixo MCP tools. Add a server route to my Next.js app that calls the
nano-banana model to generate a 16:9 image from a `prompt` field in the request
body, and polls the status endpoint until the result URL is ready. Use my
existing fetch helpers and TypeScript types.
The agent will use apixo_list_models and apixo_get_model_schema to look up the model’s exact parameters, then write the generateTask + statusTask flow into your codebase. It can also submit ad-hoc tasks or check your balance when you ask it to.

Install APIXO MCP

Five-minute setup for Cursor, Claude Code, Codex, and other MCP clients on Windows, macOS, and Linux.
Prefer to wire up the API yourself? Continue with the steps below.

Step 1: Submit a Generation Task

curl -X POST https://api.apixo.ai/api/v1/generateTask/nano-banana \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-image",
      "prompt": "A serene Japanese garden with cherry blossoms, golden hour lighting, photorealistic",
      "aspect_ratio": "16:9"
    }
  }'
Response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz"
  }
}

Step 2: Poll for Results

Wait a few seconds, then check the task status:
curl "https://api.apixo.ai/api/v1/statusTask/nano-banana?taskId=task_abc123xyz" \
  -H "Authorization: Bearer YOUR_API_KEY"
Success Response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://cdn.apixo.ai/generated/abc123.jpg\"]}",
    "costTime": 12500,
    "createTime": 1704067200000,
    "completeTime": 1704067212500
  }
}

Step 3: Download Your Image

The resultUrls array contains direct links to your generated images. Open the URL in a browser or download programmatically.
Generated images are available for 24 hours. Download and store important results.

Complete Example

Here’s a complete working example:
const generateImage = async (prompt) => {
  const API_KEY = process.env.APIXO_API_KEY;
  const MODEL = 'nano-banana';
  
  // Submit
  const submit = await fetch(`https://api.apixo.ai/api/v1/generateTask/${MODEL}`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      request_type: 'async',
      input: { mode: 'text-to-image', prompt, aspect_ratio: '1:1' },
    }),
  });
  
  const { data: { taskId } } = await submit.json();
  
  // Poll
  while (true) {
    await new Promise(r => setTimeout(r, 3000));
    const status = await fetch(
      `https://api.apixo.ai/api/v1/statusTask/${MODEL}?taskId=${taskId}`,
      { headers: { 'Authorization': `Bearer ${API_KEY}` } }
    );
    const { data } = await status.json();
    
    if (data.state === 'success') {
      return JSON.parse(data.resultJson).resultUrls;
    }
    if (data.state === 'failed') {
      throw new Error(data.failMsg);
    }
  }
};

// Usage
const urls = await generateImage('A cute robot drinking coffee');
console.log(urls);

Next Steps

How APIXO Works

Learn the difference between Generation APIs and the LLM Gateway

Generation API Overview

Browse image, video, and audio model API docs

LLM Gateway

Use Claude, OpenAI, and Gemini compatible APIs

Best Practices

Optimize polling, retries, and production reliability