All requests go to https://genjutsu.top. Send a Genjutsu API key as a bearer token. POST https://genjutsu.top/v1/media/generate · Authorization: Bearer $GENJUTSU_API_KEY · Required scopes: generate, read, assets
curl -X POST "https://genjutsu.top/v1/media/generate" \
-H "Authorization: Bearer $GENJUTSU_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "nano-banana-2-lite",
"mode": "t2i",
"params": {
"prompt": "A lighthouse on a rocky cliff at golden hour, soft clouds, cinematic light"
}
}'
Request with optional parameters
curl -X POST "https://genjutsu.top/v1/media/generate" \
-H "Authorization: Bearer $GENJUTSU_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "nano-banana-2-lite",
"mode": "t2i",
"params": {
"count": 1,
"prompt": "A lighthouse on a rocky cliff at golden hour, soft clouds, cinematic light",
"aspect_ratio": "16:9",
"image_resolution": "none"
}
}'
nano-banana-2-lite
Image to Image i2i
Parameter
Type
Required
Default
Details
prompt
string
Required
-
up to 50000 characters
images_list
list of image asset IDs
Required
-
Add 1 to 10 PNG, JPEG or WebP reference images. Each image can be up to 20 MiB.
accepts image/png, image/jpeg, image/webp; at least 1 files; up to 10 files
count
integer
Optional
1
range 1 to 8; step 1
aspect_ratio
one of
Optional
"16:9"
"16:9"
"9:16"
"1:1"
"4:3"
"3:4"
image_resolution
one of
Optional
"none"
"none"1K
"2k"2K
"4k"4K
Minimal request
images_list: Replace with the asset ID of your own uploaded image (upload it with POST /v1/assets/uploads first). Accepted types: image/png, image/jpeg, image/webp.
# Media IDs below are placeholders: replace them with your own uploaded assets before running this.
curl -X POST "https://genjutsu.top/v1/media/generate" \
-H "Authorization: Bearer $GENJUTSU_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "nano-banana-2-lite",
"mode": "i2i",
"params": {
"prompt": "A lighthouse on a rocky cliff at golden hour, soft clouds, cinematic light",
"images_list": [
"asset:00000000-0000-4000-8000-000000000001"
]
}
}'
Request with optional parameters
images_list: Replace with the asset ID of your own uploaded image (upload it with POST /v1/assets/uploads first). Accepted types: image/png, image/jpeg, image/webp.
images_list: Replace with the asset ID of your own uploaded image (upload it with POST /v1/assets/uploads first). Accepted types: image/png, image/jpeg, image/webp.
# Media IDs below are placeholders: replace them with your own uploaded assets before running this.
curl -X POST "https://genjutsu.top/v1/media/generate" \
-H "Authorization: Bearer $GENJUTSU_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "nano-banana-2-lite",
"mode": "i2i",
"params": {
"count": 1,
"prompt": "A lighthouse on a rocky cliff at golden hour, soft clouds, cinematic light",
"images_list": [
"asset:00000000-0000-4000-8000-000000000001",
"asset:00000000-0000-4000-8000-000000000002"
],
"aspect_ratio": "16:9",
"image_resolution": "none"
}
}'
Submit the request to POST /v1/media/generate. It answers 202 with a task_id. Poll GET /v1/media/tasks/{task_id} every 5 seconds until is_final is true: the state is then succeeded, failed or cancelled and the same task holds the result (outputs) or the error (error_code and error_message). Repeating the submit with the same Idempotency-Key returns the original task. The IDs and URLs in responses are illustrative.
# Needs curl and jq.
# 1. Submit. The response is 202 with task_id, state and credits_held.
ID=$(curl -s -X POST "https://genjutsu.top/v1/media/generate" \
-H "Authorization: Bearer $GENJUTSU_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "nano-banana-2-lite",
"mode": "t2i",
"params": {
"prompt": "A lighthouse on a rocky cliff at golden hour, soft clouds, cinematic light"
}
}' | jq -r .task_id)
echo "task: $ID"
# 2. Poll every 5 seconds until is_final is true (state is then succeeded, failed or cancelled).
while true; do
TASK=$(curl -s "https://genjutsu.top/v1/media/tasks/$ID" -H "Authorization: Bearer $GENJUTSU_API_KEY")
echo "state: $(echo "$TASK" | jq -r .state)"
[ "$(echo "$TASK" | jq -r .is_final)" = "true" ] && break
sleep 5
done
# 3. The final task carries the result: outputs[].url when succeeded, error_code and error_message when failed.
echo "$TASK" | jq '{state, outputs, error_code, error_message, credits}'
Errors use lowercase codes and carry retryable and request_id. A pending cancellation is not a cancellation: if the model finishes anyway, the task may still be charged. See the API reference for cancelling.
Resource-style API (alternative)
POST /v1/generations takes the same values under inputs (and an optional quote_id) and answers with a generation resource: poll GET /v1/generations/{id} by id until its status is succeeded, failed or cancelled, then fetch GET /v1/generations/{id}/result. Its errors use UPPER_CASE codes. New integrations should prefer the media API above; both run the same pipeline and prices.
# Needs curl and jq.
# 1. Submit. The response is 202 with the generation id.
ID=$(curl -s -X POST "https://genjutsu.top/v1/generations" \
-H "Authorization: Bearer $GENJUTSU_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"mode": "t2i",
"model": "nano-banana-2-lite",
"inputs": {
"prompt": "A lighthouse on a rocky cliff at golden hour, soft clouds, cinematic light"
}
}' | jq -r .id)
echo "generation: $ID"
# 2. Poll until the status is succeeded, failed or cancelled.
while true; do
STATUS=$(curl -s "https://genjutsu.top/v1/generations/$ID" -H "Authorization: Bearer $GENJUTSU_API_KEY" | jq -r .status)
echo "status: $STATUS"
case "$STATUS" in succeeded|failed|cancelled) break ;; esac
sleep 2
done
# 3. Fetch the result (only available once the status is succeeded).
curl -s "https://genjutsu.top/v1/generations/$ID/result" -H "Authorization: Bearer $GENJUTSU_API_KEY"