Make async APIs a first-class API in AI SDK
In some cases, provider APIs do not respond with the result to a user's prompt, but with a task ID or a callback URL which has to be polled until the result is ready and the method like generateVideo() can be resolved with the result. As an alternative to polling, most if not all provider APIs support a webhook URL to be passed. We have to support both ways and default to the long polling behavior we currently implement across some of our provider models. Support for Webhook URLs can depend on models within the same provider. Instead of passing a webhookUrl at call time, a user should also be able to pass an async callback function which resolves with a webhook URL, letting the provider decide whether to generate it or not depending on model configuration.
Users will be interested into the long poll mechanism, like using their own fetch method, tracking the number of poll requests, configure the poll interval (e.g. make it exponential/dynamic).
Let's discuss what API we want to implement. We are open to input!
Current architecture for context
Current Architecture (for context)
User calls: generateVideo({ model, prompt })
↓
Core function: model.doGenerate(options) ← returns Promise<Result>
↓
Provider impl: postJsonToApi(...) ← submit job
while (!done) { ← internal polling loop
await delay(interval)
status = await getFromApi()
}
return result ← resolves only when complete
The provider owns the entire lifecycle. The SDK core has zero visibility or control.
Summary of current polling implementations across providers
11 files use the submit-then-poll pattern, where postJsonToApi() (or similar) does not directly return the response, but instead returns a URL or task ID that needs to be polled until the actual response is ready. They fall into three categories.
Image Generation (2)
@ai-sdk/black-forest-labs
- File:
packages/black-forest-labs/src/black-forest-labs-image-model.ts - Submit:
postJsonToApi→polling_url+id - Poll:
pollForImageUrl()—forloop with max attempts,getFromApito polling URL - Lines: 261–333
@ai-sdk/luma
- File:
packages/luma/src/luma-image-model.ts - Submit:
postJsonToApi→ generationid - Poll:
pollForImageUrl()—forloop with max attempts,getFromApito/generations/{id} - Lines: 153–198
Video Generation (5)
@ai-sdk/replicate
- File:
packages/replicate/src/replicate-video-model.ts - Submit:
postJsonToApi→ predictionid+urls.get - Poll:
whileloop indoGenerate,getFromApitourls.get - Lines: 193–254
@ai-sdk/fal (video)
- File:
packages/fal/src/fal-video-model.ts - Submit:
postJsonToApi→response_url - Poll:
while (true)indoGenerate,getFromApito response URL - Lines: 156–249
@ai-sdk/klingai
- File:
packages/klingai/src/klingai-video-model.ts - Submit:
postJsonToApi→task_id - Poll:
while (true)indoGenerate,getFromApito task status endpoint - Lines: 276–348
@ai-sdk/google (video)
- File:
packages/google/src/google-generative-ai-video-model.ts - Submit:
postJsonToApi→ operationname - Poll:
while (!done)indoGenerate,getFromApito operation URL - Lines: 185–251
@ai-sdk/google-vertex (video)
- File:
packages/google-vertex/src/google-vertex-video-model.ts - Submit:
postJsonToApi→ operationname - Poll:
while (!done)indoGenerate,postJsonToApitofetchPredictOperation - Lines: 181–251
Transcription (4)
@ai-sdk/assemblyai
- File:
packages/assemblyai/src/assemblyai-transcription-model.ts - Submit:
postJsonToApi→ transcriptid - Poll:
waitForCompletion()—while (true), directfetchto/v2/transcript/{id} - Lines: 268–329
@ai-sdk/revai
- File:
packages/revai/src/revai-transcription-model.ts - Submit:
postFormDataToApi→ jobid - Poll:
while (status !== 'transcribed')indoGenerate,getFromApito/jobs/{id} - Lines: 322–390
@ai-sdk/gladia
- File:
packages/gladia/src/gladia-transcription-model.ts - Submit:
postJsonToApi→result_url - Poll:
while (true)indoGenerate,getFromApito result URL - Lines: 525–589
@ai-sdk/fal (transcription)
- File:
packages/fal/src/fal-transcription-model.ts - Submit:
postJsonToApi→request_id - Poll:
while (true)indoGenerate,getFromApito request status URL - Lines: 136–232
Common Shape
All follow roughly the same pattern:
- Submit via
postJsonToApi(orpostFormDataToApi) → get back a task ID or polling URL - Poll in a loop (
while/for) callinggetFromApi(orfetch) with adelay()between iterations - Check status — looking for terminal states like
Ready,completed,succeed,done - Return the final result (image URL, video URL, transcript)
- Timeout protection via max attempts or elapsed time
Default Poll Intervals and Timeouts
| Package | Poll Interval | Timeout |
|---|---|---|
black-forest-labs |
500ms | 60s |
luma |
500ms | 120 attempts (~60s) |
replicate |
2000ms | 5 min |
fal (video) |
2000ms | 5 min |
klingai |
5000ms | 10 min |
google / google-vertex |
10000ms | 10 min |
assemblyai |
3000ms | none (polls indefinitely) |
revai |
1000ms | 60s |
gladia |
1000ms | 60s |
fal (transcription) |
1000ms | 60s |
Related
- https://github.com/vercel/ai/pull/11159
- https://github.com/vercel/ai/pull/10281, https://github.com/vercel/ai/pull/11913 - introduced most of the models with internal long polling
Some analysis from claude + opus that I just keep here for reference. Its assessment is missing some important aspect, e.g. it's treating approach B as backwards compliant but misses that it requires a spec change which is a breaking change for the AI SDK
API Design Analysis: First-Class Async APIs in AI SDK
Problem Statement
11 providers implement ad-hoc polling loops inside doGenerate(). Each has different intervals, timeouts, and error handling. Webhook support exists only as provider-specific options (e.g., blackForestLabs({ webhookUrl })), invisible to the SDK core. Users and frameworks like workflow.dev have no way to:
- Customize polling behavior
- Use webhooks instead of polling
- Observe progress/status changes
- Suspend execution (workflow.dev's createWebhook/createHook)
Current Architecture (for context)
Current Architecture (for context)
User calls: generateVideo({ model, prompt })
↓
Core function: model.doGenerate(options) ← returns Promise<Result>
↓
Provider impl: postJsonToApi(...) ← submit job
while (!done) { ← internal polling loop
await delay(interval)
status = await getFromApi()
}
return result ← resolves only when complete
The provider owns the entire lifecycle. The SDK core has zero visibility or control.
The provider owns the entire lifecycle. The SDK core has zero visibility or control.
Approach A: Webhook URL Option (Minimal Surface Change)
Add webhookUrl and createWebhookUrl directly to the call options. Providers pass them through to their APIs. Resolution still happens inside doGenerate().
User-Facing API
// Default: unchanged (backward compatible)
const result = await generateVideo({ model, prompt });
// Static webhook URL
const result = await generateVideo({
model,
prompt,
webhookUrl: "https://my-app.com/webhook/abc",
});
// Dynamic webhook URL (called only if provider supports it for this model)
const result = await generateVideo({
model,
prompt,
createWebhookUrl: async () => ({
url: "https://my-app.com/webhook/abc",
secret: "my-secret",
// Promise the SDK waits on instead of polling
received: webhookPromise,
}),
});
// Polling customization
const result = await generateVideo({
model,
prompt,
poll: {
intervalMs: 5000,
timeoutMs: 300_000,
onAttempt: ({ attempt, elapsedMs }) => {},
},
});
Provider Interface Change
type VideoModelV3CallOptions = {
// ... existing fields ...
webhookUrl?: string;
webhookSecret?: string;
poll?: {
intervalMs?: number;
timeoutMs?: number;
};
};
workflow.dev Integration
export async function videoWorkflow() {
"use workflow";
const webhook = createWebhook();
const result = await generateVideo({
model: google("veo-2"),
prompt: "A cat on mars",
createWebhookUrl: async () => ({
url: webhook.url,
received: webhook.then((req) => req.json()),
}),
});
// Workflow suspends at `received`, resumes when provider calls webhook
}
Tradeoffs
| Pros | Minimal API surface change. Backward compatible. Simple mental model. The createWebhookUrl callback lets the provider decide whether to use webhooks. |
| Cons | Provider still owns the full lifecycle inside doGenerate() — polling logic stays duplicated across 11 providers. The received promise is awkward: who parses the webhook payload? The provider needs to understand the raw webhook body, but it comes from user-land. No way to observe intermediate status. poll options must be threaded through to each provider manually. |
| workflow.dev fit | Decent. The received promise maps to await webhook. But the provider must parse the webhook payload, which creates a coupling issue — the provider needs to know both its API's webhook format AND how to extract it from the received promise result. |
Approach B: Two-Phase Provider Interface (Split Submit/Resolve)
Extract the submit-then-poll pattern into the provider interface itself. The provider implements doSubmit() and doGetStatus(). The SDK core orchestrates polling, webhooks, and status observation.
Provider Interface
type VideoModelV3 = {
readonly specificationVersion: "v3";
// ... existing fields ...
// Existing: for providers that respond synchronously (keep for backward compat)
doGenerate(options: VideoModelV3CallOptions): PromiseLike<VideoResult>;
// New: for async providers
doSubmit?(options: VideoModelV3CallOptions): PromiseLike<AsyncSubmission>;
doGetStatus?(
submission: AsyncSubmission,
): PromiseLike<AsyncStatus<VideoResult>>;
parseWebhookPayload?(payload: unknown): VideoResult;
};
type AsyncSubmission = {
taskId: string;
statusUrl?: string;
providerMetadata?: Record<string, unknown>;
};
type AsyncStatus<TResult> =
| { status: "pending"; progress?: number; message?: string }
| { status: "processing"; progress?: number; message?: string }
| { status: "completed"; result: TResult }
| { status: "failed"; error: string };
User-Facing API
// Default: transparent polling (backward compatible)
const result = await generateVideo({ model, prompt });
// Polling configuration
const result = await generateVideo({
model,
prompt,
poll: {
intervalMs: 5000,
timeoutMs: 300_000,
backoff: "exponential", // or (attempt) => Math.min(1000 * 2**attempt, 30000)
onAttempt: ({ attempt, elapsedMs, status }) => {},
},
});
// Webhook: provide a factory (called only if provider implements doSubmit)
const result = await generateVideo({
model,
prompt,
webhook: async () => {
const url = await createMyWebhookEndpoint();
return {
url,
secret: "my-secret",
// SDK awaits this, then passes to provider.parseWebhookPayload()
received: waitForWebhookCall(url),
};
},
});
// Submit-only (fire and forget) — for frameworks that manage their own lifecycle
const submission = await generateVideo.submit({ model, prompt });
// submission: { taskId, checkStatus(), providerMetadata }
// Later, resolve manually:
const result = await submission.resolve(); // polls until done
const result = await submission.resolve(webhookData); // resolve with webhook payload
SDK Core Implementation (sketch)
// Inside generateVideo():
async function generateVideo(options) {
const model = resolveModel(options.model);
// If provider supports two-phase, use it
if (model.doSubmit) {
const submission = await model.doSubmit(callOptions);
if (options.webhook) {
// Webhook path
const { url, received } = await options.webhook();
// Provider already sent webhookUrl during doSubmit (added to callOptions)
const payload = await received;
return model.parseWebhookPayload(payload);
} else {
// Polling path (orchestrated by SDK, not provider)
return pollUntilComplete(model, submission, options.poll);
}
} else {
// Legacy: provider handles everything in doGenerate
return model.doGenerate(callOptions);
}
}
async function pollUntilComplete(model, submission, pollConfig) {
const interval = pollConfig?.intervalMs ?? model.defaultPollInterval ?? 2000;
const timeout = pollConfig?.timeoutMs ?? model.defaultPollTimeout ?? 300_000;
const backoff = pollConfig?.backoff ?? "fixed";
const start = Date.now();
let attempt = 0;
while (true) {
const status = await model.doGetStatus(submission);
pollConfig?.onAttempt?.({
attempt: ++attempt,
elapsedMs: Date.now() - start,
status,
});
if (status.status === "completed") return status.result;
if (status.status === "failed") throw new AsyncTaskError(status.error);
if (Date.now() - start > timeout) throw new AsyncTaskTimeoutError();
await delay(getInterval(interval, backoff, attempt));
}
}
workflow.dev Integration
// Pattern 1: Webhook (zero-polling, fully durable)
export async function videoWorkflow() {
"use workflow";
const result = await generateVideo({
model: google("veo-2"),
prompt: "A cat on mars",
webhook: async () => {
const wh = createWebhook();
return { url: wh.url, received: wh.then((r) => r.json()) };
},
});
// Workflow suspends, zero compute. Resumes on webhook.
}
// Pattern 2: Submit + Hook (maximum control)
export async function videoWorkflow() {
"use workflow";
const submission = await generateVideo.submit({
model: google("veo-2"),
prompt: "A cat on mars",
});
// Use workflow hook with submission taskId as token
const hook = createHook<VideoWebhookPayload>({ token: submission.taskId });
// Send taskId to external system, or register webhook externally
await notifySystem({ taskId: submission.taskId, hookToken: hook.token });
// Workflow suspends, resumes when hook is triggered
const payload = await hook;
const result = await submission.resolve(payload);
}
// Pattern 3: DurableAgent tool with video generation
const agent = new DurableAgent({
model: "anthropic/claude-sonnet-4-5",
tools: {
generateProductVideo: {
description: "Generate a product video",
inputSchema: z.object({ description: z.string() }),
execute: async ({ description }) => {
"use step";
const result = await generateVideo({
model: google("veo-2"),
prompt: description,
webhook: async () => {
const wh = createWebhook();
return { url: wh.url, received: wh.then((r) => r.json()) };
},
});
return result.videos[0].url;
},
},
},
});
Tradeoffs
| Pros | Eliminates duplicated polling logic across 11 providers. SDK orchestrates — consistent behavior, retries, backoff, observability. Clean webhook integration. generateVideo.submit() gives frameworks full control. parseWebhookPayload() solves the "who parses" problem. Provider migration is incremental (doGenerate still works). |
| Cons | Larger interface change. Providers need to implement 2-3 new methods. webhookUrl needs to be passed during doSubmit(), but the webhook factory is called after — chicken-and-egg problem requires careful ordering (call webhook factory first, then submit with URL). More abstraction layers for provider authors to understand. |
| workflow.dev fit | Excellent. generateVideo.submit() maps directly to workflow steps. The webhook factory integrates cleanly with createWebhook(). The taskId maps to hook tokens. DurableAgent tools can use either pattern naturally. |
Approach C: Async Task Handle
generateVideo() always returns immediately with a task handle. The handle is PromiseLike (so await still works for the simple case) but also exposes status, webhook, and subscription APIs.
User-Facing API
// Simple case: still works with await (backward compatible)
const result = await generateVideo({ model, prompt });
// Get the task handle explicitly
const task = generateVideo({ model, prompt });
// Check status
const status = await task.getStatus();
// { status: 'processing', progress: 0.45, estimatedTimeRemainingMs: 12000 }
// Subscribe to status changes
task.onStatusChange((status) => {
console.log(`${status.status}: ${status.progress}%`);
});
// Wait with custom timeout
const result = await task.waitFor({ timeoutMs: 120_000 });
// Resolve via webhook (stops internal polling)
task.resolveWith(webhookPayloadPromise);
const result = await task;
// Abort
task.abort();
// Serialize for persistence (workflow.dev, database, etc.)
const serialized = task.serialize();
// Later:
const task2 = generateVideo.restore(serialized);
const result = await task2;
Provider Interface
Same as Approach B (doSubmit + doGetStatus), but the SDK wraps it in an AsyncTask class.
workflow.dev Integration
export async function videoWorkflow() {
"use workflow";
const task = generateVideo({ model: google("veo-2"), prompt: "A cat" });
// Serialize task state for durability
const state = task.serialize();
// state is saved as part of workflow step
// Create webhook and resolve with it
const webhook = createWebhook();
task.resolveWith(webhook.then((r) => r.json()));
const result = await task;
}
// Or: restore a task in a different workflow run
export async function resumeVideoWorkflow(serializedTask: string) {
"use workflow";
const task = generateVideo.restore(serializedTask);
const result = await task;
}
Tradeoffs
| Pros | Rich API surface. task.serialize() / restore() is powerful for durable execution. Status subscriptions enable real-time UI. resolveWith() is intuitive. Still backward compatible via PromiseLike. |
| Cons | generateVideo() return type changes from Promise |
| workflow.dev fit | Good, but serialize/restore conflicts with workflow.dev's own durability model. workflow.dev already handles state persistence at the workflow level — duplicating it at the task level creates confusion about who owns the state. The simpler submit() + resolve() from Approach B is cleaner for workflow.dev. |
Approach D: Completion Strategy (Composable)
Factor the "how to wait for completion" concern into a strategy object. The SDK ships built-in strategies; users and frameworks can provide custom ones.
User-Facing API
import { polling, webhook, manual } from "ai/strategies";
// Default: built-in polling
const result = await generateVideo({ model, prompt });
// Custom polling
const result = await generateVideo({
model,
prompt,
completion: polling({
interval: 5000,
timeout: 300_000,
backoff: (attempt) => Math.min(1000 * 2 ** attempt, 30_000),
onAttempt: ({ attempt, status }) => {},
}),
});
// Webhook strategy
const result = await generateVideo({
model,
prompt,
completion: webhook({
createUrl: async () => ({
url: "https://example.com/wh",
secret: "abc",
}),
received: webhookPromise,
}),
});
// Manual strategy (full control)
const { submission, resolve } = await generateVideo({
model,
prompt,
completion: manual(),
});
// submission.taskId, submission.statusUrl, etc.
// Later:
const result = await resolve(data);
// Combine: try webhook, fall back to polling
const result = await generateVideo({
model,
prompt,
completion: webhook({
createUrl: () => ({ url: "..." }),
received: webhookPromise,
fallback: polling({ timeout: 300_000 }),
}),
});
Strategy Interface
type CompletionStrategy<TResult> = {
type: "polling" | "webhook" | "manual";
execute(context: CompletionContext<TResult>): Promise<TResult>;
};
type CompletionContext<TResult> = {
submission: AsyncSubmission;
checkStatus: () => Promise<AsyncStatus<TResult>>;
parseWebhookPayload: (payload: unknown) => TResult;
abortSignal?: AbortSignal;
};
workflow.dev Integration
import { webhook } from "ai/strategies";
export async function videoWorkflow() {
"use workflow";
const wh = createWebhook();
const result = await generateVideo({
model: google("veo-2"),
prompt: "A cat on mars",
completion: webhook({
createUrl: async () => ({ url: wh.url }),
received: wh.then((r) => r.json()),
}),
});
}
// Or: build a reusable workflow strategy
function workflowWebhook() {
return {
type: "webhook" as const,
async execute(ctx) {
const wh = createWebhook({ token: ctx.submission.taskId });
const payload = await wh;
return ctx.parseWebhookPayload(await payload.json());
},
};
}
const result = await generateVideo({
model,
prompt,
completion: workflowWebhook(),
});
Tradeoffs
| Pros | Maximum composability. Strategies are testable and reusable. webhook + fallback: polling is elegant. Clean separation of concerns. workflow.dev can publish its own strategy (@workflow/ai-strategy). The CompletionContext gives strategies everything they need. |
| Cons | Higher conceptual overhead. Users must learn the strategy pattern. manual() changes the return type — TypeScript overloads get complex. Import from ai/strategies adds another entry point. Possibly over-engineered for the common case (just give me a webhook URL option). Provider authors need to understand the strategy contract. |
| workflow.dev fit | Very good. workflow.dev can publish a dedicated workflowWebhook() strategy that internally uses createWebhook(). This is the most "framework-friendly" approach. But it requires |
workflow.dev to depend on ai/strategies types.
Recommendation Matrix
| Criterion | A (Webhook URL) | B (Two-Phase) | C (AsyncTask) | D (Strategy) |
|---|---|---|---|---|
| Backward compat | Excellent | Excellent | Good* | Excellent |
| Provider migration effort | Low | Medium | Medium | Medium |
| Eliminates duplicated polling | No | Yes | Yes | Yes |
| Polling customization | Limited | Good | Good | Excellent |
| Webhook ergonomics | Good | Good | Good | Good |
| workflow.dev integration | Decent | Excellent | Good | Very Good |
| Agent/framework friendliness | Low | High (submit()) | Medium | High |
| Conceptual simplicity | Excellent | Good | Medium | Medium |
| Status observability | None | Via onAttempt | Via onStatusChange | Via strategy |
| Composability | Low | Medium | Medium | High |
- AsyncTask changes the return type shape, which could break .then() chains or TypeScript exact type checks.
My Recommendation: Approach B with elements of D
Approach B (Two-Phase Provider Interface) is the strongest foundation because it solves the root problem: extracting the submit/poll lifecycle out of providers and into the SDK core.
This eliminates 11 duplicated polling implementations and gives the SDK a single place to add webhook support, backoff strategies, observability, and framework integration.
Borrow the strategy concept from D but keep it simpler — just poll and webhook options on the call, not a full strategy object:
// The 90% case: just works
const result = await generateVideo({ model, prompt });
// Power users: customize polling
const result = await generateVideo({
model,
prompt,
poll: { intervalMs: 5000, backoff: "exponential", onAttempt: fn },
});
// Webhook users (including workflow.dev)
const result = await generateVideo({
model,
prompt,
webhook: async () => ({
url: webhookUrl,
received: webhookPromise,
}),
});
// Framework authors: fire-and-forget
const submission = await generateVideo.submit({ model, prompt });
This gives workflow.dev exactly what it needs:
- webhook callback → maps to createWebhook()
- generateVideo.submit() → maps to workflow steps with createHook() for manual resolution
- received promise → maps to await webhook (workflow suspends, zero compute)
- parseWebhookPayload on provider → solves "who parses the webhook body"
And it gives regular developers:
- Zero change for the default case
- poll options for customizing intervals/timeouts/backoff
- poll.onAttempt for observability
- webhook for production webhook infrastructure
I do like this API overall
// standard usacase, backwards compatible
const result = await generateVideo({ model, prompt });
// customize polling
const result = await generateVideo({
model,
prompt,
poll: { intervalMs: 5000, backoff: "exponential", onAttempt: fn },
});
// Use Webhooks
const result = await generateVideo({
model,
prompt,
webhook: async () => ({
url: webhookUrl,
received: webhookPromise,
}),
});
Something that is lacking is a fallback from poll to webhook, if the latter is not implemented. Approach D (Completion Strategy) has a better API for fallback but I think
- It's an edge case
- the completion strategy API is too complicated
- fallback form poll to webhook is implied, the other way around makes less sense.
But the problem is that it would need a spec change (adds doSubmit, doGetStatus, parseWebhookPayload, see below). But since we since the video model spec is experimental, we can change the spec without the need of a breaking change
// Existing: for providers that respond synchronously (keep for backward compat)
doGenerate(options: VideoModelV3CallOptions): PromiseLike
// New: for async providers
doSubmit?(options: VideoModelV3CallOptions): PromiseLike
type AsyncSubmission = { taskId: string; statusUrl?: string; providerMetadata?: Record<string, unknown>; };
type AsyncStatus
</details>
I'm not a fan of the `generateVideo.submit()` API, at call time we can't always know if the call will be async or not. Providers/models could be dynamic.
```ts
// Submit-only (fire and forget) — for frameworks that manage their own lifecycle
const submission = await generateVideo.submit({ model, prompt });
// submission: { taskId, checkStatus(), providerMetadata }
// Later, resolve manually:
const result = await submission.resolve(); // polls until done
const result = await submission.resolve(webhookData); // resolve with webhook payload
Some research on what API endpoints support async processing and which of these support webhook URLs
Chat / Language Models
None of these endpoints accept a per-request webhook_url. Async is only available via batch APIs or deferred mode.
┌─────────────┬────────────────────────────────────┬──────┬────────┬─────────┬───────────────────────┬─────────────────────────┬────────────────────────────────────────────────────────┐ │ Provider │ Endpoint │ Sync │ Stream │ Webhook │ Polling │ Batch │ Notes │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ OpenAI │ /v1/chat/completions │ Yes │ SSE │ No │ No │ Yes (JSONL, 50% off) │ Batch via /v1/batches │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Anthropic │ /v1/messages │ Yes │ SSE │ No │ No │ Yes (100K reqs, 50% │ Batch via /v1/messages/batches │ │ │ │ │ │ │ │ off) │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Google │ /models/{id}:generateContent │ Yes │ SSE │ No │ No │ Yes │ │ │ Gemini │ │ │ │ │ │ (batchGenerateContent) │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Google │ .../models/{id}:generateContent │ Yes │ SSE │ No │ Yes │ Yes │ Long-running ops pattern │ │ Vertex │ │ │ │ │ (predictLongRunning) │ (batchPredictionJobs) │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Amazon │ /model/{id}/converse │ Yes │ SSE │ No │ Yes (GetAsyncInvoke) │ Yes (StartAsyncInvoke) │ Results go to S3 │ │ Bedrock │ │ │ │ │ │ │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Azure │ /deployments/{id}/chat/completions │ Yes │ SSE │ No │ No │ Yes (JSONL, 50% off) │ Same as OpenAI batch │ │ OpenAI │ │ │ │ │ │ │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Mistral │ /v1/chat/completions │ Yes │ SSE │ No │ No │ Yes (1M reqs, │ Batch via /v1/batch/jobs │ │ │ │ │ │ │ │ file+inline) │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Cohere │ /v2/chat │ Yes │ SSE │ No │ No │ No │ Sync + stream only │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ DeepSeek │ /chat/completions │ Yes │ SSE │ No │ No │ No │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ xAI (Grok) │ /v1/chat/completions │ Yes │ SSE │ No │ Yes (deferred) │ Yes │ "deferred": true returns request_id, poll via │ │ │ │ │ │ │ │ │ /v1/chat/deferred-completion/{id} │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Groq │ /openai/v1/chat/completions │ Yes │ SSE │ No │ No │ Yes (50K reqs, 50% off) │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Perplexity │ /chat/completions │ Yes │ SSE │ No │ No │ No │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Together AI │ /v1/chat/completions │ Yes │ SSE │ No │ No │ Yes (50% off) │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Fireworks │ /inference/v1/chat/completions │ Yes │ SSE │ No │ No │ Yes (50% off) │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Cerebras │ /v1/chat/completions │ Yes │ SSE │ No │ No │ No │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ DeepInfra │ /v1/openai/chat/completions │ Yes │ SSE │ No │ No │ No │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ Baseten │ /v1/chat/completions │ Yes │ SSE │ No │ No │ No │ │ ├─────────────┼────────────────────────────────────┼──────┼────────┼─────────┼───────────────────────┼─────────────────────────┼────────────────────────────────────────────────────────┤ │ MoonshotAI │ /v1/chat/completions │ Yes │ SSE │ No │ No │ No │ │ └─────────────┴────────────────────────────────────┴──────┴────────┴─────────┴───────────────────────┴─────────────────────────┴────────────────────────────────────────────────────────┘ Responses API ┌────────────┬───────────────┬──────┬────────┬───────────────────┬───────────────────┬───────┬───────────────────────────────────────────────────────────────────────────────────────────┐ │ Provider │ Endpoint │ Sync │ Stream │ Webhook │ Polling │ Batch │ Notes │ ├────────────┼───────────────┼──────┼────────┼───────────────────┼───────────────────┼───────┼───────────────────────────────────────────────────────────────────────────────────────────┤ │ OpenAI │ /v1/responses │ Yes │ SSE │ Yes │ Yes (background: │ Yes │ Only OpenAI endpoint with native async + polling. Poll via GET /v1/responses/{id}. │ │ │ │ │ │ (project-level) │ true) │ │ Webhook events: response.completed, response.failed, etc. │ ├────────────┼───────────────┼──────┼────────┼───────────────────┼───────────────────┼───────┼───────────────────────────────────────────────────────────────────────────────────────────┤ │ xAI │ /v1/responses │ Yes │ SSE │ No │ No │ No │ │ ├────────────┼───────────────┼──────┼────────┼───────────────────┼───────────────────┼───────┼───────────────────────────────────────────────────────────────────────────────────────────┤ │ Hugging │ /v1/responses │ Yes │ SSE │ No │ No │ No │ │ │ Face │ │ │ │ │ │ │ │ └────────────┴───────────────┴──────┴────────┴───────────────────┴───────────────────┴───────┴───────────────────────────────────────────────────────────────────────────────────────────┘ Embedding Models ┌────────────────┬───────────────────────────┬──────┬────────┬─────────┬─────────┬──────────────────────────────────────────────────┬───────────────┐ │ Provider │ Endpoint │ Sync │ Stream │ Webhook │ Polling │ Batch │ Notes │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ OpenAI │ /v1/embeddings │ Yes │ No │ No │ No │ Yes │ Via batch API │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ Google Gemini │ /models/{id}:embedContent │ Yes │ No │ No │ No │ Yes (batchEmbedContents, asyncBatchEmbedContent) │ │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ Google Vertex │ .../models/{id}:predict │ Yes │ No │ No │ No │ Yes (batchPredictionJobs) │ │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ Amazon Bedrock │ /model/{id}/invoke │ Yes │ No │ No │ Yes │ Yes (StartAsyncInvoke) │ │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ Mistral │ /v1/embeddings │ Yes │ No │ No │ No │ Yes (via batch jobs) │ │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ Cohere │ /v2/embed │ Yes │ No │ No │ No │ No │ │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ Together AI │ /v1/embeddings │ Yes │ No │ No │ No │ No │ │ ├────────────────┼───────────────────────────┼──────┼────────┼─────────┼─────────┼──────────────────────────────────────────────────┼───────────────┤ │ Fireworks │ /inference/v1/embeddings │ Yes │ No │ No │ No │ No │ │ └────────────────┴───────────────────────────┴──────┴────────┴─────────┴─────────┴──────────────────────────────────────────────────┴───────────────┘ Image Generation Models ┌────────────────┬──────────────────────────────────┬────────────┬────────┬──────────────────────────────────┬───────────────┬───────┬──────────────────────────────────────────────────┐ │ Provider │ Endpoint │ Sync │ Stream │ Webhook │ Polling │ Batch │ Notes │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ OpenAI │ /v1/images/generations │ Yes │ No │ No │ No │ No │ Can use Responses API for async │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Google Gemini │ /models/{id}:predict │ Yes │ No │ No │ No │ No │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Google Vertex │ .../models/{id}:predict │ Yes │ No │ No │ No │ No │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Amazon Bedrock │ /model/{id}/invoke │ Yes │ No │ No │ Yes │ Yes │ Via StartAsyncInvoke │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ xAI │ /v1/images/generations │ Yes │ No │ No │ No │ No │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Together AI │ /v1/images/generations │ Yes │ No │ No │ No │ No │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Fireworks │ /inference/v1/images/generations │ Yes │ No │ No │ No │ No │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ DeepInfra │ /v1/inference/{modelId} │ Yes │ No │ No │ No │ No │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Black Forest │ /{modelId} │ No │ No │ Yes (underdocumented) │ Yes (primary) │ No │ Async-only. Returns polling_url │ │ Labs │ │ │ │ │ │ │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Replicate │ /models/{id}/predictions │ Yes │ SSE │ Yes (webhook + │ Yes │ No │ Most complete async: sync, poll, webhook, stream │ │ │ │ │ │ webhook_events_filter) │ │ │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Luma │ /dream-machine/v1/generations │ Yes │ No │ Yes (callback_url) │ Yes │ No │ sync param for images │ │ │ │ (images) │ │ │ │ │ │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ fal.ai │ /{modelId} │ Yes │ SSE+WS │ Yes (fal_webhook query param) │ Yes (via │ No │ 3 modes: fal.run (sync), queue.fal.run (async), │ │ │ │ │ │ │ queue) │ │ ws.fal.run (WS) │ ├────────────────┼──────────────────────────────────┼────────────┼────────┼──────────────────────────────────┼───────────────┼───────┼──────────────────────────────────────────────────┤ │ Prodia │ /v2/job │ Yes │ No │ No │ No │ No │ Sync only │ └────────────────┴──────────────────────────────────┴────────────┴────────┴──────────────────────────────────┴───────────────┴───────┴──────────────────────────────────────────────────┘ Video Generation Models ┌───────────┬───────────────────────────────┬──────┬────────┬────────────────────┬─────────┬───────┬─────────────────────┐ │ Provider │ Endpoint │ Sync │ Stream │ Webhook │ Polling │ Batch │ Notes │ ├───────────┼───────────────────────────────┼──────┼────────┼────────────────────┼─────────┼───────┼─────────────────────┤ │ Luma │ /dream-machine/v1/generations │ No │ No │ Yes (callback_url) │ Yes │ No │ Video is async-only │ ├───────────┼───────────────────────────────┼──────┼────────┼────────────────────┼─────────┼───────┼─────────────────────┤ │ Replicate │ /models/{id}/predictions │ No │ SSE │ Yes (webhook) │ Yes │ No │ │ └───────────┴───────────────────────────────┴──────┴────────┴────────────────────┴─────────┴───────┴─────────────────────┘ Speech (Text-to-Speech) Models ┌────────────┬──────────────────────────────┬──────┬───────────────────┬────────────────────────────┬─────────┬───────┬──────────────────────┐ │ Provider │ Endpoint │ Sync │ Stream │ Webhook │ Polling │ Batch │ Notes │ ├────────────┼──────────────────────────────┼──────┼───────────────────┼────────────────────────────┼─────────┼───────┼──────────────────────┤ │ OpenAI │ /v1/audio/speech │ Yes │ Chunked+SSE │ No │ No │ No │ │ ├────────────┼──────────────────────────────┼──────┼───────────────────┼────────────────────────────┼─────────┼───────┼──────────────────────┤ │ ElevenLabs │ /v1/text-to-speech/{voiceId} │ Yes │ HTTP chunked + WS │ No │ No │ No │ │ ├────────────┼──────────────────────────────┼──────┼───────────────────┼────────────────────────────┼─────────┼───────┼──────────────────────┤ │ Deepgram │ /v1/speak │ Yes │ WebSocket │ Yes (callback query param) │ No │ No │ Callback-based async │ ├────────────┼──────────────────────────────┼──────┼───────────────────┼────────────────────────────┼─────────┼───────┼──────────────────────┤ │ Hume │ /v0/tts/file │ Yes │ No │ No │ No │ No │ │ ├────────────┼──────────────────────────────┼──────┼───────────────────┼────────────────────────────┼─────────┼───────┼──────────────────────┤ │ LMNT │ /v1/ai/speech/bytes │ Yes │ WebSocket │ No │ No │ No │ │ ├────────────┼──────────────────────────────┼──────┼───────────────────┼────────────────────────────┼─────────┼───────┼──────────────────────┤ │ fal.ai │ /{modelId} │ Yes │ SSE+WS │ Yes (fal_webhook) │ Yes │ No │ │ └────────────┴──────────────────────────────┴──────┴───────────────────┴────────────────────────────┴─────────┴───────┴──────────────────────┘ Transcription (Speech-to-Text) Models ┌────────────┬─────────────────────────────────┬──────┬─────────────────────┬──────────────────────────────────────┬─────────┬─────────────────┬────────────────────────┐ │ Provider │ Endpoint │ Sync │ Stream │ Webhook │ Polling │ Batch │ Notes │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ OpenAI │ /v1/audio/transcriptions │ Yes │ SSE (not whisper-1) │ No │ No │ No │ │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ Groq │ /openai/v1/audio/transcriptions │ Yes │ No │ No │ No │ Yes (via batch) │ │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ ElevenLabs │ /v1/speech-to-text │ Yes │ No │ Yes (webhook bool + webhook_id) │ No │ No │ │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ Deepgram │ /v1/listen │ Yes │ WebSocket (live) │ Yes (callback query param) │ No │ No │ Retries 10x on failure │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ Gladia │ /v2/pre-recorded │ No │ WebSocket (live) │ Yes (callback_url / callback_config) │ Yes │ No │ Inherently async │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ Rev.ai │ /speechtotext/v1/jobs │ No │ Separate API │ Yes (notification_config.url) │ Yes │ No │ Inherently async │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ AssemblyAI │ /v2/transcript │ No │ Separate API │ Yes (webhook_url) │ Yes │ No │ Inherently async │ ├────────────┼─────────────────────────────────┼──────┼─────────────────────┼──────────────────────────────────────┼─────────┼─────────────────┼────────────────────────┤ │ fal.ai │ /{modelId} │ Yes │ SSE+WS │ Yes (fal_webhook) │ Yes │ No │ │ └────────────┴─────────────────────────────────┴──────┴─────────────────────┴──────────────────────────────────────┴─────────┴─────────────────┴────────────────────────┘
Summary: Non-Media Endpoints with Async Support
These are the notable non-media-generation endpoints that support async patterns beyond simple streaming: ┌────────────────┬────────────────────────────────────┬────────────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Provider │ Endpoint │ Type │ Async Mechanism │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ OpenAI │ /v1/responses │ Chat/Reasoning │ background: true + polling (GET /v1/responses/{id}) + project-level webhooks (response.completed etc.) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ xAI (Grok) │ /v1/chat/completions │ Chat │ "deferred": true + polling (GET /v1/chat/deferred-completion/{request_id}) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Amazon Bedrock │ /model/{id}/converse │ Chat │ StartAsyncInvoke + GetAsyncInvoke polling (results to S3) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Google Vertex │ .../models/{id}:predictLongRunning │ Chat │ Google Cloud long-running operations polling pattern │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ OpenAI │ /v1/chat/completions │ Chat │ Batch API only (JSONL, 50% off, 24h) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Anthropic │ /v1/messages │ Chat │ Batch API only (/v1/messages/batches, 50% off, 24h) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Google Gemini │ /models/{id}:generateContent │ Chat │ Batch API only (batchGenerateContent) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Mistral │ /v1/chat/completions │ Chat │ Batch API only (/v1/batch/jobs, up to 1M requests) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Azure OpenAI │ /deployments/{id}/chat/completions │ Chat │ Batch API only (JSONL, 50% off) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Groq │ /openai/v1/chat/completions │ Chat │ Batch API only (50K reqs, 50% off) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Together AI │ /v1/chat/completions │ Chat │ Batch API only (50% off) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Fireworks │ /inference/v1/chat/completions │ Chat │ Batch API only (50% off) │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ OpenAI │ /v1/embeddings │ Embedding │ Batch API only │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Mistral │ /v1/embeddings │ Embedding │ Batch API via /v1/batch/jobs │ ├────────────────┼────────────────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ Amazon Bedrock │ /model/{id}/invoke │ Embedding │ StartAsyncInvoke polling │ └────────────────┴────────────────────────────────────┴────────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────┘ Key takeaway: For chat/language models, only OpenAI Responses API (background: true), xAI (deferred: true), Amazon Bedrock (StartAsyncInvoke), and Google Vertex (predictLongRunning) offer true per-request async with polling. All other chat providers only offer async via bulk batch APIs. No chat provider supports a per-request webhook_url parameter — OpenAI's webhook support is project-level only and limited to the Responses API.
For the big ones, OpenAI, xAI, Bedrock, and Google support async processing via dedicated endpoints or arguments, but none support webhook URLs. OpenAI does support project-based webhook URLs, but that's not useful for us.
initial implementation ~~for Fal video~~: https://github.com/vercel/ai/pull/12515
turns out only Fal and Replicate support webhook callbacks URLs for videos
| Provider | Package | Webhook Support |
|---|---|---|
| FAL | @ai-sdk/fal |
Yes (?fal_webhook= query param) |
| Replicate | @ai-sdk/replicate |
Yes (webhook + webhook_events_filter body params) |
| xAI | @ai-sdk/xai |
No |
@ai-sdk/google |
No | |
| Google Vertex | @ai-sdk/google-vertex |
No |
| Alibaba | @ai-sdk/alibaba |
No |
| KlingAI | @ai-sdk/klingai |
No |
@gr2m Reviewing this, in terms of different provider implementations, I have 2 additions I don't think this was covering yet:
- Fireworks also uses async image generation with polling for some models for which it is required, see #11159.
- Replicate has an interesting pattern where they may fall back to a polling approach if the image or video generation takes too long - it doesn't always require polling. https://replicate.com/docs/reference/http#predictions.create-description
- Generating an image taking more than 60 seconds is unlikely, but technically we lack support for this at the moment. We do support it for video generation, where it's of course more likely to be relevant.
A few thoughts on the future first-class API abstraction:
- How do you think about this across different providers? Would e.g. the
polloption object only be allowed for providers that offer that (polling endpoint, request/task IDs, etc.)? Or would we always allow it and for providers that return the result immediately simply skip polling? - How do we support the Replicate behavior? E.g. if a video generation task takes only 30 seconds, I suppose we don't need to poll for that?
- It would be interesting to see if there's a way to enforce polling. As in "even if this task might take 10 seconds, we want to get a task ID back and poll right away". That might help implement our API more consistently.
- I think it's important to consider that this goes beyond video generation. While in practice it's unlikely to be needed for 90+% of image generation efforts, some providers (like Replicate) already have this in place for image generation. And if we think about e.g. a future model which allows you to generate 20 images in one job, that would likely require polling too.
- What about exposing the polling mechanism through the top-level API? Maybe there's a use-case where the caller doesn't want to wait for polling until it's done - maybe they just want to get the request/task ID and occasionally re-check. Or maybe it's a task that is expected to take 5 hours, and the caller wants to store that request/task ID and check if it's done at some future point.
- It feels a bit low-level to expose this, but I think it's worth thinking about. It would give developers more control and avoids making lots of requests if the developer is expecting for this to take a while, but doesn't want to keep
awaiting for the result. I think it becomes a more relevant concern the longer a task is expected to take. - Using a webhook would be a good alternative to this, but as far as I understand we may not be able to support that for every provider, since it depends on the provider?
- It feels a bit low-level to expose this, but I think it's worth thinking about. It would give developers more control and avoids making lots of requests if the developer is expecting for this to take a while, but doesn't want to keep
FYI I have a full request for async APIs for video (as video is still experimental) https://github.com/vercel/ai/pull/12515
Identify issue type
{
"evidence": [
"Title asks to make async APIs a first-class API in AI SDK.",
"Description proposes support for provider async task IDs/callback URLs, webhook URLs, dynamic webhook callbacks, and configurable polling behavior.",
"The issue explicitly says “Let's discuss what API we want to implement” and compares possible new APIs such as poll options, webhooks, doSubmit/doGetStatus, and completion strategies.",
"Comments discuss API design tradeoffs, provider support research, and an initial implementation PR for async APIs."
],
"rationale": "The issue requests new SDK capabilities and API design for async provider workflows, webhooks, polling customization, and provider interface changes. It is not reporting a concrete broken current behavior.",
"type": "feature",
"confidence": "high"
}
Provider async API research update (2026-07-31)
I reviewed the upstream documentation for the provider packages currently implemented in this repository. The original issue is directionally correct, but the provider inventory—and the earlier conclusion that only fal and Replicate have video webhooks—is now outdated.
Scope
I counted durable server-side jobs that can outlive the request and are completed through status retrieval/polling, an HTTP webhook, or both. I did not count SSE, WebSockets, or ordinary streamed inference responses.
Across the 43 current concrete/meta provider packages:
- 17 providers have at least one webhook-capable async surface.
- 15 additional providers offer polling-only async jobs.
- 7 providers have no documented durable inference-job API.
- 4 packages are generic adapters whose capability depends on the upstream implementation.
These are upstream platform capabilities. In several cases the corresponding async surface is not yet exposed by the current AI SDK adapter.
Providers with webhook support today
“Both” means the provider documents both later status/result retrieval and webhooks.
| Provider | Webhook-capable models or operations | Delivery | Current AI SDK exposure |
|---|---|---|---|
| Replicate | All models invoked through the Predictions API; training jobs also support webhooks | Both | Image/video adapters currently poll |
| fal | All models supporting the Queue API | Both | Video/transcription adapters currently poll |
| Fireworks | flux-kontext-pro, flux-kontext-max image generation |
Both | webhook_url and secret are already passed through |
| Black Forest Labs | Current SDK models: flux-kontext-pro, flux-kontext-max, flux-pro-1.1-ultra, flux-pro-1.1, flux-pro-1.0-fill |
Both | webhookUrl and webhookSecret are already supported |
| Luma | Photon images (photon-1, photon-flash-1) and Ray video |
Both | Current package implements Photon images and polls |
| Google Gemini API | Veo video, background Interactions, and Batch API. Current Veo IDs include Veo 2, 3, and 3.1 variants | Both | Video and Interactions implementations currently poll; webhook_config is not exposed |
| OpenAI | Background Responses and Batch API on compatible models | Both | Background task lifecycle and webhook configuration are not exposed |
| Azure OpenAI | Background Responses, Batch, fine-tuning, and Realtime incoming-call events | Both | Not exposed as a task lifecycle |
| Baseten | Any deployed model using the asynchronous prediction endpoint | Both | Current adapter exposes the synchronous/OpenAI-compatible surface |
| DeepInfra | Native API inference endpoints; not the OpenAI-compatible API | Webhook only | Native callback mode is not exposed |
| AssemblyAI | Pre-recorded STT: universal-2, universal-3-pro, universal-3-5-pro, and legacy best |
Both | Webhook URL and auth-header options are already passed through |
| RevAI | Async STT models machine, low_cost, and fusion |
Both | notification_config is already passed through |
| Gladia | Pre-recorded transcription | Both | Callback configuration is already passed through |
| Deepgram | Pre-recorded STT models and Aura TTS | Webhook-only mode | TTS callback options exist; there is no later result-retrieval endpoint |
| ElevenLabs | Scribe v2 batch STT; transcripts can also be retrieved by ID | Both | Async webhook flow is not exposed |
| Hume | Expression Measurement Batch jobs | Both | Current package only implements Hume TTS |
| MiniMax | MiniMax-Hailuo-2.3, MiniMax-Hailuo-2.3-Fast, MiniMax-Hailuo-02, S2V-01, and video-agent templates |
Both | Current package does not implement video |
Webhook configuration is not uniform:
- Replicate, fal, Luma, BFL, Fireworks, Baseten, RevAI, etc. accept a per-request callback URL.
- OpenAI, Azure OpenAI, and ElevenLabs use registered project/workspace endpoints, sometimes combined with a per-request opt-in.
- Gemini supports both static project-level and dynamic request-level configuration.
- MiniMax performs callback URL challenge verification.
- DeepInfra Native and Deepgram callback mode do not provide a normal polling fallback.
Polling-only providers
| Provider | Async operations/models |
|---|---|
| Alibaba | Wan image/video tasks and background Agent Responses |
| Amazon Bedrock | StartAsyncInvoke/GetAsyncInvoke for Nova Reel, Luma Ray 2, Nova multimodal embeddings, and TwelveLabs Marengo. Batch jobs can emit EventBridge events, but that is not a native HTTP webhook |
| Anthropic | Message Batches across supported Claude models |
| Anthropic AWS | Message Batches through Claude Platform on AWS |
| ByteDance/Volcengine | Video generation tasks and batch jobs |
| Cerebras | Batch API |
| Cohere | v2 Batch API and Embed Jobs |
| Google Vertex AI | Veo 2/3/3.1 long-running operations. The Gemini API webhook documentation does not establish a Vertex webhook contract |
| Groq | Chat and audio Batch API; no usable webhook field or registration contract appears in the API reference |
| KlingAI | Video generation tasks; the current adapter uses create/get polling and I found no verifiable public webhook contract |
| Mistral | Batch jobs for chat, embeddings, OCR, and transcription |
| Perplexity | Async Sonar, especially sonar-deep-research; webhook support remains roadmap work |
| Prodia | Beta async job API for supported generation types, including video |
| Together AI | Batch inference |
| xAI | grok-imagine-video, deferred chat completions, and Batch API |
No documented durable inference-task API
- Cartesia
- DeepSeek
- LMNT
- MoonshotAI
- QuiverAI
- Vercel/v0
- Voyage
Cartesia has webhooks for its separate telephony/call product, but those are not inference-job completion webhooks.
The following packages are indeterminate by design:
@ai-sdk/gateway: depends on the routed provider.@ai-sdk/huggingface: depends on the selected Inference Provider; Hugging Face Hub Jobs are a separate API.@ai-sdk/open-responses: depends on the server implementation.@ai-sdk/openai-compatible: depends on the upstream API.
API design implications
The provider differences suggest that the first-class abstraction should expose the durable job itself rather than only making the existing one-shot functions' polling loop configurable:
submit(options): Promise<TaskHandle>
getStatus(handle): Promise<TaskStatus>
getResult(handle): Promise<Result>
cancel?(handle): Promise<void>
The handle should retain provider-specific task IDs, raw status/progress metadata, expiry/result URLs, cancellation support, and capability metadata such as deliveryModes: ['poll', 'webhook'].
Webhook configuration needs to accommodate per-request URLs, registered workspace endpoints, signature secrets, challenge verification, and callback-only jobs. Existing generateImage, generateVideo, and transcribe behavior could remain backward-compatible wrappers that submit and poll internally, while the first-class API would let applications persist a handle, return immediately, resume after restart, or complete work from a webhook.
Use cases we should consider
- asynchronous tasks that might take days. In that case we don't want the AI SDK method call to resolve when it's all done, we want to give the user full control about polling
- The result might be a very big artifact which users might want to download in a different place then where they started the operation
On the 'tasks that might take days' point: #12515 already made the operation handle a JSONValue, which is the important part. What would make it really usable is a public way to get that handle out before polling starts (something like an onStart({ operation }) callback) and a way to hand it back later, e.g. a resume call that only checks status and never starts a new job. We ran into this building a batch video client. If the process restarts or the poll times out and the only way to recover is calling generateVideo again, you resubmit and the user pays twice for the same clip. What worked for us: persist the task ID first, poll second, and only retry a submit when the provider explicitly rejected it. A timeout or 5xx on submit just gets marked unknown and checked by ID later. That also covers the 'download somewhere else' case, since a different worker can resume from the stored handle.