Polling, Callback, and Streaming: What’s the Difference?
Your AI large model image generation API — how long does it take to produce results? After a request is sent, it can take as little as 5 seconds or as long as 30 seconds. Do you really have to keep waiting for minutes for it to return?
Waiting for one or two requests is fine, but as your user base grows and image generation demand surges, with hundreds or thousands of users generating content simultaneously, the question of “how to wait for the result” directly determines whether your system can handle the load.
At this point, you need to carefully consider one question: How should the action of “waiting for the result” be designed?
Should the client keep asking “Is it ready yet?” (polling)? Or should the server proactively notify the client “Come get the image” once generation is complete (callback)? Or should the data flow like a stream, pushing progress and results to the client as they are generated (streaming response)?
What problems do these three approaches solve respectively? In high-latency, high-concurrency scenarios like AI image generation, how should you choose and implement them?

I. What Problems Do Polling, Callback, and Streaming Response Solve Respectively
Polling — Repeatedly asking “Is it ready yet?” (Recommended)
Polling: The client holds an ID and actively queries the server every few seconds to ask “Is it ready yet?” It’s crude but universal.
For example, you submit an image generation request, and the backend tells you “It will take a while.” You don’t know when it will finish — what do you do? The simplest and most straightforward method: Send a request every few seconds asking — “Is it done? Is it done?” — until the backend returns a “completed” flag, at which point you stop querying.
Callback: Leave an address, and contact me when it’s done
Callback: Once generation is finished, the server proactively sends a request to the address you specified, telling you “Come get the image.” It’s efficient, but requires you to have a publicly accessible server.
The idea of a callback is the opposite — don’t keep asking repeatedly. Tell me in advance who should receive the result and what to do next; I’ll contact you proactively when I’m done.
However, if your server crashes, you may fail to receive the returned content! This needs attention.
Streaming Response — Words popping out one by one
Streaming Response: The server pushes progress and results to the client bit by bit, like a flowing stream.
Streaming responses are different from the two above. Polling and callbacks care about “when the task ends,” while streaming cares about “how the process and results of the task are gradually displayed to the user.”
If you’ve used ChatGPT, you know that when it answers questions, the text appears character by character — that’s a streaming response.
Streaming also has drawbacks: The server needs to maintain long connections. If there are too many concurrent users, the server’s memory and connection count will face significant pressure. Additionally, client-side code is more complex than ordinary requests; it must handle data fragmentation, protocol parsing, disconnection and reconnection, and so on.
II. How to Integrate Grsai API’s Callback and Polling Models
GrsaiAPI (https://grsai.com) is a domestic source API provider offering affordable and stable AI large model API services. Models include Nano banana pro, Nano banana2, Nano banana 2 lite, Gpt image 2, gemini 3.1 pro….. image and language models. It supports OpenAI, Gemini protocol, and responses-api protocol calls. Model list: https://grsai.com/dashboard/models

Currently there are old and new documentation — how to choose? The new documentation is strongly recommended. Nano banana and GPT image models use a unified interface, but only support asynchronous polling. The old documentation has different interfaces for Nano banana and GPT; models cannot be mixed or tasks will get stuck, and it supports both callback webhook parameters and polling.
New documentation: https://qmy27nhsd9.apifox.cn/452409577e0 (Banana GPT unified interface address)
Old documentation: https://grsai.com/dashboard/documents/nano-banana (Banana GPT interface addresses are different)
Below is a detailed explanation of the different query methods for the two documentations.

Grsai API Old Version Documentation: WebHook Callback + Polling Dual Mode
In the Grsai API old version documentation, the Nano banana model interface uses /v1/draw/nano-banana, while GPT image generation uses /v1/draw/completions. The callback control parameter is webHook.

The logic is as follows:
Callback: Provide a webHook address. After generation is complete, the server POSTs the result to that address, and you passively receive it.
Polling: Set webHook to “-1”. The interface immediately returns an ID, which you then use to call the /v1/draw/result interface to poll for results.

Use POST request header configuration:
{
"Content-Type": "application/json",
"Authorization": "Bearer apikey" // apikey should be filled with the secret key created on the Grsai console Apikey page, a code starting with sk.
}Grsai API interface addresses: Note that banana models must use the banana interface, and GPT models must use the GPT interface. Do not call banana models with the GPT interface, or the task will get stuck in progress! The parameters of the two documentations are also different.
Banana request address: https://https://grsaiapi.com/v1/draw/nano-banana
GPT request address: https://https://grsaiapi.com/v1/draw/completionsCallback request parameter usage:
{
"model": "nano-banana-pro", // model
"prompt": "prompt", // prompt
"aspectRatio": "auto", // size
"imageSize": "1K", // resolution
"urls": [
"https://example.com/example.png" // reference image link
],
"webHook": "https://example.com/callback", // your server address
"shutProgress": false // progress is enabled by default; set to true to disable progress
}

Join the conversation! Your thoughts help the community grow.