Skip to main content
Build a mobile photo editor that lets users choose a photo, pick a model, and describe an edit. The app shows the edited photo when the job completes and lets the user reopen past edits.

1. Set up the app and session

In the management panel, add image_to_image to your app’s Allowed operations. Activate an OpenAI or Replicate credential for the models you want to offer. For a freemium app, set up a free Plan so unsubscribed users can try an edit. Use a stable installation ID to register the device and save the session. The examples use Bash, curl, and jq. Set BACKAPP_APP_KEY, BACKAPP_APP_VERSION, and BACKAPP_ACCESS_TOKEN and run the snippets in the same shell. Keep the same app and user session for every API call.

2. Upload a photo

Let the user pick a photo from their library. Send JPEG, PNG, or WebP up to 10 MiB, 4,096 pixels per side, and 16 million pixels in total. Convert HEIC photos to a supported format before uploading for this workflow. The example assumes a local file named photo.jpg.
HTTP 201 returns file_id and expires_at. Keep the source available until processing finishes. Reuse the same file ID to try another edit while the file is still available.

3. Choose a model and prompt

Populate the model picker from your app’s catalog. Save the selected model’s full id, including the provider prefix. If the catalog is empty, check the app’s provider credentials.
Offer a custom prompt or prefill one for a style such as Watercolor. Ask for the desired change and specify what to preserve. The prompt must be nonblank and no longer than 2,000 characters.

4. Start the edit

Generate and save a request ID for each new edit. If the submission response is lost, resend the same payload with the saved request ID. Backapp can return the existing job while it exists and submission checks pass. Use a fresh ID when the user explicitly starts another edit.
HTTP 202 returns a job. Save its job_id to resume after an app restart. If the API returns model_not_available, refresh the model picker. For HTTP 402 quota_exceeded, explain that the user has reached their allowance and show upgrade options if available.

5. Show the edited photo

Poll the job with a delay while its status is pending or processing. Keep one status request in flight at a time and stop at completed or failed. Resume from the saved job ID when the user returns to the app.
On completion, render result.image.url and use result.image.width and result.image.height to size the preview. This example downloads the result for local display or export.
Use result.image.content_type when choosing a file extension for export. On failure, display the job error and offer retry when error.retryable is true. See Image to Image for complete response examples.

6. Show edit history

List completed image transforms for the current app and user. Show the edited image, prompt, and creation time in each row. Use job_id to reopen an edit through the same status endpoint.
Results are newest first. If next_cursor is a string, send it as the cursor query parameter with the same filters to load the next page. A null cursor marks the last page. Job retention days controls how long the edit appears in history. File retention hours controls how long the source and edited photos are kept. An edited photo can expire while the job is still listed. Show an unavailable state if its URL returns HTTP 404 and let users export results before they expire. See Files and Jobs.