caozhiyuan/copilot-api is a local AI gateway that exposes OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages interfaces for multiple providers. It lets clients such as Claude Code, OpenCode, and Codex connect through one endpoint to GitHub Copilot, the built-in Codex provider, and other configured services.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/caozhiyuan/copilot-api/agents-mdgit clone --depth 1 https://github.com/caozhiyuan/copilot-apiWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/caozhiyuan/copilot-api/agents-md)<a href="https://agentmods.dev/instructions/caozhiyuan/copilot-api/agents-md"><img src="https://agentmods.dev/badge/instructions/caozhiyuan/copilot-api/agents-md.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00652 | $0.00652 |
| Opus 5 | $0.00326 | $0.00326 |
| Sonnet 5 | $0.00130 | $0.00130 |
| Haiku 4.5 | $0.00065 | $0.00065 |
Grade A, and why
copilot-api AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 35 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Repository Guidelines
Project Structure & Module Organization
This is a Bun/TypeScript API gateway project. Core server and route code lives in src/, with shared utilities under src/lib/, API protocol contract types (OpenAI Chat Completions, OpenAI Responses, Anthropic Messages) under src/lib/types/, provider integrations under src/services/, and HTTP routes under src/routes/. Tests are in tests/ and follow the same feature names as the source modules they cover. Static web assets are in pages/; documentation and screenshots are in docs/. The Electron desktop app is isolated under desktop/ with its own source, assets, and package files. Plugin scripts live in plugin/ and are excluded from the root ESLint config.
Build, Test, and Development Commands
bun run dev: run the API in watch mode with system CA enabled.bun run start: run the production entrypoint locally.bun run build: build the package withtsdown.bun run build:desktop: build the desktop server bundle.bun run typecheck: run TypeScript checks withnoEmit.bun run lintorbun run lint:all: run ESLint and Prettier checks.bun test: run all Bun tests.bun test tests/provider-resolver.test.ts: run one test file.
Coding Style & Naming Conventions
Use ES modules and strict TypeScript. Prefer ~/* imports for files under src/. Use camelCase for variables and functions, PascalCase for types/classes, and descriptive filenames such as responses-stream-translation.ts. Avoid any; model request, response, entity, and DTO fields from the actual source types. Formatting is enforced by ESLint plus Prettier, with semicolons disabled.
Run bun run lint --fix <files> to format changed files with the repository's ESLint/Prettier configuration. Do not run standalone prettier or bunx prettier; they may ignore the inline repository options (including semi: false) and rewrite entire files with the wrong style.
Testing Guidelines
Use Bun's built-in test runner. Add or update tests in tests/ with *.test.ts names. When code changes are made, changed code must reach at least 85% unit test coverage. Cover request translation, provider behavior, auth, config, and streaming edge cases near the modified code.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 6d ago First seen · 35 lines · 652 tokens per session scan A c61808ac2dae
copilot-api AGENTS.md is an instructions file published in the GitHub repository caozhiyuan/copilot-api (1,009 stars, last pushed yesterday), licensed MIT. It adds 652 tokens to every session, about $0.0033 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other instructions, from other repositories
ai-rules-sync AGENTS.md
Instructions for lbb00/ai-rules-sync, covering agents instructions, project overview, tech stack, key features and directory structure.
free-ai-gateway AGENTS.md
Instructions for zaber-dev/free-ai-gateway, covering 🤖 free-ai gateway - agentic development guidelines, 🏛️ monorepo architecture & package boundaries, 🛑 strict architectural rules for agents, 💻 essential developer commands and build all packages across monorepo.
loadout playwright-typescript.instructions.md
Playwright TypeScript Test Generation Instructions.
loadout typescript.instructions.md
TypeScript Engineering Instructions (CLI + API + UI, framework-agnostic).
eai-gofer typescript.instructions.md
Instructions for eai-support/eai-gofer, covering typescript development instructions, code quality standards, file structure and testing.
agent-compass typescript.instructions.md
Instructions for YoavLax/agent-compass, a project described as: Get your repo ready for AI.