Control Claude Code, Goose, and Aider with an HTTP API.
Install agentapi
:
- Download the latest release binary from the releases page
- Rename it (e.g.
mv agentapi-darwin-arm64 agentapi
) - Make it executable (
chmod +x agentapi
) - Put it in your PATH (e.g.
sudo mv agentapi /usr/local/bin
) - Verify the installation (
agentapi --help
) - (macOS) If you're prompted that macOS was unable to verify the binary, go to
System Settings -> Privacy & Security
, click "Open Anyway", and run the command again.
Run a Claude Code server (assumes claude
is installed on your system):
agentapi server -- claude
Send a message to the agent:
curl -X POST localhost:3284/message \
-H "Content-Type: application/json" \
-d '{"content": "Hello, agent!", "type": "user"}'
Get the conversation history:
curl localhost:3284/messages
You may go to https://coder.github.io/agentapi/chat to see a web chat interface making use of your local AgentAPI server.
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.
agentapi server -- claude --allowedTools "Bash(git*) Edit Replace"
You may also use agentapi
to run the Aider and Goose agents:
agentapi server -- aider --model sonnet --api-key anthropic=sk-ant-apio3-XXX
agentapi server -- goose
The OpenAPI schema is available in this repository: openapi.json.
By default, the server runs on port 3284. Additionally, the server exposes an OpenAPI schema at http://localhost:3284/openapi.json. You may also inspect the available endpoints at http://localhost:3284/docs.
There are 4 endpoints:
- GET
/messages
- returns a list of all messages in the conversation with the agent - POST
/message
- sends a message to the agent. When a 200 response is returned, AgentAPI has detected that the agent started processing the message - GET
/status
- returns the current status of the agent, either "stable" or "running" - GET
/events
- an SSE stream of events from the agent: message and status updates
Attach to a running agent's terminal session.
agentapi attach --url localhost:3284
Press ctrl+c
to detach from the session.
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.