> ## 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.

# Loops

> Start Sessions automatically on a schedule, from a webhook, or from GitHub and Linear events, and review every run.

Beta

> [!NOTE]
>
> **Factory** is in private preview and is enabled per workspace by the **Orq.ai** team.

## Use cases

> [accordion] Repetitive maintenance
>
> Run the same task on a schedule, such as a weekly dependency update, a changelog or a stale pull request cleanup.

> [accordion] React to GitHub
>
> Start a Session when a pull request opens, a check run fails or an issue is commented on.

> [accordion] React to Linear
>
> Start a Session when an issue is created or changes in a Linear team.

> [accordion] Connect any other system
>
> Give a monitoring or ticketing tool a webhook URL, and start a Session from its payload.

## Overview

A **Loop** is a saved instruction that starts a [Session](https://docs.orq.ai/factory/sessions.md) every time it fires. It carries its own model, instructions, repositories and [Runner](https://docs.orq.ai/factory/runners.md), so each run starts the same way without anyone opening the composer. A Loop fires from its triggers or by hand, and every firing is recorded as a run. Loops live in the **Loops** page of the Factory sidebar.

## Create a Loop

Click **Loop** on the **Loops** page. The template gallery opens.

1. Pick a template, or start from an empty Loop. A template prefills the triggers and instructions.
2. Fill in the **Studio** fields described in [Configuration](#configuration).
3. Click **Create**.

See [Loop templates](https://docs.orq.ai/factory/loop-templates.md) for what each template does.

## Configuration

The **Studio** tab of a Loop holds its settings.

| Field | Description |
| - | - |
| **Name** | Up to 100 characters. |
| **Triggers** | Up to 10. See [Triggers](#triggers). |
| **Model** | The model and effort of every run. Defaults to the Factory model. |
| **System instructions** | How the agent works in every run. |
| **Loop instructions** | The first message of every run. Type `@` to mention up to 8 [Agents](https://docs.orq.ai/factory/agents.md), or `{{` to insert a field of the trigger. |
| **Skills**, **MCP servers** | The Skills and MCP servers available to every run. |
| **Repository** | Up to 7 repositories cloned into every run. |
| **Runner** | The Runner every run starts from. Empty uses the default Runner. |
| **Metadata** | Up to 13 key-value pairs stamped on the Session of each run. Values can use trigger fields. |

## Triggers

A Loop fires when any of its triggers fires.

> [tab] Schedule
>
> Runs every hour, day, week or month.
>
> | Setting | Options |
> | - | - |
> | Frequency | Hourly, daily, weekly on chosen weekdays, or monthly on a day of the month. |
> | Time | Hour and minute. |
> | Time zone | Any IANA time zone. UTC by default. |
> | End | An end date, or **Never end**. |

> [tab] Event
>
> Runs when a connected [integration](https://docs.orq.ai/factory/integrations.md) reports an event.
>
> | Source | Events | Scope |
> | - | - | - |
> | GitHub | Issue, Issue or PR comment, Pull request, PR review, PR review comment, Check run, Push | Repository |
> | Linear | Issue, Comment, Issue SLA, Customer request, Cycle, Project, Project update | Team |
>
> Add conditions on the event fields to narrow the trigger. A trigger takes up to 20 conditions, and all of them must match.
>
> A run started by a GitHub event also clones the repository the event names.

> [tab] Webhook
>
> Runs when another system sends a `POST` request to the trigger URL.
>
> The secret is shown once when the trigger is created. Copy it then, or rotate it later. Send it in the `X-Webhook-Secret` header.
>
> Conditions on the payload are optional. A request that does not match is accepted and ignored.

> [tab] Manual
>
> Click **Run** on any enabled Loop. The **Run loop** dialog takes an optional **Input**, available in the instructions as `{{event.input}}`.

## Enable, disable and delete

The row menu on the **Loops** page has **Edit**, **Run**, **Enable** and **Delete**. A disabled Loop keeps its configuration and does not fire.

## Review runs

A Loop has two tabs for what it did.

| Tab | Shows |
| - | - |
| **Activity** | Sessions, cost, cost by model, average cost per pull request, cache rate, pull request outcomes and top Runners for a time range. |
| **Sessions** | Every run with its trigger type, status and linked Session. |

A run is **Queued**, **Running**, **Completed**, **Failed** or **Skipped**. A skipped run starts no Session and shows why.

| Skip reason | Meaning |
| - | - |
| **Loop was paused** | The Loop was disabled when it fired. |
| **Loop was archived** | The Loop was archived. |
| **Factory was archived** | The Factory was archived. |
| **Rate limit reached** | The Loop fired more often than its hourly limit. |
| **Budget limit reached** | A [budget](https://docs.orq.ai/factory/budgets.md) that covers the Factory was used up. |

## Limits

These limits are platform defaults and are not editable in the Studio.

| Limit | Default | Behavior |
| - | - | - |
| Concurrent runs | 1 | Extra runs queue and start as earlier runs finish. |
| Invocations per hour | 20 | Firings above the limit are recorded as skipped. |
| Run time | 24 hours | Lifetime of the Session of each run. |


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