copilot-api AGENTS.md

copilot-api AGENTS.md is an instructions file for Codex, OpenCode from caozhiyuan/copilot-api. It costs 652 tokens per session, scanned A, original, MIT.

A set of repository instructions for Copilot API, a Bun and TypeScript gateway that connects clients to different AI providers. It describes the source folders, protocol types, provider services, routes, tests, desktop app, and plugin scripts.

In plain words
What is it for?
Use it to locate API routes and provider integrations, work with OpenAI and Anthropic message formats, run the development server, build the package or desktop app, and run checks and tests.
Why use it?
It gives agents the project structure and exact commands for development, building, type checking, linting, and tests. This reduces mistakes caused by putting code in the wrong area or skipping required checks.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md.

About the project

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.

caozhiyuan/copilot-api · 1,009 stars · on GitHub · caozhiyuan.github.io

Install

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.

agentmods
npx agentmods add instructions/caozhiyuan/copilot-api/agents-md
Clone the repo
git clone --depth 1 https://github.com/caozhiyuan/copilot-api

Made for: Codex, OpenCode.

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

agentmods badge for copilot-api AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/caozhiyuan/copilot-api/agents-md.svg)](https://agentmods.dev/instructions/caozhiyuan/copilot-api/agents-md)
Your own site
<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>
Per session 652 This file is loaded in full into every session.
When invoked 652 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 6d ago against content hash c61808ac2dae, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

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.

AGENTS.md · 35 lines

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 with tsdown.
  • bun run build:desktop: build the desktop server bundle.
  • bun run typecheck: run TypeScript checks with noEmit.
  • bun run lint or bun 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.

Read the full file on GitHub · 35 lines

Changes

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.

  1. 6d ago First seen · 35 lines · 652 tokens per session scan A c61808ac2dae

Subscribe to this mod's changes

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.