|
1 | 1 | # AgentAPI
|
2 | 2 |
|
3 | 3 | Control Claude Code, Goose, and Aider with an HTTP API.
|
| 4 | + |
4 | 5 | <div>
|
5 | 6 | <img width="800px" src="https://github.com/user-attachments/assets/4b9950f5-bfa7-4f38-bf09-58364f78c100">
|
6 | 7 | </div>
|
7 | 8 |
|
8 |
| -## Usage |
| 9 | +## Quickstart |
| 10 | + |
| 11 | +Install `agentapi` by downloading the latest release binary from the [releases page](https://github.com/coder/agentapi/releases) and putting it in your PATH. |
| 12 | + |
| 13 | +Run a Claude Code server (assumes `claude` is installed on your system): |
9 | 14 |
|
10 |
| -AgentAPI is under active development. Release binaries will be available soon. |
| 15 | +```bash |
| 16 | +agentapi server -- claude |
| 17 | +``` |
11 | 18 |
|
12 |
| -To run the server with Claude Code: |
| 19 | +Send a message to the agent: |
13 | 20 |
|
14 | 21 | ```bash
|
15 |
| -go run main.go server -- claude |
| 22 | +curl -X POST localhost:3284/message \ |
| 23 | + -H "Content-Type: application/json" \ |
| 24 | + -d '{"content": "Hello, agent!", "type": "user"}' |
16 | 25 | ```
|
17 | 26 |
|
18 |
| -You may also pass additional arguments to the agent command. For example: |
| 27 | +Get the conversation history: |
| 28 | + |
| 29 | +```bash |
| 30 | +curl localhost:3284/messages |
| 31 | +``` |
| 32 | + |
| 33 | +## CLI Commands |
| 34 | + |
| 35 | +### `agentapi server` |
| 36 | + |
| 37 | +Run 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. |
19 | 38 |
|
20 | 39 | ```bash
|
21 |
| -go run main.go server -- claude --allowedTools "Bash(git*) Edit Replace" |
| 40 | +agentapi server -- claude --allowedTools "Bash(git*) Edit Replace" |
22 | 41 | ```
|
23 | 42 |
|
24 |
| -By default, the server runs on port 3284. You can inspect the available endpoints by opening http://localhost:3284/docs. |
| 43 | +You may also use `agentapi` to run the Aider and Goose agents: |
| 44 | + |
| 45 | +```bash |
| 46 | +agentapi server -- aider --model sonnet --api-key anthropic=sk-ant-apio3-XXX |
| 47 | +agentapi server -- goose |
| 48 | +``` |
| 49 | + |
| 50 | +By default, the server runs on port 3284. The server exposes an OpenAPI schema at http://localhost:3284/openapi.json. You may also inspect the available endpoints at http://localhost:3284/docs. |
25 | 51 |
|
26 | 52 | There are 4 endpoints:
|
27 | 53 |
|
28 | 54 | - GET `/messages` - returns a list of all messages in the conversation with the agent
|
29 | 55 | - POST `/message` - sends a message to the agent. When a 200 response is returned, AgentAPI has detected that the agent started processing the message
|
30 |
| -- GET `/status` - returns the current status of the agent, either "waiting_for_input" or "running" |
31 |
| -- GET `/events` - an SSE stream of events from the agent: new messages and status updates |
| 56 | +- GET `/status` - returns the current status of the agent, either "stable" or "running" |
| 57 | +- GET `/events` - an SSE stream of events from the agent: message and status updates |
| 58 | + |
| 59 | +### `agentapi attach` |
| 60 | + |
| 61 | +Attach to a running agent's terminal session. |
| 62 | + |
| 63 | +```bash |
| 64 | +agentapi attach --url localhost:3284 |
| 65 | +``` |
| 66 | + |
| 67 | +Press `ctrl+c` to detach from the session. |
32 | 68 |
|
33 | 69 | ## How it works
|
34 | 70 |
|
35 |
| -AgentAPI runs an in-memory terminal emulator. It translates API calls into appropriate terminal keystrokes, and parses the agent's outputs into individual messages using a set of heuristics. |
| 71 | +AgentAPI runs an in-memory terminal emulator. It translates API calls into appropriate terminal keystrokes, and parses the agent's outputs into individual messages. At the time of writing, none of the agents expose a native HTTP API. Once they do, AgentAPI will be updated to support them. |
0 commit comments