Four ways to run an AI request
Every request runs one of your workflows: the model you picked, backup models if it fails, and a log of every call. What changes between the four patterns is how the result gets back to you, and whether your backend is asked for data along the way.
Pick a pattern
Start simple. The same workflow works with Sync and Async. A backend pipeline adds backend steps to it, and an agent lets the model call your endpoints as tools.
Sync
SimplestYour server sends a request and gets the full AI result back in the same call.
POST /v1/aiSee how it works →Async
Live to usersGet a channel back right away. The result streams to your users and arrives at your webhook.
POST /v1/ai/asyncSee how it works →Backend pipeline
Your data in the loopAI steps and your backend take turns. ModelRiver calls you when a step needs your data.
POST /v1/ai/async + backend stepsSee how it works →Agent
AI calls your APIThe model decides which of your tools to call. Each tool is an endpoint of yours, and ModelRiver makes the signed calls.
POST /v1/ai/async + toolsSee how it works →Side by side
| Sync | Async | Backend pipeline | Agent | |
|---|---|---|---|---|
| You call | POST /v1/ai | POST /v1/ai/async | POST /v1/ai/async on a workflow with backend steps | POST /v1/ai/async on a workflow with tools |
| The call returns | The full AI result | A channel, right away (202) | A channel, right away (202) | A channel, right away (202) |
| The result reaches | Your server, in the HTTP response | Your users over WebSocket, and your webhooks | Your users over WebSocket, after your backend steps | Your users over WebSocket, and your webhooks |
| Your backend during the run | Waits for the response | Free; gets the result by webhook | Answers signed webhooks with your data | Answers the tool calls the model makes |
| Streaming | Optional, to your server (SSE) | Token by token to the browser | Step progress and the final result | Tool progress, then the whole answer |
| Best for | Short tasks: classify, extract, moderate | Chat answers and longer jobs | AI features that need your data and rules | Assistants that look things up in your app |
Not sure? Start with Sync. Move to Async when a user waits on a page or a request takes more than a few seconds. Add backend steps when the AI needs your data or your business rules in the middle of the run. Use an agent when the model should decide what to look up.
Already on the OpenAI SDK?
You can also call any workflow through OpenAI-compatible endpoints. Point your SDK at ModelRiver and use the workflow name as the model. It works like Sync, with optional streaming, and keeps failover, structured outputs and cost tracking.
POST /v1/chat/completionsPOST /v1/completionsPOST /v1/embeddingsGET /v1/models
Works with the OpenAI SDKs for Python and Node.js, LangChain, LlamaIndex, the Vercel AI SDK and other OpenAI-compatible clients. OpenAI compatibility docs
const client = new OpenAI({
baseURL: "https://api.modelriver.com/v1",
apiKey: process.env.MODELRIVER_API_KEY,
});
await client.chat.completions.create({
model: "my_workflow", // your workflow name
messages,
});Same everywhere
Whichever pattern you use, every workflow gets the same safety net.
2 backups
Provider failover
If the primary model fails, ModelRiver tries up to two backup models before giving up.
Every call
Request logs
Each request, provider attempt, webhook and callback is logged with timing and cost.
Your keys
Bring your own keys
Requests go to providers with your API keys. You pay providers directly.
No key
Test mode
Run a workflow on sample data with no provider call, to build your integration first.