You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- to build a unified chat interface for coding agents
@@ -54,9 +53,6 @@ You can use AgentAPI:
54
53
55
54
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.
56
55
57
-
> [!NOTE]
58
-
> When using Codex, always specify the agent type explicitly (`agentapi server --type=codex -- codex`), or message formatting may break.
59
-
60
56
```bash
61
57
agentapi server -- claude --allowedTools "Bash(git*) Edit Replace"
> When using Codex, always specify the agent type explicitly (`agentapi server --type=codex -- codex`), or message formatting may break.
69
+
71
70
An OpenAPI schema is available in [openapi.json](openapi.json).
72
71
73
72
By 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.
@@ -79,6 +78,54 @@ There are 4 endpoints:
79
78
- GET `/status` - returns the current status of the agent, either "stable" or "running"
80
79
- GET `/events` - an SSE stream of events from the agent: message and status updates
81
80
81
+
#### Allowed hosts
82
+
83
+
By 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.
84
+
85
+
To allow requests from any host, use `*` as the allowed host.
86
+
87
+
```bash
88
+
agentapi server --allowed-hosts '*' -- claude
89
+
```
90
+
91
+
To allow a specific host, use:
92
+
93
+
```bash
94
+
agentapi server --allowed-hosts 'example.com' -- claude
95
+
```
96
+
97
+
To 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.
98
+
99
+
```bash
100
+
agentapi server --allowed-hosts 'example.com,example.org' -- claude
101
+
# or
102
+
AGENTAPI_ALLOWED_HOSTS='example.com example.org' agentapi server -- claude
103
+
```
104
+
105
+
#### Allowed origins
106
+
107
+
By 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.
108
+
109
+
To allow requests from any origin, use `*` as the allowed origin:
110
+
111
+
```bash
112
+
agentapi server --allowed-origins '*' -- claude
113
+
```
114
+
115
+
To allow a specific origin, use:
116
+
117
+
```bash
118
+
agentapi server --allowed-origins 'https://example.com' -- claude
119
+
```
120
+
121
+
To 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`):
122
+
123
+
```bash
124
+
agentapi server --allowed-origins 'https://example.com,http://localhost:3000' -- claude
125
+
# or
126
+
AGENTAPI_ALLOWED_ORIGINS='https://example.com http://localhost:3000' agentapi server -- claude
{FlagChatBasePath, "c", "/chat", "Base path for assets and routes used in the static files of the chat interface", "string"},
182
194
{FlagTermWidth, "W", uint16(80), "Width of the emulated terminal", "uint16"},
183
195
{FlagTermHeight, "H", uint16(1000), "Height of the emulated terminal", "uint16"},
196
+
// localhost is the default host for the server. Port is ignored during matching.
197
+
{FlagAllowedHosts, "a", []string{"localhost", "127.0.0.1", "[::1]"}, "HTTP allowed hosts (hostnames only, no ports). Use '*' for all, comma-separated list via flag, space-separated list via AGENTAPI_ALLOWED_HOSTS env var", "stringSlice"},
198
+
// localhost:3284 is the default origin when you open the chat interface in your browser. localhost:3000 and 3001 are used during development.
199
+
{FlagAllowedOrigins, "o", []string{"http://localhost:3284", "http://localhost:3000", "http://localhost:3001"}, "HTTP allowed origins. Use '*' for all, comma-separated list via flag, space-separated list via AGENTAPI_ALLOWED_ORIGINS env var", "stringSlice"},
0 commit comments