← All guides

Adding AI Image & Video Generation to a Mobile App — the API Path (2026)

LivePair AI ·

If you're shipping a mobile app that needs AI image or video generation, you don't need a mobile SDK — you need three HTTP calls and one architectural rule. This guide walks through the pattern that keeps your API key safe, the async job model every serious media API uses, and how per-result billing maps to a mobile feature budget.

The one rule: your API key never ships in the binary

Everything in a shipped IPA or APK is extractable — strings, bundled resources, embedded credentials. If your generation API key sits in the app, anyone with apktool can pull it out and spend your balance. This isn't theoretical; leaked-key scraping of mobile binaries is a routine abuse pattern.

The fix is the backend-proxy pattern: your app authenticates to your own backend with whatever user auth you already have, your backend holds the generation key and calls the provider, and results come back through your endpoint. Ten lines of server code buys you rate limiting, per-user quotas, and abuse controls for free — things you'd have had to build anyway.

What the API actually looks like

LivePair's generation API is a two-endpoint async contract: POST /v1/agent/generate with a model id and prompt returns a jobId immediately; GET /v1/agent/jobs/{id} polls until status is done and returns a media URL. No streaming, no sockets — plain JSON over HTTPS, which means any HTTP client in any mobile stack works.

The model catalog at GET /v1/agent/models is free to query, so your backend can list available image and video models and their per-result prices at runtime rather than hardcoding them.

StepEndpointWhat you get
SubmitPOST /v1/agent/generatejobId — returns instantly, doesn't block
PollGET /v1/agent/jobs/{jobId}status → done + media URL
CatalogGET /v1/agent/modelslive model list + pricing, free
BalanceGET /v1/agent/balanceremaining prepaid credit

Why async jobs instead of a blocking response

Image generation takes seconds; video takes tens of seconds to minutes. A synchronous HTTP call held open that long dies to mobile network switches, OS backgrounding, and proxy timeouts. The submit-then-poll pattern survives all of it — your app can background, relaunch, and resume polling the same jobId.

On iOS that pairs naturally with BGTaskScheduler or a push notification when the job completes; on Android, WorkManager. The job id is opaque and single-purpose — polling it from the client is safe if you proxy that call too.

The billing model that fits mobile

Per-result billing maps cleanly to mobile economics: you know the cost of every generation before it's submitted (the job response carries the quote), so an in-app 'credits' system or a free-tier daily cap is just arithmetic on your side. LivePair bills from prepaid credit starting at $5 — a 5-second 720p clip runs about $0.40, images a few cents depending on the model.

For failed or policy-rejected generations nothing settles — you only pay for completed renders. That's the right contract for a mobile feature where users will poke the button to see what happens.

Media handling on the client

Generated media URLs are temporary — LivePair renders auto-delete after 48 hours. If your app shows a history of past generations, download the media when the job completes and store it yourself (S3, your own bucket, local cache). Treat the API URL as a delivery channel, not storage.

For chat-style UIs, render the URL directly and lazy-cache; for gallery features, copy on completion. Video clips land as mp4 — playable in every native player without transcoding.

Putting it together — the minimal integration

A working integration is: (1) one backend endpoint that submits a generation with your key and returns the jobId, (2) one backend endpoint that returns job status, (3) your app polling that second endpoint with an exponential backoff, (4) rendering the media URL when done. Total server code: under 40 lines in any framework.

The full contract — endpoints, auth headers, catalog fields, error shapes — lives in the LivePair docs at /docs/mobile, with client snippets for React Native, Flutter, Swift, and Kotlin. Start there; the pattern above is the whole architecture.

When you'd want more than REST

If your app's agents need to discover and call generation tools autonomously, LivePair also exposes an MCP server (livepairai.com/mcp) and an x402 payment rail where a wallet-carrying agent pays per call in USDC — no API key at all. Overkill for a user-facing app, exactly right for agentic backends.

For bot-style distribution rather than an app, there are also zero-dependency templates for Telegram, Discord, and X posting in the livepair-bots repo — same API, different surface.

FAQ

Can I call the generation API directly from the mobile app?
Technically yes, practically no — your API key would sit in the shipped binary where anyone can extract it and spend your balance. Route through your own backend; it's ~40 lines and gets you rate limiting too.
Do I need a mobile SDK for AI image generation?
No. The whole contract is JSON over HTTPS — submit a job, poll it, get a URL. Any HTTP client in Swift, Kotlin, React Native, or Flutter works; a dedicated SDK adds a dependency without adding capability.
How does billing work for a mobile feature?
Per result from prepaid credit — you see the quote before the job settles, failed generations don't charge, and there's no subscription. A 5-second 720p clip is about $0.40; images are a few cents depending on the model.
What happens to generated media?
Media URLs auto-delete after 48 hours — download and store on your own infrastructure if the app needs history. Generations never enter a public feed, and private-tier models stay off public surfaces entirely.