# Router

> Run any decision model with fal, powered by OpenRouter.


## Overview

- **Endpoint**: `https://fal.run/openrouter/router/decisions`
- **Model ID**: `openrouter/router/decisions`
- **Category**: text-to-text
- **Kind**: inference
**Tags**: 



## Pricing

You will be charged based on the number of input and output tokens.

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`state`** (`string | object | list<void>`, _required_):
  Text or structured JSON content for the model to evaluate.
  - One of: string | object | list<void>
  - Examples: "My card was charged twice. Please refund the duplicate."

- **`questions`** (`Questions`, _required_):
  Questions keyed by caller-defined IDs. Each question is evaluated independently against the same state.
  - Examples: {"refund_requested":{"type":"noul","instructions":"Is the customer requesting a refund?"},"department":{"type":"choice","criteria":{"shipping":"Delivery status, delays, or lost packages","returns":"Refunds, exchanges, or damaged items","billing":"Charges, invoices, or payment problems"},"instructions":"Which team should handle this request?"}}

- **`model`** (`string`, _optional_):
  OpenRouter Decisions model to use. Default value: `"typesafe/jev-1.13"`
  - Default: `"typesafe/jev-1.13"`
  - Examples: "typesafe/jev-1.13"

- **`session_id`** (`string`, _optional_):
  Identifier for grouping related decision requests.



**Required Parameters Example**:

```json
{
  "state": "My card was charged twice. Please refund the duplicate.",
  "questions": {
    "refund_requested": {
      "type": "noul",
      "instructions": "Is the customer requesting a refund?"
    },
    "department": {
      "type": "choice",
      "criteria": {
        "shipping": "Delivery status, delays, or lost packages",
        "returns": "Refunds, exchanges, or damaged items",
        "billing": "Charges, invoices, or payment problems"
      },
      "instructions": "Which team should handle this request?"
    }
  }
}
```

**Full Example**:

```json
{
  "state": "My card was charged twice. Please refund the duplicate.",
  "questions": {
    "refund_requested": {
      "type": "noul",
      "instructions": "Is the customer requesting a refund?"
    },
    "department": {
      "type": "choice",
      "criteria": {
        "shipping": "Delivery status, delays, or lost packages",
        "returns": "Refunds, exchanges, or damaged items",
        "billing": "Charges, invoices, or payment problems"
      },
      "instructions": "Which team should handle this request?"
    }
  },
  "model": "typesafe/jev-1.13"
}
```


### Output Schema

The API returns the following output format:

- **`model`** (`string`, _required_)

- **`answers`** (`Answers`, _required_)

- **`usage`** (`DecisionsUsage`, _required_)

- **`id`** (`string`, _optional_)

- **`provider`** (`string`, _optional_)



**Example Response**:

```json
{
  "model": "",
  "usage": {}
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/openrouter/router/decisions \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "state": "My card was charged twice. Please refund the duplicate.",
     "questions": {
       "refund_requested": {
         "type": "noul",
         "instructions": "Is the customer requesting a refund?"
       },
       "department": {
         "type": "choice",
         "criteria": {
           "shipping": "Delivery status, delays, or lost packages",
           "returns": "Refunds, exchanges, or damaged items",
           "billing": "Charges, invoices, or payment problems"
         },
         "instructions": "Which team should handle this request?"
       }
     }
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "openrouter/router/decisions",
    arguments={
        "state": "My card was charged twice. Please refund the duplicate.",
        "questions": {
            "refund_requested": {
                "type": "noul",
                "instructions": "Is the customer requesting a refund?"
            },
            "department": {
                "type": "choice",
                "criteria": {
                    "shipping": "Delivery status, delays, or lost packages",
                    "returns": "Refunds, exchanges, or damaged items",
                    "billing": "Charges, invoices, or payment problems"
                },
                "instructions": "Which team should handle this request?"
            }
        }
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("openrouter/router/decisions", {
  input: {
    state: "My card was charged twice. Please refund the duplicate.",
    questions: {
      refund_requested: {
        type: "noul",
        instructions: "Is the customer requesting a refund?"
      },
      department: {
        type: "choice",
        criteria: {
          shipping: "Delivery status, delays, or lost packages",
          returns: "Refunds, exchanges, or damaged items",
          billing: "Charges, invoices, or payment problems"
        },
        instructions: "Which team should handle this request?"
      }
    }
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/openrouter/router/decisions)
- [API Documentation](https://fal.ai/models/openrouter/router/decisions/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=openrouter/router/decisions)

### fal.ai Platform

- [Platform Documentation](https://fal.ai/docs/documentation)
- [Python Client](https://fal.ai/docs/api-reference/client-libraries/python)
- [JavaScript Client](https://fal.ai/docs/api-reference/client-libraries/javascript)

### Other agent-readable surfaces

This file covers one model. To find anything else:

- [Platform overview](https://fal.ai/llms.txt): Entry points and representative endpoint IDs
- [Documentation index](https://fal.ai/docs/llms.txt): Every documentation page
- [Full documentation text](https://fal.ai/docs/llms-full.txt): The whole documentation inlined
- Any other model: `https://fal.ai/models/<endpoint-id>/llms.txt`
