AIRelays
llms.txt4 starsChanged 43 days agoMITView on GitHub
AIRelays is a local OpenAI-compatible HTTP server with provider-scoped runtimes. The default runtime uses an AIRelays-owned ChatGPT subscription login and balances requests across multiple of your own OpenAI accounts by default; it also serves image generation and edits (/v1/images/generations, /v1/images/edits, gpt-image-2) on that subscription. The Claude runtime balances your own subscriptions through AIRelays-owned local claude CLI profiles (never your personal Claude Code sign-in) for claude:* and claude-* models, with chat, completions and Responses, images, files, conversations and tool calls (see…
- Pipes a download into a shell
- Installs packages
In this repository2 other files it gives its agents.
- llms-full.txtllms.txt
- airelaysSkill
The file
We split this llms.txt into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 55
Default per-IP limits: 120 requests/minute, burst 40, 50 concurrent requests, temporary block after repeated bad tokens.
≈ “Common” is an estimate: at least 1 in 5 of the 3,913 llms.txt files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
# AIRelays
AIRelays is a local OpenAI-compatible HTTP server with provider-scoped runtimes. The default runtime uses an AIRelays-owned ChatGPT subscription login and balances requests across multiple of your own OpenAI accounts by default; it also serves image generation and edits (`/v1/images/generations`, `/v1/images/edits`, `gpt-image-2`) on that subscription. The Claude runtime balances your own subscriptions through AIRelays-owned local `claude` CLI profiles (never your personal Claude Code sign-in) for `claude:*` and `claude-*` models, with chat, completions and Responses, images, files, conversations and tool calls (see docs/capabilities.md). AIRelays protects `/v1/*` and `/no-tools/v1/*` with its own relay bearer token by default and can run all enabled providers in open local relay mode. `[security] network_scope` (`loopback`, `private` default, `any`) decides which client addresses may connect at all. A cross-platform desktop app (macOS, Windows, Linux) wraps the same relay with a system tray and dashboard.
## Key Docs
- [README.md](README.md): overview, install (CLI and desktop), quick start, compatibility layer
- [docs/getting-started.md](docs/getting-started.md): setup, custom CLI configuration, multi-account sign-in, verification
- [docs/configuration.md](docs/configuration.md): config file shape, listener and network scope, environment overrides, headless/desktop model discovery, opt-in reasoning fallback, and traffic-log retention
- [docs/security.md](docs/security.md): relay auth, who can connect (`network_scope`) and internet setup, open local relay mode, Claude guardrails, desktop update integrity
- [docs/capabilities.md](docs/capabilities.md): what works on GPT models and on Claude models, side by side
- [docs/api.md](docs/api.md): routes, compatibility adaptations, model metadata and reference pricing, errors, provider limits
- [docs/architecture.md](docs/architecture.md): components, request admission pipeline, request flow, module boundaries
- [docs/subscription-status.md](docs/subscription-status.md): usage reporting for OpenAI and Claude, desktop account details via **?**
- [docs/faq.md](docs/faq.md): common questions and limits
- [docs/troubleshooting.md](docs/troubleshooting.md): symptoms, causes, fixes
- [docs/adr/README.md](docs/adr/README.md): durable design decisions
- [desktop/README.md](desktop/README.md): Connect card with who-can-connect and **Try it** examples, Models table with prices, Traffic detail, tray menu (Copy Address), About page and in-place updates, build, supervision
- [DISCLAIMER.md](DISCLAIMER.md): independence and intended use
- [docs/README.md](docs/README.md): index of every documentation page
## Agent Skill
- [skills/airelays/SKILL.md](skills/airelays/SKILL.md): agent skill that teaches agents to install, run and call AIRelays (CLI and HTTP API), with its limits, sharp edges and error fixes
## Install
- Headless relay and CLI (macOS, Linux): `curl -fsSL https://raw.githubusercontent.com/lpalbou/AIRelays/main/scripts/install-headless.sh | bash`
- Desktop app (macOS Apple Silicon, Linux x86_64): `curl -fsSL https://raw.githubusercontent.com/lpalbou/AIRelays/main/scripts/install-desktop.sh | bash`
- Desktop app (Windows x64, PowerShell): `irm https://raw.githubusercontent.com/lpalbou/AIRelays/main/scripts/install-desktop.ps1 | iex`
- PyPI: `python -m pip install airelays`; `AIRELAYS_VERSION=X.Y.Z` pins a release for any installer
## Main Commands
- `airelays init` / `airelays init --no-auth` / `airelays init --host 0.0.0.0 --network-scope any` (writes a new config; `--force` rewrites one)
- `airelays login` (additive; repeat to enroll more accounts) / `airelays login --device` (headless)
- `airelays logout <email>` / `airelays accounts` (list, order, refresh, resets, redeem)
- `airelays serve` / `airelays serve --no-auth` / `airelays serve --host 0.0.0.0 --network-scope private|any` / `--balance <strategy>`
- `airelays balance [strategy] [--provider claude]` (switch account balancing on the running relay)
- `airelays status` / `airelays doctor` / `airelays models` / `airelays usage` / `airelays logs`
- `airelays token show` / `airelays token rotate`
- `airelays claude set-token` (optional headless setup token; account `default`, inference-only)
- `airelays claude login` (additive) / `airelays claude accounts`
- `airelays claude login --replace ACCOUNT` / `airelays claude logout ACCOUNT` (or `--all`)
- `claude setup-token` (on any machine with a browser, before `airelays claude set-token`)
## Important Notes
- Shared CLI options (`--config`, `--data-dir`, `--logs-dir`, `--auth-storage`, `--bearer-token-file`) work before or after subcommands; a later explicit value wins. `--auth-storage` is accepted for compatibility only.
- Sign-ins (OpenAI, relay token, Claude setup token) are owner-only files in the data directory on every OS; AIRelays does not use the OS keychain. OpenAI sign-ins that 0.16.0 or earlier kept in the keychain need a new sign-in (`airelays doctor` lists them under `openai_keyring_sign_ins`).
- Who can connect: `[security] network_scope` (`AIRELAYS_NETWORK_SCOPE`, `airelays serve --network-scope`, `airelays init --network-scope`) is `loopback`, `private` (default: loopback, RFC 1918, CGNAT 100.64/10, link-local, IPv6 ULA and link-local) or `any`. It is checked on every route before rate limits and auth; refused clients get 403 `client_not_on_private_network` or `client_not_on_this_machine`. A loopback listener (CLI default `127.0.0.1`) always enforces `loopback`. `any` requires `require_bearer_auth = true` (refused with `--no-auth`). With `trust_x_forwarded_for = true` the scope applies to the first `X-Forwarded-For` address. `airelays init`/`status` print it as **Who can connect**; `/v1/relay/status` reports `relay.network_scope`, `relay.effective_network_scope` and `security.network_scope`. Internet use needs router port forwarding and a TLS reverse proxy or VPN (see docs/security.md).
- Desktop: **Anyone on the internet** asks for confirmation, turns the API key on and disables **Open (no key)**; the Connect card and the tray's **Copy Address** submenu then show the public address (looked up from api.ipify.org, then checkip.amazonaws.com, only in that scope). The **Try it** panel shows curl, Python, JavaScript/TypeScript and Rust examples for the cheapest priced chat model, with the key masked on screen and included by Copy. Tray: left click opens the dashboard and right click the menu on macOS and Windows; on Linux every click opens the menu.
- `/v1/models` entries carry `airelays.pricing` (provider API list price in USD per 1M tokens: input, cached input, output, `matched_family`, `source`, `as_of`, `cost_tier`) or `null` when unpublished; `airelays models` prints it. Subscription requests are not billed per token, so it is only a relative cost indicator.
- Default per-IP limits: 120 requests/minute, burst 40, 50 concurrent requests, temporary block after repeated bad tokens. `GET /healthz` is public (scope still applies) and returns the relay version.
- Traffic logs default to 7 days, 1024 MiB total, and hourly/50 MiB rotation. `airelays logs`, GET/PUT `/v1/relay/logging`, and tray Settings inspect or change the saved policy; see `docs/configuration.md` for limits and permanent-deletion behavior.
- OpenAI runtime: first-class `responses`, `chat.completions`, and `completions`
- OpenAI runtime: `POST /v1/images/generations` and `POST /v1/images/edits` serve `gpt-image-2` (listed in `/v1/models`): `prompt`, `background`, `moderation` are checked locally and forwarded; `quality` and `size` are forwarded but the service picks its own (listed in `x-airelays-ignored-parameters` when the rendered image differs; the response reports the rendered `size` and `quality`); `n` runs one upstream call per image; `stream: true` yields `image_generation.completed` / `image_edit.completed` events; `output_format`, `output_compression`, `partial_images`, `response_format`, `style`, `user`, `safety_identifier`, `input_fidelity` are dropped and listed in `x-airelays-ignored-parameters` (the answer is always PNG `b64_json`); `mask` returns 422; Claude models return 422; image variations stay 501. Edits take multipart files or JSON data URLs and local `file_id`s
- The image-generation quota is a separate 24-hour upstream bucket, reported as `rate_limits.image_generation` in `/v1/subscription/status` (read from image responses and a free prompt-less probe, `[providers.openai] image_usage_probe`), as `image_usage` in `/v1/relay/status`, in the desktop (**Images · 24h window** bar) and by `airelays usage`; an exhausted image quota benches an account for images only
- Claude runtime: `chat.completions`, `completions` and `responses`; images, PDFs and text files as input; local files and conversations; function tool calls returned to the application (AIRelays never runs a tool; forced calls are refused; strict tools run non-strict, disclosed)
- Claude uses only AIRelays-owned accounts: browser profiles with their own `CLAUDE_CONFIG_DIR` under `~/.airelays/claude/accounts/<id>/`, plus an optional setup token (`default`, inference-only, no usage). The personal Claude Code sign-in (`~/.claude`), an inherited `CLAUDE_CONFIG_DIR`, and `CLAUDE_CODE_OAUTH_TOKEN` are ignored; with no account, `claude:*` requests return 503 `provider_auth_error`. Signing out never touches Claude Code. Selection honors fresh usage and model eligibility, with failover only before response bytes reach the client.
- Errors use OpenAI's error object (`{"error": {message, type, param, code}}` plus a `detail` copy); unknown models return 404 `model_not_found`; quota rejections carry `Retry-After`; Claude streams start only once the CLI produces output. Non-empty `stop`, `logprobs`, `top_logprobs` and `logit_bias` are rejected with 422 (neither upstream honors them); `seed` is stripped and disclosed. `finish_reason` includes `content_filter`; refusals are returned in `message.refusal`. Unrecognized chat/completions parameters are dropped and listed in `x-airelays-ignored-parameters`; every response carries `x-request-id`
- Claude failures are classified before any account is paused: request errors pause nothing, a model one account cannot serve pauses only that model there (`unavailable_models` in relay status), a rejected sign-in marks the account as needing a new sign-in; messages name each account's state and the action to take
- Chat accepts `content: null` with `tool_calls`, `file` content parts, `allowed_tools`, `verbosity`, `prompt_cache_key` and the deprecated `functions` interface; `json_schema` is rewritten to strict form only with `strict: true`; conversations keep their whole history; `GET /v1/files` paginates like OpenAI; `GET /v1/models/{model}` returns one model
- Chat and completions responses report `usage` in OpenAI's Chat Completions shape on both runtimes (`prompt_tokens` includes cached tokens; details only when reported; omitted when unknown); with `stream_options.include_usage` chunks carry `usage: null` and a final `choices: []` chunk holds the usage; `/v1/responses` keeps Responses usage
- One launcher starts every `claude` process: it finds `claude` on PATH and in the usual install locations (path used as found), or uses `[providers.claude].command` / `AIRELAYS_CLAUDE_COMMAND` (JSON array) as a full argv; Windows requires a real `claude.exe` and refuses npm `.cmd` shims; system prompts go through a private file when supported; over-long arguments return 413; `doctor`/`status` show the CLI path
- models starting with `claude:` or discovered concrete `claude-*` ids route to the Claude runtime when it is enabled
- model discovery follows the installed Codex client version and Claude CLI catalog; `GET /v1/models?refresh=true` bypasses provider caches, and Claude alias resolutions appear in `airelays.resolved_model`
- OpenAI catalogs form a union; balancing, affinity, and failover stay inside the requested model's supporting account subset; `airelays.account_availability` exposes coverage counts and `catalog_visibility` preserves upstream-hidden status
- other model ids route to the OpenAI runtime when it is enabled
- Claude runtime follows the relay's listener (local or network) and its protected or open local auth mode
- `GET /v1/relay/accounts/resets` lists OpenAI usage-limit reset credits per account and `POST /v1/relay/accounts/resets/redeem` redeems one through the relay (upstream outcome reported verbatim)
- `GET /v1/subscription/status` reports OpenAI usage by default and Claude usage with `?provider=claude`, both in one normalized shape; `?all_accounts=true` always returns the per-account list, with a per-account `error` when a probe fails
- Claude usage includes explicitly named scoped caps (including Fable), credit/spend metadata with declared currency scales, and fetch timestamps; scoped exhaustion does not imply all-model exhaustion, and quota percentages are not token counts
- Claude usage comes from each profile's Claude Code via the SDK `get_usage` control request (no inference; verified with 2.1.292+), refreshed every five minutes; the relay never reads Claude credentials. Readings without live data keep the last good values marked stale with `stale_reason` (`usage_unavailable`, `nonessential_traffic_disabled`, `cli_unsupported`, `cli_failed`) and never unblock or rank an account
- the upstream rejects `temperature`/`top_p`/penalty parameters; the relay strips them on both runtimes and discloses it via the `x-airelays-ignored-parameters` header. Output-token limits (`max_completion_tokens`, `max_tokens`, `max_output_tokens`) are honoured on both runtimes: GPT models enforce them upstream (at least 16), and a Claude run stops at the limit; a cut answer reports `finish_reason: "length"`.
- `reasoning_effort` works on both runtimes; each model's supported modes and default are published in `/v1/models` under `airelays.reasoning`, using provider catalog metadata when available
- `response_format` structured outputs work on chat completions for both runtimes (Claude: `json_schema` enforced natively by the CLI's `--json-schema`, `json_object` checked to be one JSON object; OpenAI: `json_schema` and native `json_object`); supported types per model are published under `airelays.structured_output`
- failed upstream OpenAI calls retry automatically with exponential backoff (default 3 retries, 5s/20s/60s; configurable, `0` disables) before returning an OpenAI-shaped error with the real HTTP status
- `airelays doctor` runs local setup checks plus live OpenAI `/models` and optional `/responses` probes
- Headless and desktop servers share OpenAI model discovery, including common Codex installations outside PATH. Codex is optional; the bundled catalog-version floor is `0.167.2`. Each account is queried separately; `/v1/models` combines their catalogs and routing respects per-model account coverage.
- OpenAI reasoning fallback is opt-in (`[providers.openai] reasoning_fallback = true`): only an explicit `reasoning_effort_not_allowed` rejection of `none` permits one same-account retry at its lowest advertised effort, before output. It may use more reasoning tokens; response metadata `airelays.reasoning_fallback` reports requested/effective effort. Strict behavior is the default. See docs/configuration.md.
## Optional
- [CHANGELOG.md](CHANGELOG.md): release history
- [ACKNOWLEDGEMENTS.md](ACKNOWLEDGEMENTS.md): credits
- [CONTRIBUTING.md](CONTRIBUTING.md): contributor workflow
- [SECURITY.md](SECURITY.md): vulnerability reporting
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

