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

# Plugins

> Extend any model's capabilities with ARouter plugins. Enable web search, context compression, auto-routing, and more via the plugins array.

Plugins extend any model's capabilities without changing the underlying model. Pass a `plugins` array in your request body to activate one or more plugins.

```json theme={null}
{
  "model": "openai/gpt-5.4",
  "messages": [...],
  "plugins": [
    {"id": "web"},
    {"id": "context-compression"}
  ]
}
```

Plugins are composable — you can combine multiple plugins in a single request.

***

## Available Plugins

### `web` — Web Search

Ground responses with real-time web data. Works with any model.

```json theme={null}
{"plugins": [{"id": "web"}]}
```

Shorthand: append `:online` to any model slug.

| Option            | Type       | Description                                      |
| ----------------- | ---------- | ------------------------------------------------ |
| `max_results`     | `number`   | Number of results to retrieve (default: 5)       |
| `engine`          | `string`   | Search engine: `"native"`, `"exa"`, `"parallel"` |
| `include_domains` | `string[]` | Restrict results to these domains                |
| `exclude_domains` | `string[]` | Exclude results from these domains               |

See [Web Search](/en/guides/features/web-search) for the full reference.

***

### `context-compression` — Context Window Management

Automatically compress prompts that exceed a model's context window by removing middle messages.

```json theme={null}
{"plugins": [{"id": "context-compression"}]}
```

| Option    | Type      | Description                                                                          |
| --------- | --------- | ------------------------------------------------------------------------------------ |
| `enabled` | `boolean` | Set to `false` to disable (useful for small-context models where it's on by default) |

See [Message Transforms](/en/guides/features/message-transforms) for details.

***

### `auto-router` — Configurable Auto Routing

Customize which models the `auto` router can select from using wildcard patterns.

```json theme={null}
{
  "model": "auto",
  "plugins": [
    {
      "id": "auto-router",
      "allowed_models": ["anthropic/*", "openai/gpt-5.4"]
    }
  ]
}
```

| Option           | Type       | Description                                                  |
| ---------------- | ---------- | ------------------------------------------------------------ |
| `allowed_models` | `string[]` | Wildcard patterns restricting which models `auto` can select |

**Pattern syntax:**

| Pattern          | Matches              |
| ---------------- | -------------------- |
| `anthropic/*`    | All Anthropic models |
| `openai/gpt-5*`  | All GPT-5 variants   |
| `google/*`       | All Google models    |
| `openai/gpt-5.4` | Exact match only     |

See [Model Routing — Auto Routing](/en/model-routing#auto-routing) for full details.

***

## Using Multiple Plugins

Plugins can be combined in a single request:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      baseURL: "https://api.arouter.ai/v1",
      apiKey: "lr_live_xxxx",
    });

    // Web search + context compression
    const response = await client.chat.completions.create({
      model: "anthropic/claude-sonnet-4.6",
      messages: longConversation,
      // @ts-ignore
      plugins: [
        { id: "web", max_results: 3 },
        { id: "context-compression" },
      ],
    });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        base_url="https://api.arouter.ai/v1",
        api_key="lr_live_xxxx",
    )

    response = client.chat.completions.create(
        model="anthropic/claude-sonnet-4.6",
        messages=long_conversation,
        extra_body={
            "plugins": [
                {"id": "web", "max_results": 3},
                {"id": "context-compression"},
            ]
        },
    )
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://api.arouter.ai/v1/chat/completions \
      -H "Authorization: Bearer lr_live_xxxx" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "anthropic/claude-sonnet-4.6",
        "messages": [...],
        "plugins": [
          {"id": "web", "max_results": 3},
          {"id": "context-compression"}
        ]
      }'
    ```
  </Tab>
</Tabs>

***

## Plugin Shorthands

Some plugins have model suffix shorthands for convenience:

| Shorthand | Plugin equivalent          |
| --------- | -------------------------- |
| `:online` | `plugins: [{"id": "web"}]` |

***

## Plugin Execution Order

When multiple plugins are active, ARouter applies them in this order:

1. **context-compression** — Input is compressed if needed before being sent to the model
2. **web** — Search results are retrieved and injected into the prompt
3. **auto-router** — Model selection happens (if `model: "auto"`)
4. Request is forwarded to the selected model

***

## Pricing

Plugin pricing is in addition to normal LLM token costs:

| Plugin                  | Additional Cost               |
| ----------------------- | ----------------------------- |
| `context-compression`   | Free                          |
| `web` (Exa engine)      | \$4 / 1,000 results           |
| `web` (Parallel engine) | \$4 / 1,000 results           |
| `web` (Native engine)   | Provider passthrough (varies) |
| `auto-router`           | Free                          |
