> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nimbleway.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WebRouter Route

> Send a query in plain words, and WebRouter picks the tool and provider and runs it in one call

> [!NOTE]
>
> **WebRouter is in closed beta.** It's available to selected accounts, and the API may still change. To get access, [talk to the Nimble team](https://nimbleway.com/contact-general/).

WebRouter **Route** takes a query in plain words, plans it as a single step, and runs it. The planner picks the tool (search, extract, research, or browse) and the provider, so one call returns the answer.

Use Route when you are not sure which tool fits. When you know, call the tool directly: [Search](https://docs.nimbleway.com/nimble-sdk/web-router/search.md), [Extract](https://docs.nimbleway.com/nimble-sdk/web-router/extract.md), [Research](https://docs.nimbleway.com/nimble-sdk/web-router/research.md), or [Browse](https://docs.nimbleway.com/nimble-sdk/web-router/browse.md).

## Quick Start

### Example Request

```python Python theme={"system"}
import requests

response = requests.post(
    "https://sdk.nimbleway.com/v2/web-router/route",
    headers={"Authorization": "Bearer YOUR-API-KEY"},
    json={"query": "latest Python release", "optimized_for": "speed"},
)

data = response.json()
print(data["plan"]["steps"][0]["tool"])
print(data["result"] or data["job"])
```

```typescript TypeScript theme={"system"}
const response = await fetch("https://sdk.nimbleway.com/v2/web-router/route", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR-API-KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ query: "latest Python release", optimized_for: "speed" }),
});

const data = await response.json();
console.log(data.plan.steps[0].tool);
console.log(data.result ?? data.job);
```

```bash cURL theme={"system"}
curl -X POST 'https://sdk.nimbleway.com/v2/web-router/route' \
--header 'Authorization: Bearer <YOUR-API-KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "latest Python release",
    "optimized_for": "speed"
}'
```

### Example Response

```json theme={"system"}
{
  "plan": {
    "format_version": "1",
    "goal": "latest Python release",
    "steps": [
      {
        "id": "s1",
        "tool": "search",
        "why": "",
        "body": { "optimized_for": "speed", "query": "latest Python release" },
        "mcp_tool": "web_gateway_search"
      }
    ],
    "output": "s1"
  },
  "result": {
    "provider": "nimble_selection",
    "byok": false,
    "query": "latest Python release",
    "results": [
      {
        "url": "https://www.python.org/downloads/",
        "title": "Download Python | Python.org",
        "description": "Download the latest version of Python...",
        "content": "Download the latest version of Python...",
        "score": null,
        "published_date": null,
        "extra": {}
      }
    ],
    "answer": null
  },
  "job": null
}
```

## How it works

**1. You send a query**

The query is the tool's input: a search's query, a browse's task, or the
URLs to extract.

**2. WebRouter plans one step**

The planner picks the tool and its body, weighing `optimized_for` and `budgets`.

**3. WebRouter runs it**

A search or extract answers in `result`, with status `200`. A research or
browse starts a job, returned in `job` with status `202`.

Exactly one of `result` and `job` is set. `plan` always shows the step that ran.

## When the route starts a job

A research or browse is billed as a start. The response holds the job instead of an answer:

```json theme={"system"}
{
  "plan": {
    "format_version": "1",
    "goal": "Compare the pricing pages of the top three web scraping APIs",
    "steps": [
      {
        "id": "s1",
        "tool": "research",
        "why": "",
        "body": { "query": "Compare the pricing pages of the top three web scraping APIs" },
        "mcp_tool": "web_gateway_research"
      }
    ],
    "output": "s1"
  },
  "result": null,
  "job": {
    "job_id": "wgrj_3f1c2a9e7b4d4e0a9c1f2d8e5b6a7c90",
    "provider": "nimble_selection",
    "byok": false,
    "state": "queued"
  }
}
```

Poll it by `job.job_id`, at `GET /v2/web-router/research/{job_id}` or `GET /v2/web-router/browse/{job_id}`, matching the step's `tool`. See [Research](https://docs.nimbleway.com/nimble-sdk/web-router/research.md) and [Browse](https://docs.nimbleway.com/nimble-sdk/web-router/browse.md).

## Parameters

> [accordion] query - Required
>
> **query** `string` *required*
>
> The request, in plain words. Up to 10,000 characters.
>
> **Example:** `latest Python release`

> [accordion] optimized\_for
>
> **optimized\_for** `string` (default: balanced)
>
> What the planner favors when it picks the tool and provider.
>
> **Options:** `speed`, `cost`, `coverage`, `balanced`

> [accordion] budgets
>
> **budgets** `object`
>
> What answering may spend. Unset sets no limit. The planner only picks providers whose estimate fits.
>
> * `time_seconds`: wall-clock time, in seconds
> * `cost_usd`: spend, in US dollars

## Errors

| Status | Meaning |
| - | - |
| `422` | The query or a budget is invalid, or no provider fits the budget |
| `501` | The planned tool cannot run through Route yet (`not_implemented`) |
| `502` | The provider failed to serve the request |
| `504` | No provider answered in time |

## Next Steps

> [card] [WebRouter overview](https://docs.nimbleway.com/nimble-sdk/web-router/overview.md)
>
> Which call to use, authentication, and jobs

> [card] [API Reference](https://docs.nimbleway.com/api-reference/webrouter/route.md)
>
> Every field of the request and response


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.