Sync: send a request, get the result
Your server calls ModelRiver and waits. When the AI is done, the full result comes back in the same HTTP response. No WebSocket, no webhook, nothing else to run.
The four patterns
Sync
SimplestYour server sends a request and gets the full AI result back in the same call.
POST /v1/aiAsync
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 →How a sync request runs
One request, one response. ModelRiver handles the provider calls in between.
- Your backend
Send the request
Your backend calls
POST /v1/aiPOST /v1/aiwith the workflow name and the messages. - ModelRiver
Run the workflow
Applies the workflow's model, instructions and response format, then calls the provider with your key.
- AI provider
Generate the answer
If the primary model fails, ModelRiver tries up to two backup models before giving up.
- Your backend
Get the result
The same HTTP response carries the answer, plus which provider and model answered.
{ "status": "success", "data": {…}, "meta": {…} }
POST /v1/ai
{
"workflow": "classify_ticket",
"messages": [{ "role": "user", "content": "Charged twice" }]
}{
"status": "success",
"data": { "category": "billing", "priority": "high" },
"meta": {
"used_provider": "anthropic",
"used_model": "claude-haiku-5-5",
"duration_ms": 840
}
}When to use sync
Use it when
- The answer is ready in a few seconds
- Your server needs the result before it continues, like classify, extract or moderate
- You want the simplest setup, or you already use the OpenAI SDK (set the base URL to ModelRiver)
Pick another pattern when
- A user waits on a page for a long answer: use Async so it streams to the browser
- The AI needs your data or rules mid-run: use a backend pipeline
What ModelRiver handles
2 backups
Provider failover
Tried in order before the response returns, so a provider outage rarely reaches your user.
One call
No extra services
No queue, WebSocket or webhook to run. One HTTP request in, one response out.
SSE
Optional streaming
Turn on streaming to receive the answer on your server as it is generated.
Logged
Request logs
Each request shows the provider attempts, tokens, duration and cost in the console.