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
docs: convert API proxy docs to Starlight format (#941)
- Add Starlight frontmatter (title, description) to both docs
- Convert GitHub blockquotes to Starlight admonitions
- Fix OPENAI_BASE_URL to include /v1 suffix
- Fix ANTHROPIC_BASE_URL to use IP address
- Remove inaccurate Squid config section
- Fix NO_PROXY value to match actual code
- Replace stale line number references
- Add health check and body limit documentation
- Add cross-references between related docs
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
description: Secure LLM API credential management using an isolated proxy sidecar container.
4
+
---
2
5
3
6
The AWF firewall supports an optional Node.js-based API proxy sidecar that securely holds LLM API credentials and automatically injects authentication headers while routing all traffic through Squid to respect domain whitelisting.
4
7
5
-
> [!NOTE]
6
-
> For a comprehensive deep dive into how AWF handles authentication tokens and credential isolation, see the [Authentication Architecture](authentication-architecture.md) guide.
8
+
:::note
9
+
For a deep dive into how AWF handles authentication tokens and credential isolation, see the [Authentication Architecture](./authentication-architecture.md) guide.
10
+
:::
7
11
8
12
## Overview
9
13
10
14
When enabled, the API proxy sidecar:
11
-
-**Isolates credentials**: API keys never exposed to agent container
15
+
-**Isolates credentials**: API keys are never exposed to the agent container
12
16
-**Auto-authentication**: Automatically injects Bearer tokens and API keys
13
17
-**Dual provider support**: Supports both OpenAI (Codex) and Anthropic (Claude) APIs
14
-
-**Transparent proxying**: Agent code uses standard environment variables
18
+
-**Transparent proxying**: Agent code uses standard SDK environment variables
15
19
-**Squid routing**: All traffic routes through Squid to respect domain whitelisting
16
20
17
21
## Architecture
@@ -29,9 +33,9 @@ When enabled, the API proxy sidecar:
29
33
│ │ │ Agent Container │ │
30
34
│ │ │ 172.30.0.20 │ │
31
35
│ │ │ OPENAI_BASE_URL= │ │
32
-
│ │ │ http://api-proxy:10000│────┘
36
+
│ │ │ http://172.30.0.30:10000/v1│────┘
33
37
│ │ │ ANTHROPIC_BASE_URL= │
34
-
│ │ │ http://api-proxy:10001 │
38
+
│ │ │ http://172.30.0.30:10001 │
35
39
│ │ └──────────────────────────────┘
36
40
│ │
37
41
└─────────┼─────────────────────────────────────┘
@@ -40,153 +44,175 @@ When enabled, the API proxy sidecar:
40
44
api.openai.com or api.anthropic.com
41
45
```
42
46
43
-
**Traffic Flow:**
44
-
1. Agent makes request to `api-proxy:10000` or `api-proxy:10001`
45
-
2. API proxy injects authentication headers
46
-
3. API proxy routes through Squid via HTTP_PROXY/HTTPS_PROXY
When API keys are provided, the sidecar sets these environment variables in the agent container:
106
+
When API keys are provided, AWF sets these environment variables in the agent container:
103
107
104
-
| Variable | Value | When Set| Description |
108
+
| Variable | Value | When set| Description |
105
109
|----------|-------|----------|-------------|
106
-
|`OPENAI_BASE_URL`|`http://api-proxy:10000`|When `OPENAI_API_KEY` is provided| OpenAI API proxy endpoint |
107
-
|`ANTHROPIC_BASE_URL`|`http://api-proxy:10001`|When `ANTHROPIC_API_KEY` is provided| Anthropic API proxy endpoint |
110
+
|`OPENAI_BASE_URL`|`http://172.30.0.30:10000/v1`|`OPENAI_API_KEY` is set| OpenAI API proxy endpoint |
111
+
|`ANTHROPIC_BASE_URL`|`http://172.30.0.30:10001`|`ANTHROPIC_API_KEY` is set| Anthropic API proxy endpoint |
108
112
109
113
These are standard environment variables recognized by:
110
-
- OpenAI Python SDK
111
-
- OpenAI Node.js SDK
112
-
- Anthropic Python SDK
113
-
- Anthropic TypeScript SDK
114
-
- Codex CLI tools
114
+
- OpenAI Python SDK (`openai`)
115
+
- OpenAI Node.js SDK (`openai`)
116
+
- Anthropic Python SDK (`anthropic`)
117
+
- Anthropic TypeScript SDK (`@anthropic-ai/sdk`)
118
+
- Codex CLI
115
119
- Claude Code CLI
116
120
117
-
## Security Benefits
121
+
:::tip
122
+
You don't need to change any agent code. The SDKs automatically read `*_BASE_URL` environment variables and redirect API calls through the proxy.
123
+
:::
118
124
119
-
### Credential Isolation
125
+
## Security benefits
126
+
127
+
### Credential isolation
120
128
121
129
API keys are held in the sidecar container, not the agent:
122
-
- Agent code cannot read API keys from environment
123
-
- Compromised agent cannot exfiltrate credentials
124
-
- Keys are not exposed to the agent container’s stdout/stderr logs
125
-
- Keys are stored in sidecar and deployment configuration on disk; protect host filesystem and config accordingly (only non-sensitive key prefixes may be logged for debugging)
130
+
- Agent code cannot read API keys from environment variables
131
+
- A compromised agent cannot exfiltrate credentials
132
+
- Keys are not exposed in the agent container's stdout/stderr logs
133
+
134
+
:::danger[Protect host credentials]
135
+
API keys are stored in the sidecar container's environment and in the Docker Compose configuration on disk. Protect the host filesystem and configuration accordingly. Only non-sensitive key prefixes are logged for debugging.
136
+
:::
126
137
127
-
### Network Isolation
138
+
### Network isolation
128
139
129
140
The proxy enforces domain-level egress control:
130
-
-Agent can only reach `api-proxy` hostname
131
-
-Sidecar routes ALL traffic through Squid proxy
132
-
- Squid enforces domain whitelist (L7 filtering)
133
-
-No firewall exemption needed for sidecar
141
+
-The agent can only reach the API proxy IP (`172.30.0.30`) for API calls
142
+
-The sidecar routes all traffic through Squid proxy
143
+
- Squid enforces the domain whitelist (L7 filtering)
144
+
-iptables rules prevent the agent from bypassing the proxy
134
145
135
-
### Resource Limits
146
+
### Resource limits
136
147
137
148
The sidecar has strict resource constraints:
138
-
-512MB memory limit
149
+
-512 MB memory limit
139
150
- 100 process limit
140
-
- All unnecessary capabilities dropped
151
+
- All capabilities dropped
141
152
-`no-new-privileges` security option
142
153
143
-
## How It Works
154
+
## How it works
144
155
145
-
### 1. Container Startup
156
+
### 1. Container startup
146
157
147
-
When `--enable-api-proxy` is set:
148
-
1. Node.js API proxy starts at 172.30.0.30
149
-
2. API keys passed via environment variables
150
-
3. HTTP_PROXY/HTTPS_PROXY configured to route through Squid
151
-
4.Agent container waits for sidecar health check
158
+
When you pass `--enable-api-proxy`:
159
+
1.AWF starts a Node.js API proxy at `172.30.0.30`
160
+
2. API keys are passed to the sidecar via environment variables
161
+
3.`HTTP_PROXY`/`HTTPS_PROXY` in the sidecar are configured to route through Squid
162
+
4.The agent container waits for the sidecar health check to pass
152
163
153
-
### 2. Request Flow
164
+
### 2. Request flow
154
165
155
166
```
156
167
Agent Code
157
-
↓ (makes HTTP request to api-proxy:10000)
168
+
↓ (HTTP request to 172.30.0.30:10000/v1)
158
169
Node.js API Proxy
170
+
↓ (strips client auth headers)
159
171
↓ (injects Authorization: Bearer $OPENAI_API_KEY)
160
-
↓ (routes via HTTP_PROXY to Squid)
172
+
↓ (routes via HTTPS_PROXY to Squid)
161
173
Squid Proxy
162
174
↓ (enforces domain whitelist)
163
175
↓ (TLS connection to api.openai.com)
164
176
OpenAI API
165
177
```
166
178
167
-
### 3. Header Injection
179
+
### 3. Header injection
180
+
181
+
The Node.js proxy automatically:
182
+
-**Strips** any client-supplied `Authorization`, `x-api-key`, `Proxy-Authorization`, and `X-Forwarded-*` headers
0 commit comments