Migrating to Unified Image API from Google AI Studio, fal.ai or Replicate
2 min readWritten by Unified Image API Team
Moving an existing Nano Banana integration here is usually an afternoon: the concepts map one-to-one, and the differences are the parts you'll be glad to delete. Below are the mappings we're asked about most.
The mental model
| Concept | Google AI Studio (Gemini API) | Replicate | Us |
|---|---|---|---|
| Call style | sync generateContent | async prediction | async job |
| Auth | x-goog-api-key | Authorization: Bearer | Authorization: Bearer |
| Result | base64 in response | URL when prediction completes | presigned URL on the job |
| Retry safety | none built in | none built in | mandatory Idempotency-Key |
| Failed call | billed per token | depends | credits auto-refunded |
| Completion push | none | webhooks | signed webhooks |
From Google AI Studio
Google's API is synchronous and returns the image inline as base64. Two changes:
- Split the call.
POST /v1/generations(getid) then pollGET /v1/generations/{id}or usewebhook_url. Your timeout problems disappear: the submit returns in milliseconds regardless of model load. - Fetch instead of decode. Results come as presigned URLs valid 15 minutes — stream them to your storage instead of holding base64 blobs in memory.
diff
- POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent
- {"contents":[{"parts":[{"text":"a red fox in snow"}]}]}
+ POST $BASE/v1/generations
+ {"model":"nanobanana","prompt":"a red fox in snow","resolution":"1K","ratio":"1:1"}The prompt string itself transfers unchanged — same underlying model family, same prompting behaviour.
From Replicate
The shape is already familiar (create prediction → poll/webhook). What changes:
versionhashes → stable model ids (nanobanana,nanobanana-pro) listed atGET /v1/models; no pinning ceremony, routing and failover happen behind the id.input: {...}→ flat body:prompt,resolution(1K/2K/4K),ratio,n,seed, plusimagesfor image-to-image. The legacysizefield ("1024x1024") is still accepted and mapped to the nearest tier and ratio.- Billing: per-second GPU pricing → fixed credits per image, known before you submit (
costin the response), refunded on failure.
The checklist
- Create a key, put real traffic's IP ranges in the key's allowlist.
- Wrap submit with an
Idempotency-Keyper user intent (see our idempotency post). - Map your error handling to
codevalues — the errors table is short. - Run both providers in parallel for a day (credits are prepaid; a test run on the Starter pack costs a few dollars) and compare failure rates before switching DNS-style.
Full request/response schemas with real payloads: API reference. Per-model pricing in USD: models.