Todas as requisições vão para https://genjutsu.top. Envie uma chave de API da Genjutsu como token bearer. POST https://genjutsu.top/v1/media/generate · Authorization: Bearer $GENJUTSU_API_KEY · Escopos necessários: 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"
}
}'
Requisição com parâmetros opcionais
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
Parâmetro
Tipo
Obrigatório
Padrão
Detalhes
prompt
string
Obrigatório
-
até 50000 caracteres
images_list
lista de IDs de ativos de image
Obrigatório
-
Add 1 to 10 PNG, JPEG or WebP reference images. Each image can be up to 20 MiB.
aceita image/png, image/jpeg, image/webp; pelo menos 1 arquivos; até 10 arquivos
count
integer
Opcional
1
intervalo de 1 a 8; passo 1
aspect_ratio
um de
Opcional
"16:9"
"16:9"
"9:16"
"1:1"
"4:3"
"3:4"
image_resolution
um de
Opcional
"none"
"none"1K
"2k"2K
"4k"4K
Requisição mínima
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"
]
}
}'
Requisição com parâmetros opcionais
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"
}
}'
Envie a solicitação para POST /v1/media/generate. Ela responde 202 com um task_id. Consulte GET /v1/media/tasks/{task_id} a cada 5 segundos até is_final ser true: o estado será succeeded, failed ou cancelled e a mesma tarefa traz o resultado (outputs) ou o erro (error_code e error_message). Repetir o envio com a mesma Idempotency-Key devolve a tarefa original. Os IDs e URLs das respostas são ilustrativos.
# 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}'
Os erros usam códigos em minúsculas e trazem retryable e request_id. Um cancelamento pendente não é um cancelamento: se o modelo terminar mesmo assim, a tarefa ainda pode ser cobrada. Veja a referência da API para cancelar.
API estilo recurso (alternativa)
POST /v1/generations aceita os mesmos valores em inputs (e um quote_id opcional) e responde com um recurso generation: consulte GET /v1/generations/{id} pelo id até o status ser succeeded, failed ou cancelled e depois busque GET /v1/generations/{id}/result. Os erros usam códigos em MAIÚSCULAS. Novas integrações devem preferir a API media acima; ambas usam o mesmo processo e os mesmos preços.
# 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"