Repository navigation
Closed
Description
Summary
Implement the Anthropic API proxy that is shown in the egg architecture diagram but not yet implemented. This is a core security feature that enables zero-credential exposure in the sandbox.
Architecture Reference
From README.md:
│ │ │ Anthropic Proxy │◄─┼──────────┼──│ Claude Code │
│ │ │ (credential inject) │ │ Proxy │ │ (ANTHROPIC_BASE_URL) │
Components to Implement
1. gateway/anthropic_credentials.py (new file)
Extract from jib's gateway-sidecar/anthropic_credentials.py:
AnthropicCredentialdataclass (header_name, header_value)AnthropicCredentialsManagerclass with mtime-based cache invalidation- Support for both API key (
x-api-key) and OAuth token (Authorization: Bearer) - Thread-safe credential access
2. Gateway Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/v1/messages |
POST | Anthropic API proxy with streaming SSE support |
/v1/messages/count_tokens |
POST | Token counting API proxy |
3. Key Features
- Streaming SSE support: Forward streaming responses from Anthropic API
- Credential injection: Add API key/OAuth header before forwarding
- Blocked tools filtering (private mode): Filter out
web_search,WebSearch,web_fetch,WebFetchfrom tool lists - IP-based session lookup: Use
get_session_by_ip()(from Phase 2a) to determine session mode - Connection pooling: Singleton httpx client for efficiency
Dependencies
- Phase 2a must be complete (
get_session_by_ip()method required)
Acceptance Criteria
-
anthropic_credentials.pyextracted and adapted for egg -
/v1/messagesendpoint with streaming support -
/v1/messages/count_tokensendpoint - Credential injection working (API key and OAuth)
- Blocked tools filtering in private mode
- IP-based session mode detection
- Integration test with mock Anthropic API
Reference
- jib implementation:
james-in-a-box/gateway-sidecar/anthropic_credentials.py - jib gateway proxy code:
james-in-a-box/gateway-sidecar/gateway.py(search for/v1/messages)
Authored-by: jib
Metadata
Metadata
Assignees
Labels
No labels
Activity
Add Anthropic API proxy with credential injection
jwbron commentedon Feb 3, 2026
#20
Phase 2b: Anthropic API proxy with credential injection (#20)
plan(1557): address reviewer_plan NACK — fix two-query JQL + 10 non-b…