JUHE API Marketplace

Tutorial: Generate Images with Nano Banana API in Python & Node.js

3 min read

Introduction

Nano Banana API is a fast, developer-friendly way to turn text descriptions into images. Integrating it through JuheAPI takes minimal setup and lets you switch between models with just one line of code.

Prerequisites

  • API key from JuheAPI
  • Installed Python 3.x or Node.js
  • Basic knowledge of REST API requests

API Basics

Base URL

The Nano Banana API via JuheAPI uses:

https://wisdom-gate.juheapi.com/v1

Available Endpoints

While the example documentation shows text chat completions, the same endpoint path supports image generation models.

Quick Start with JuheAPI

Here’s the curl example for a text model. You’ll replace the model with an image-capable one for text-to-image tasks.

curl --location --request POST 'https://wisdom-gate.juheapi.com/v1/chat/completions' \
--header 'Authorization: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Host: wisdom-gate.juheapi.com' \
--header 'Connection: keep-alive' \
--data-raw '{
  "model": "wisdom-ai-claude-sonnet-4",
  "messages": [
    { "role": "user", "content": "Hello, how can you help me today?" }
  ]
}'

To generate images, change model to the Nano Banana image model ID and adjust payload.

Text-to-Image in Python

Install Dependencies

pip install requests

Full Python Script

import requests
import base64

API_KEY = "YOUR_API_KEY"
url = "https://wisdom-gate.juheapi.com/v1/chat/completions"

payload = {
    "model": "wisdom-vision-gemini-2.5-flash-image",  # Image generation model
    "messages": [
        {
            "role": "user",
            "content": "A futuristic city skyline at sunset, digital art style"
        }
    ]
}

headers = {
    "Authorization": API_KEY,
    "Content-Type": "application/json",
    "Accept": "*/*"
}

response = requests.post(url, json=payload, headers=headers)

if response.status_code == 200:
    data = response.json()
    image_base64 = data.get("choices", [{}])[0].get("message", {}).get("content")
    if image_base64:
        with open("output.png", "wb") as f:
            f.write(base64.b64decode(image_base64))
        print("Image saved as output.png")
    else:
        print("No image returned.")
else:
    print("Error:", response.status_code, response.text)

Text-to-Image in Node.js

Install Dependencies

npm install axios

Full Node.js Script

const axios = require('axios');
const fs = require('fs');

const API_KEY = "YOUR_API_KEY";
const url = "https://wisdom-gate.juheapi.com/v1/chat/completions";

const payload = {
    model: "wisdom-vision-gemini-2.5-flash-image", // Image generation model
    messages: [
        {
            role: "user",
            content: "A fantasy forest with glowing plants, watercolor style"
        }
    ]
};

axios.post(url, payload, {
    headers: {
        Authorization: API_KEY,
        "Content-Type": "application/json",
        Accept: "*/*"
    }
})
.then(res => {
    const data = res.data;
    const imageBase64 = data?.choices?.[0]?.message?.content;
    if (imageBase64) {
        fs.writeFileSync("output.png", Buffer.from(imageBase64, 'base64'));
        console.log("Image saved as output.png");
    } else {
        console.log("No image returned.");
    }
})
.catch(err => {
    console.error("Error:", err.response ? err.response.data : err.message);
});

Switching Models in JuheAPI

Changing models is a single-line edit—just replace the model value. This allows you to move between text-generating models (like wisdom-ai-claude-sonnet-4) and image models (wisdom-vision-gemini-2.5-flash-image) without refactoring.

Benefits

  • One unified endpoint for multiple AI capabilities
  • Minimal code changes for different outputs

Best Practices

  • Handle API responses and errors gracefully
  • Respect rate limits to avoid blocking
  • Store your API key securely in environment variables

Conclusion

Using Nano Banana API through JuheAPI makes text-to-image generation straightforward in both Python and Node.js. With quick model switching and minimal setup, developers can prototype and iterate fast on visual content generation.