Authentication and Base URL
Access the nano banana api by pointing your client to https://api.nanobananaapis.com/v1. You need a valid API key in the Authorization header. Sign up on the Get API key page with just an email and password to receive your key instantly. The key is shown immediately after signup. If you lose it, regenerate a new one from your dashboard; the old key stops working right away.
Use Bearer YOUR_API_KEY for every request. The model ID is always uncensored. This endpoint handles text in and text out. It does not generate images, audio, or video. For multimodal pipelines, use this API for prompt writing, script generation, and post-processing.
First Request
Send a standard chat completion request. The API supports the OpenAI format. Replace YOUR_API_KEY with your actual key. This example sends a simple message to the uncensored model.
curl https://api.nanobananaapis.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
}'The response contains the generated text. You can inspect the usage token counts in the response body. The context window is 64,000 tokens total for prompt and completion. Keep your payloads under 8 MB.
Python SDK Example
Use the official OpenAI Python SDK. Set the base URL to the nanobananaapis endpoint. Pass your API key as the api_key. The client will automatically format requests correctly. This method is ideal for backend scripts that need to process text before sending it to an image or video generation service.
from openai import OpenAI
client = OpenAI(base_url="https://api.nanobananaapis.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)The SDK handles streaming and parsing for you. You can iterate over chunks if you enable streaming mode. This approach keeps your code clean and compatible with other OpenAI services if you switch providers later.
Node SDK Example
The Node.js SDK works similarly. Initialize the client with your base URL and key. Call the chat.completions.create method. This is useful for serverless functions or web servers that need to generate scripts dynamically.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.nanobananaapis.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);Ensure you handle errors properly. Common errors include authentication failures (401) if the key is invalid or expired, and rate limits (429) if you exceed 300 requests per minute. The API key is tied to your account, so protect it in your environment variables.
Streaming Responses
Enable streaming by setting stream: true in your request. The API returns a Server-Sent Events (SSE) stream. Each chunk contains part of the generated text. This is essential for real-time applications or when generating long scripts.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Parse the SSE events on your client side. The stream ends when the model finishes generating or hits the context limit. Streaming reduces perceived latency for users. It does not change the pricing; you still pay per token.
Limits, Errors, and Models
Check available models via GET /v1/models. The only model is uncensored. Rate limit is 300 requests per minute per key. Request body must be under 8 MB. Pricing is $0.25 per 1M input tokens and $1.00 per 1M output tokens. Credit never expires. If you run out, top up from $10. Errors: 401 for bad keys, 402 for insufficient credit, 429 for rate limits. No SLA or uptime guarantee is provided. The model blocks sexual content involving minors. It does not refuse other lawful adult or controversial topics.