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.

How a sync request runs

One request, one response. ModelRiver handles the provider calls in between.

  1. Your backend

    Send the request

    Your backend calls POST /v1/ai with the workflow name and the messages.

    POST /v1/ai
  2. ModelRiver

    Run the workflow

    Applies the workflow's model, instructions and response format, then calls the provider with your key.

  3. AI provider

    Generate the answer

    If the primary model fails, ModelRiver tries up to two backup models before giving up.

  4. Your backend

    Get the result

    The same HTTP response carries the answer, plus which provider and model answered.

    { "status": "success", "data": {…}, "meta": {…} }
Request
POST /v1/ai
{
  "workflow": "classify_ticket",
  "messages": [{ "role": "user", "content": "Charged twice" }]
}
Response
{
  "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.

Next: results that reach your users live