97AI.PRO

GPT Image 2 Webhook Guide — Async Task Callbacks

Use GPT Image 2 webhooks when your app cannot keep a browser or server request open while a image to image task completes. Submit the task to `https://97ai.97claude.com/api/generate` with `webhook_url`, store the returned task id, and treat polling as a fallback. Pricing is pay-per-use pricing and failed generations cost $0.

Create a task with webhook_url

Send the generation request from your backend and include a callback URL that your app controls.

curl -X POST https://97ai.97claude.com/api/generate \
  -H "Authorization: Bearer $YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt/gpt-image-2-image-to-image","input":{"prompt":"A cinematic product shot"},"webhook_url":"https://your-app.com/webhooks/97ai"}'

Task state machine

StateMeaningAction
PENDINGTask accepted and queuedStore taskId and show an in-progress state
SUCCESSGeneration completedSave resultUrls, creditsConsumed, and prompt metadata
FAILUREGeneration failed upstreamShow the error and keep billing at $0 for the failed task

Webhook handler checklist

  1. Accept only POST requests at your callback URL.
  2. Verify the task id exists in your database before updating state.
  3. Make the handler idempotent; the same terminal event may be delivered more than once.
  4. Store `resultUrls`, final state, credits consumed, and the original prompt metadata.
  5. Keep polling `GET https://97ai.97claude.com/api/generate/{taskId}` as a fallback if your callback endpoint is unavailable.

Frequently asked questions

Does GPT Image 2 support webhooks?+

Yes. Include `webhook_url` when you create the GPT Image 2 generation task through 97AI.PRO.

Should I use polling or webhooks for GPT Image 2?+

Use webhooks for production and polling for local testing or fallback recovery. Both patterns can coexist safely.

What happens if my webhook endpoint is down?+

Keep the task id and poll the task details endpoint. Your result remains available after the generation finishes.

Are failed GPT Image 2 tasks billed?+

No. Failed tasks cost $0 under 97AI.PRO's zero-risk billing policy.

Can I use a localhost webhook while developing?+

Use a tunnel such as ngrok or Cloudflare Tunnel so 97AI.PRO can reach your local callback endpoint.

Ready to try GPT Image 2?

Sign up on 97AI.PRO, top up with credit card / USDC / Alipay, and get an API key in under 60 seconds.

Related image to image