{"id":27607626,"url":"https://github.com/coder/agentapi","last_synced_at":"2026-04-02T20:21:58.905Z","repository":{"id":288457392,"uuid":"961832048","full_name":"coder/agentapi","owner":"coder","description":"HTTP API for Claude Code, Goose, Aider, Gemini, Amp, and Codex","archived":false,"fork":false,"pushed_at":"2026-01-13T16:08:59.000Z","size":860,"stargazers_count":1123,"open_issues_count":23,"forks_count":102,"subscribers_count":9,"default_branch":"main","last_synced_at":"2026-01-13T18:34:38.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":"MAINTAINERS.md","copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-04-07T08:31:21.000Z","updated_at":"2026-01-13T16:09:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"cfe451f9-24e2-4842-a75b-c14d23f20b6a","html_url":"https://github.com/coder/agentapi","commit_stats":null,"previous_names":["coder/agentapi"],"tags_count":65,"template":false,"template_full_name":null,"purl":"pkg:github/coder/agentapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fagentapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fagentapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fagentapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fagentapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder","download_url":"https://codeload.github.com/coder/agentapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fagentapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-22T22:01:29.504Z","updated_at":"2026-01-16T11:18:16.662Z","avatar_url":"https://github.com/coder.png","language":"Go","readme":"# AgentAPI\n\nControl [Claude Code](https://github.com/anthropics/claude-code), [AmazonQ](https://aws.amazon.com/developer/learning/q-developer-cli/), [Opencode](https://opencode.ai/), [Goose](https://github.com/block/goose), [Aider](https://github.com/Aider-AI/aider), [Gemini](https://github.com/google-gemini/gemini-cli), [GitHub Copilot](https://github.com/github/copilot-cli), [Sourcegraph Amp](https://ampcode.com/), [Codex](https://github.com/openai/codex), [Auggie](https://docs.augmentcode.com/cli/overview), and [Cursor CLI](https://cursor.com/en/cli) with an HTTP API.\n\n![agentapi-chat](https://github.com/user-attachments/assets/57032c9f-4146-4b66-b219-09e38ab7690d)\n\nYou can use AgentAPI:\n\n- to build a unified chat interface for coding agents\n- as a backend in an MCP server that lets one agent control another coding agent\n- to create a tool that submits pull request reviews to an agent\n- and much more!\n\n## Quickstart\n\n1. Install `agentapi`:\n\n   ```bash\n   OS=$(uname -s | tr \"[:upper:]\" \"[:lower:]\");\n   ARCH=$(uname -m | sed \"s/x86_64/amd64/;s/aarch64/arm64/\");\n   curl -fsSL \"https://github.com/coder/agentapi/releases/latest/download/agentapi-${OS}-${ARCH}\" -o agentapi \u0026\u0026 chmod +x agentapi\n   ```\n\n   Alternatively, you can download the latest release binary from the [releases page](https://github.com/coder/agentapi/releases).\n\n1. Verify the installation:\n\n   ```bash\n   agentapi --help\n   ```\n\n   \u003e On macOS, if you're prompted that the system was unable to verify the binary, go to `System Settings -\u003e Privacy \u0026 Security`, click \"Open Anyway\", and run the command again.\n\n1. Run a Claude Code server (assumes `claude` is installed on your system and in the `PATH`):\n\n   ```bash\n   agentapi server -- claude\n   ```\n\n   \u003e If you're getting an error that `claude` is not in the `PATH` but you can run it from your shell, try `which claude` to get the full path and use that instead.\n\n1. Send a message to the agent:\n\n   ```bash\n   curl -X POST localhost:3284/message \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\"content\": \"Hello, agent!\", \"type\": \"user\"}'\n   ```\n\n1. Get the conversation history:\n\n   ```bash\n   curl localhost:3284/messages\n   ```\n\n1. Try the chat web interface at http://localhost:3284/chat.\n\n## CLI Commands\n\n### `agentapi server`\n\nRun an HTTP server that lets you control an agent. If you'd like to start an agent with additional arguments, pass the full agent command after the `--` flag.\n\n```bash\nagentapi server -- claude --allowedTools \"Bash(git*) Edit Replace\"\n```\n\nYou may also use `agentapi` to run the Aider and Goose agents:\n\n```bash\nagentapi server -- aider --model sonnet --api-key anthropic=sk-ant-apio3-XXX\nagentapi server -- goose\n```\n\n\u003e [!NOTE]\n\u003e When using Claude, Codex, Opencode, Copilot, Gemini, Amp or CursorCLI, always specify the agent type explicitly (eg: `agentapi server --type=codex -- codex`), or message formatting may break.\n\nAn OpenAPI schema is available in [openapi.json](openapi.json).\n\nBy default, the server runs on port 3284. Additionally, the server exposes the same OpenAPI schema at http://localhost:3284/openapi.json and the available endpoints in a documentation UI at http://localhost:3284/docs.\n\nThere are 4 endpoints:\n\n- GET `/messages` - returns a list of all messages in the conversation with the agent\n- POST `/message` - sends a message to the agent. When a 200 response is returned, AgentAPI has detected that the agent started processing the message\n- GET `/status` - returns the current status of the agent, either \"stable\" or \"running\"\n- GET `/events` - an SSE stream of events from the agent: message and status updates\n\n#### Allowed hosts\n\nBy default, the server only allows requests with the host header set to `localhost`. If you'd like to host AgentAPI elsewhere, you can change this by using the `AGENTAPI_ALLOWED_HOSTS` environment variable or the `--allowed-hosts` flag. Hosts must be hostnames only (no ports); the server ignores the port portion of incoming requests when authorizing.\n\nTo allow requests from any host, use `*` as the allowed host.\n\n```bash\nagentapi server --allowed-hosts '*' -- claude\n```\n\nTo allow a specific host, use:\n\n```bash\nagentapi server --allowed-hosts 'example.com' -- claude\n```\n\nTo specify multiple hosts, use a comma-separated list when using the `--allowed-hosts` flag, or a space-separated list when using the `AGENTAPI_ALLOWED_HOSTS` environment variable.\n\n```bash\nagentapi server --allowed-hosts 'example.com,example.org' -- claude\n# or\nAGENTAPI_ALLOWED_HOSTS='example.com example.org' agentapi server -- claude\n```\n\n#### Allowed origins\n\nBy default, the server allows CORS requests from `http://localhost:3284`, `http://localhost:3000`, and `http://localhost:3001`. If you'd like to change which origins can make cross-origin requests to AgentAPI, you can change this by using the `AGENTAPI_ALLOWED_ORIGINS` environment variable or the `--allowed-origins` flag.\n\nTo allow requests from any origin, use `*` as the allowed origin:\n\n```bash\nagentapi server --allowed-origins '*' -- claude\n```\n\nTo allow a specific origin, use:\n\n```bash\nagentapi server --allowed-origins 'https://example.com' -- claude\n```\n\nTo specify multiple origins, use a comma-separated list when using the `--allowed-origins` flag, or a space-separated list when using the `AGENTAPI_ALLOWED_ORIGINS` environment variable. Origins must include the protocol (`http://` or `https://`) and support wildcards (e.g., `https://*.example.com`):\n\n```bash\nagentapi server --allowed-origins 'https://example.com,http://localhost:3000' -- claude\n# or\nAGENTAPI_ALLOWED_ORIGINS='https://example.com http://localhost:3000' agentapi server -- claude\n```\n\n### `agentapi attach`\n\nAttach to a running agent's terminal session.\n\n```bash\nagentapi attach --url localhost:3284\n```\n\nPress `ctrl+c` to detach from the session.\n\n## How it works\n\nAgentAPI runs an in-memory terminal emulator. It translates API calls into appropriate terminal keystrokes and parses the agent's outputs into individual messages.\n\n### Splitting terminal output into messages\n\nThere are 2 types of messages:\n\n- User messages: sent by the user to the agent\n- Agent messages: sent by the agent to the user\n\nTo parse individual messages from the terminal output, we take the following steps:\n\n1. The initial terminal output, before any user messages are sent, is treated as the agent's first message.\n2. When the user sends a message through the API, a snapshot of the terminal is taken before any keystrokes are sent.\n3. The user message is then submitted to the agent. From this point on, any time the terminal output changes, a new snapshot is taken. It's diffed against the initial snapshot, and any new text that appears below the initial content is treated as the agent's next message.\n4. If the terminal output changes again before a new user message is sent, the agent message is updated.\n\nThis lets us split the terminal output into a sequence of messages.\n\n### Removing TUI elements from agent messages\n\nEach agent message contains some extra bits that aren't useful to the end user:\n\n- The user's input at the beginning of the message. Coding agents often echo the input back to the user to make it visible in the terminal.\n- An input box at the end of the message. This is where the user usually types their input.\n\nAgentAPI automatically removes these.\n\n- For user input, we strip the lines that contain the text from the user's last message.\n- For the input box, we look for lines at the end of the message that contain common TUI elements, like `\u003e` or `------`.\n\n### What will happen when Claude Code, Goose, Aider, or Codex update their TUI?\n\nSplitting the terminal output into a sequence of messages should still work, since it doesn't depend on the TUI structure. The logic for removing extra bits may need to be updated to account for new elements. AgentAPI will still be usable, but some extra TUI elements may become visible in the agent messages.\n\n## Roadmap\n\nPending feedback, we're considering the following features:\n\n- [Support the MCP protocol](https://github.com/coder/agentapi/issues/1)\n- [Support the Agent2Agent Protocol](https://github.com/coder/agentapi/issues/2)\n\n## Long-term vision\n\nIn the short term, AgentAPI solves the problem of how to programmatically control coding agents. As time passes, we hope to see the major agents release proper SDKs. One might wonder whether AgentAPI will still be needed then. We think that depends on whether agent vendors decide to standardize on a common API, or each sticks with a proprietary format.\n\nIn the former case, we'll deprecate AgentAPI in favor of the official SDKs. In the latter case, our goal will be to make AgentAPI a universal adapter to control any coding agent, so a developer using AgentAPI can switch between agents without changing their code.\n","funding_links":[],"categories":["Agent Protocols","Go","Proxies \u0026 Model Integrations","Agent Orchestration","其他工具与实用程序"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fagentapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder%2Fagentapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fagentapi/lists"}