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

> ## Agent Instructions
> Orq.ai is the control plane for model and MCP traffic: one key reaches the workspace's enabled models, MCP servers, and resources. The setup depends on where the agent runs.
> Hosted assistant (ChatGPT, claude.ai, a hosted sandbox): install nothing. Tell the human to add https://my.orq.ai/v2/mcp as a remote MCP connector and finish the Orq.ai sign-in. With OAuth, send no Authorization header; otherwise send an API key as a bearer token.
> Local coding agent (Claude Code, Codex, Cursor, OpenCode): run `curl -fsSL https://cli.orq.ai/install.sh | sh`. It installs the CLI and runs `orq setup`, which signs in, writes a project-scoped key to `~/.orq/env`, and wires the detected agents through the AI Gateway. It can also add the Orq MCP server and Orq Skills, the workflows for agents, evaluations, and traces: https://docs.orq.ai/ai-studio/integrations/code-assistants/orq-skills.md. Cursor receives the Orq MCP server and Orq Skills only; its model calls are not routed through the AI Gateway. Verify with `orq status`.
> Headless or CI: read `ORQ_API_KEY` from the environment; a human creates the key at https://docs.orq.ai/ai-studio/organization/api-keys.md.
> Send model traffic to https://my.orq.ai/v3/router with `Authorization: Bearer $ORQ_API_KEY`; the Anthropic SDK uses https://my.orq.ai/v3/anthropic. New integrations go on `/v3/router`: `/v2/router` stays published for backward compatibility, and `orq.prompt` works only on `/v2/router/chat/completions`.
> To enable a model for the workspace, ask a human to enable it in the Model Garden, or call `POST /v2/workspace-models` with a Management Key that has `workspace-model` write; API keys are rejected with `403`. Use the model's exact `provider/model` id. A call fails while the workspace has neither credits nor a provider key.
> On `/chat/completions`, a reasoning model rejects `tools` with a `reasoning_effort` other than `none`; `/responses` keeps reasoning.
> On a failure, branch on `error.code` and follow `error.doc_url`; a budget rejection answers 429.

# Security

> Attach plugins and guardrails, set runtime limits, and monitor gateway traffic and changes.

The **Settings** tab holds the plugins, **Guardrails**, and runtime limits that govern what the MCP Gateway forwards and how much it forwards. The same guardrails and runtime limits fields appear on the **Create MCP Gateway** form.

## Plugins

[Plugins](https://docs.orq.ai/ai-gateway/features/plugins/overview.md) attached to an MCP Gateway run on every tool call it serves. [Guardrail Rules](https://docs.orq.ai/ai-gateway/configuration/guardrail-rules.md) do not run on tool calls. To check tool traffic, use plugins and the gateway's own [Guardrails](#guardrails).

Click <kbd>+ Plugin</kbd> to attach one. Each listed plugin has a  icon to configure it and an overflow menu to remove it.

| Plugin | Behavior on the MCP Gateway |
| - | - |
| **PII Redaction** | Replaces personally identifiable information in free-text tool arguments with placeholders before the call reaches the upstream **MCP Server**, and redacts the tool result before it returns to the client. JSON tool results keep their structure, with only string values masked. Arguments whose schema pins the value (`enum`, `const`, `pattern`, `format`) are forwarded unchanged. Configure the entities to mask, the detection threshold, and the failure behavior. See [PII Redaction](https://docs.orq.ai/ai-gateway/features/plugins/pii-redaction.md). |
| **Trace Scrubbing** | Masks the selected fields (`system`, `input`, `output`, `metadata`, `variables`, or `all`) in the traces the MCP Gateway stores for each tool call. See [Trace Scrubbing](https://docs.orq.ai/ai-gateway/features/plugins/trace-scrubbing.md). |

The create and update requests take a `plugins[]` array where each entry carries the plugin `id` and that plugin's settings: **PII Redaction** takes `entities`, `regions`, `entity_thresholds`, `threshold`, `language` and `on_failure`; **Trace Scrubbing** takes `mask`.

> [!NOTE]
>
> Plugins enforced at workspace level apply as a floor: an MCP Gateway can add plugins or tighten their settings, but cannot remove or weaken an enforced one.

## Guardrails

**Guardrails** attached to an MCP Gateway check the tool calls it serves. Click <kbd>+ Guardrail</kbd> to pick a system **Guardrail** or a guardrail-capable [**Evaluator**](https://docs.orq.ai/ai-studio/optimize/evaluators.md), then set where it runs:

* **Input**: checks the tool name and arguments before the call reaches the upstream **MCP Server**. Resource reads are checked at this stage too.
* **Output**: checks the tool result before it returns to the client.
* **Both**: runs at both stages.

Cycle the stage with the row's icon:  **Input**,  **Output**,  **Both**.

A row showing the  icon **blocks requests that fail this check**: the call stops, and the client receives the guardrail's name without its reason. A blocking input check runs on every call; an output-stage check runs only when the tool result carries text or structured content. A check that errors blocks the call with a generic failure, and a check that times out blocks it and names the guardrail. A row showing the  icon **scores requests without blocking them**, publishes the score on the call's trace, and samples at the rate set on the row.

These [system guardrails](https://docs.orq.ai/ai-gateway/configuration/guardrail-rules.md#system-guardrails) are available on an MCP Gateway:

| Guardrail | What it checks | Stage | Configuration |
| - | - | - | - |
| [**PII Detection**](https://docs.orq.ai/ai-gateway/configuration/guardrail-rules.md#system-guardrails) | Personal information such as emails, phone numbers, and names. | Both | Set `language`, `regions`, `entities`, and `threshold`. |
| [**Secret Detection**](https://docs.orq.ai/ai-gateway/configuration/guardrail-rules.md#system-guardrails) | API keys, tokens, credentials, and other secrets. | Both | No options. |

**PII Redaction** is a plugin that masks values in arguments and results. [**PII Detection**](https://docs.orq.ai/ai-gateway/configuration/guardrail-rules.md#system-guardrails) is a guardrail that blocks or scores a call when it finds personal data. Use redaction when the upstream call should still run with masked values; use detection when a match should stop the call or record a score.

Guardrails run after [PII Redaction](https://docs.orq.ai/ai-gateway/features/plugins/pii-redaction.md), so a judge never sees the unmasked values.

![Plugins section with a + Plugin button and a Trace Scrubbing plugin row, above a Guardrails section with a + Guardrail button and a Secret Detection row showing the stage, blocking and 100 percent sample controls](https://mintcdn.com/orqai/4rHc7pk98wwKW0RE/images/mcp-gateway-security-settings.png?fit=max\&auto=format\&n=4rHc7pk98wwKW0RE\&q=85\&s=1edfa18425bcb00533f600544b6ee51c)

Plugins and Guardrails sections on the MCP Gateway Settings tab

When a blocking **Guardrail** fails, the client receives a tool error that names the guardrail without its reason: `Tool call blocked by input guardrail "<name>"; the tool was not run.` for input, or `Tool result blocked by output guardrail "<name>"; the result was withheld.` for output. If the check cannot be evaluated, the call fails closed with the JSON-RPC error `guardrail evaluation failed`.

Through the API, set `guardrails` on create or update. Each entry takes `id`, `execute_on` (`input`, `output`, or `both`), and optional `sample_rate`, `is_guardrail`, and `options`. On update, an omitted `guardrails` field leaves the list unchanged, and a non-empty list replaces it.

## Runtime Limits

Caps applied to traffic through the MCP Gateway. Set them on the **Create MCP Gateway** form or on the **Settings** tab of an existing gateway: every limit is console-only, and no API field or SDK method sets them. Each field takes a whole number starting at `0`.

A gateway created through the API starts from the defaults in the table below, not from a blank record, with **Max tools / gateway** stored as `0`. The request and response caps and the two request rates therefore apply immediately; only the tool cap waits to be set.

Exceeding either request rate returns `429` with a JSON-RPC error `-32001` and the message `rate limit exceeded`. The window is rolling: each request counts against the limit for the next 60 seconds, with no reset on a minute boundary. The response carries no `Retry-After` header, so back off until earlier requests age out of the window.

| Limit | Default | What it caps |
| - | - | - |
| **Request timeout (ms)** | `30000` | One request from the gateway to an upstream **MCP Server**. `0` falls back to a built-in 10-minute timeout. |
| **Tool timeout (ms)** | `30000` | One `tools/call`, including the connection to the upstream server. `0` removes the per-call deadline. |
| **Max request bytes** | `1048576` | The JSON-RPC request body the gateway accepts. `0` removes the cap. |
| **Max response bytes** | `1048576` | A response from an upstream server, and each `tools/list` result. `0` removes the cap. |
| **Max tools / gateway** | `100` | Tools exposed across all linked servers. Extra tools are dropped from the catalog without an error, and `0` leaves it uncapped. A gateway created through the API stores `0`, so it has no tool cap until one is set in the console. |
| **Per-token req/min** | `60` | Requests per minute for one access token. `0` disables the check. |
| **Per-gateway req/min** | `1000` | Requests per minute for the gateway as a whole. `0` disables the check. |

Hitting a request, response, timeout, or rate limit, or losing the upstream server, answers the call with an error the MCP client displays. Three of them also change the HTTP status; the rest arrive as a `200` response carrying the error.

| Situation | HTTP status | What the client shows |
| - | - | - |
| Request body over **Max request bytes** | `413` | `request body exceeds maximum allowed size` |
| Per-token or per-gateway rate exceeded | `429` | `rate limit exceeded` |
| Rate-limit store unreachable | `503` | `rate limit check unavailable` |
| `tools/list` result over **Max response bytes** | `200` | `response exceeds maximum allowed size` |
| Upstream response over **Max response bytes** | `200` | `upstream response exceeds maximum allowed size` |
| Timeout during `tools/call` | `200` | `upstream tool call timed out` |
| Timeout on another upstream request | `200` | `upstream request timed out` |
| Upstream host unreachable | `200` | `upstream connection refused` or `upstream host not found` |
| Upstream rejects the credentials | `200` | `upstream authentication failed`, `upstream access denied`, or `upstream resource not found` |
| Upstream fails in any other way | `200` | `upstream request failed` |

A tool that runs and reports its own failure is not an error: the gateway returns a normal `tools/call` result with `isError: true` and the upstream content.

A `tools/call` timeout means the gateway stopped waiting for the upstream response; the tool may already have completed. The gateway does not retry upstream tool calls, so retry a non-idempotent tool only when the tool itself is safe to repeat.

The [MCP Gateway errors](https://docs.orq.ai/reference/errors.md#mcp-gateway-errors) reference covers the gateway, upstream, guardrail, and management strings, with their causes and fixes.

## Network rules

MCP Server URLs and their token endpoints must be reachable over public HTTPS. Orq.ai refuses private, loopback, and link-local ranges, and does not follow redirects from a token endpoint.

The workspace [IP allowlist](https://docs.orq.ai/ai-studio/organization/workspace-security.md#ip-allowlist) restricts requests to **Orq.ai** backend APIs. It does not restrict the AI Studio frontend.


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