Read this first: what this API is and is not
If you arrived here wondering how to use nano banana api to produce pictures, the honest answer is that this service cannot do that part. "Nano Banana" is a name people commonly attach to an image-generation model, and image generation is not offered here. What nanobananaapis.com sells is access to a text language model through an OpenAI-compatible endpoint.
That still fits a lot of image workflows, because image tools are only as good as the text you feed them. A text model can write the prompts, vary them, check them against a style sheet, produce captions and alt text, and draft the scripts that glue a pipeline together. This page walks through that use. If you only need pictures, you want an image service instead, and you can pair it with this one.
The model is a single open-weight model, run by an independent provider, tuned to answer without content refusals for lawful adult use. It is not the official API of any big vendor. The one hard limit: no sexual content involving minors.
Step 1: get a key
Sign up with Google, or with an email and password, then open the API key page. You will see a one-click button to claim $0.50 of trial credit. It is valid for 7 days, it needs no card, and it is limited to one per person. A trial key allows 2 concurrent requests and 60 requests per minute, which is plenty for trying things out.
Copy the key and keep it out of your repository. In a shell you can store it like this:
export NANOBANANA_KEY="paste-your-key-here"
Step 2: send your first request
Three values matter: the base URL, the model ID and the Authorization header. Everything else follows the OpenAI chat-completions format. Here is a first call with curl:
curl https://api.nanobananaapis.com/v1/chat/completions -H "Authorization: Bearer $NANOBANANA_KEY" -H "Content-Type: application/json" -d '{
"model": "uncensored",
"messages": [
{"role": "user", "content": "Write one detailed image prompt for a foggy harbor at dawn."}
],
"max_tokens": 200
}'
The same thing in Python with the official openai package:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.nanobananaapis.com/v1",
api_key=os.environ["NANOBANANA_KEY"],
)
r = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write one detailed image prompt for a foggy harbor at dawn."}],
)
print(r.choices[0].message.content)
And in Node:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.nanobananaapis.com/v1",
apiKey: process.env.NANOBANANA_KEY,
});
const r = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Write one detailed image prompt for a foggy harbor at dawn." }],
});
console.log(r.choices[0].message.content);
Check the response headers once. X-Balance-USD shows your remaining credit and X-Request-Id identifies the call if you need help. The docs page lists every supported parameter.
Step 3: turn ideas into structured prompts
The most useful trick for an image pipeline is to make the model return structured data instead of free text. JSON mode does that. You describe the schema in the system message, and the reply parses straight into your code, so a list of rough ideas becomes a table of prompts with fixed fields.
import json, os
from openai import OpenAI
client = OpenAI(
base_url="https://api.nanobananaapis.com/v1",
api_key=os.environ["NANOBANANA_KEY"],
)
SYSTEM = (
"You write prompts for an image model. Reply with JSON only: "
'{"prompts": [{"subject": str, "style": str, "lighting": str, "negative": str, "full": str}]}'
)
def expand(idea: str, n: int = 3):
r = client.chat.completions.create(
model="uncensored",
response_format={"type": "json_object"},
temperature=0.9,
messages=[
{"role": "system", "content": SYSTEM},
{"role": "user", "content": f"Give {n} distinct prompts for: {idea}"},
],
)
return json.loads(r.choices[0].message.content)["prompts"]
for p in expand("a lighthouse keeper's kitchen in winter"):
print(p["full"])
Raise the temperature when you want variety and lower it for consistency. The seed parameter is passed through, so you can pin it when you need to reproduce an earlier batch. Always wrap json.loads in a try block and re-ask once if parsing fails, since any language model can slip.
The site also has a related explainer on the image side of things: prompt generation and post-processing. It covers how the text step connects to a generator.
More jobs a text model does well in an image workflow
- Style sheets. Keep one system message with your fixed style rules and feed each new subject through it, so a whole series stays visually consistent.
- Captions and alt text. After images exist, describe them in a few words each. Pass your own description of the image as input; the model cannot see pictures, because the API takes text only.
- Shot lists and scripts. For a storyboard or a short video, draft the scene list, the voiceover and the on-screen beats as text.
- Prompt critique. Paste a prompt that gives bad results and ask for three rewrites with the changes explained.
- Fiction and character work for adults. Character sheets, backstories and dialogue for stories and companion apps, with the model not refusing lawful adult themes.
For long jobs, stream the output with stream: true so a user interface can show text as it arrives. Tool calling is also supported, which lets a model decide when to call your own function, for example one that submits a prompt to the image service you use.
Limits and what a run costs
Know the numbers before you build a batch. A full key allows 8 concurrent requests and 300 requests per minute. The context window is 100,000 tokens covering prompt and completion, the maximum request body is 8 MB, and max_tokens is optional. Going over the rate returns HTTP 429 with the code rate_limited or concurrency; wait and retry.
Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. Say you generate 500 prompt sets, each with a 400-token input and a 600-token output:
- Input: 500 x 400 = 200,000 tokens x $0.15 / 1M = $0.03
- Output: 500 x 600 = 300,000 tokens x $0.50 / 1M = $0.15
- Total: $0.18
So the $0.50 trial credit covers roughly 1,300 sets of that size. For regular use, top up any whole amount from $20 to $500, by crypto (USDT on TRC20, USDC on Base). Bonuses are 5% from $50, 10% from $100 and 15% from $200. See the pricing page for the table. Credit does not expire.
Pairing it with an image service
The usual setup has two stages. The text stage uses this API to produce prompts. The image stage sends those prompts to whichever image generator you use, and that generator has its own account, its own pricing and its own rules, which you should read on its site. Keep the two stages in separate functions, so you can change either side without rewriting the other.
A practical tip: save every prompt together with the seed and temperature you used to create it. When an image turns out well, you can trace it back to the exact text that produced it, and when a batch disappoints, you can see whether the fault lay in the idea, the prompt writer or the image model. It also gives you a cheap way to compare two system messages by running both on the same list of ideas and judging the two sets of prompts side by side.
A small end-to-end script
To tie the pieces together, here is a short script that reads a file of rough ideas, expands each one into prompts with JSON mode, and writes the result to a file your image tool can read. It handles one failure mode that will otherwise bite you: the reply that is not valid JSON.
import json, os
from openai import OpenAI
client = OpenAI(
base_url="https://api.nanobananaapis.com/v1",
api_key=os.environ["NANOBANANA_KEY"],
)
def one(idea: str):
for _ in range(2):
r = client.chat.completions.create(
model="uncensored",
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": 'Reply with JSON only: {"prompt": str}'},
{"role": "user", "content": f"Write a vivid, specific image prompt for: {idea}"},
],
max_tokens=250,
)
try:
return json.loads(r.choices[0].message.content)["prompt"]
except (json.JSONDecodeError, KeyError):
continue
return None
ideas = [line.strip() for line in open("ideas.txt") if line.strip()]
out = {i: one(i) for i in ideas}
json.dump(out, open("prompts.json", "w"), indent=2)
Run it on five ideas first and read the results by eye. Adjust the system message until the prompts match the style you want, then scale up. Because each request here is small, a thousand ideas finish quickly and cost cents.
Mistakes beginners make
- Expecting pictures. The response is always text. If your code tries to save a binary image from the reply, it will fail, because there is none.
- Looking for a different model name. There is one model, and its ID is
uncensored. Copying a vendor model name from a tutorial gives a not-found error. - Forgetting the system message. Without it, the model has no style guidance and drifts between short and long prompts. Put your rules there.
- Sending secrets in prompts. Prompts are not used for training, but you should still avoid pasting passwords or private keys into any model input.
- Running a hundred requests at once. A full key allows 8 at a time. Use a pool or a semaphore, and add a retry for 429.
If something behaves oddly, the support page is the place to ask, and the request ID from the response headers makes the question much easier to answer.
