Architecture
NexaLayer (Agent Layer) is an intermediate layer between AI Agents and an existing proxy backend. It provides agent-friendly APIs and session abstraction while delegating user/order/proxy operations to the backend.System positioning
Responsibility split
| Responsibility | Agent Layer | Backend |
|---|---|---|
| Agent auth (API Key / JWT) | ✅ | ❌ |
| Session lifecycle | ✅ | ❌ |
| Product/session recommendation | ✅ | ❌ |
| User/account creation | Proxy | ✅ |
| Order create / renew | Proxy | ✅ |
| Proxy IP allocation | Proxy | ✅ |
| Balance / recharge | Proxy | ✅ |
| Telemetry & health | ✅ | ❌ |
Layered architecture
Core modules
- Auth — API Key (X-API-Key) or JWT (Bearer). Per-key rate limit.
- Account — Register agent; 1:1 mapping to backend user; backend_user_id, backend_username, backend_token cache.
- Session — session_id, type (dynamic/static), status, proxy_config, rotation_policy, health (risk_level, health_score, success_rate), usage, expires_at.
- ProxyService — StaticProxyManager, DynamicProxyManager, SmartRouter; calls backend to create/renew/rotate/release proxies.
- Billing — getBalance, recharge, usage report; delegates to backend.
- Telemetry — reportEvent, batch, updateSessionHealth; stores events and drives health/recommendations.
Data flow (session create)
- Agent calls
POST /sessionswith type and config. - Agent Layer validates, checks balance (via backend or cache), creates session row (status
creating). - Agent Layer calls backend to create order / allocate proxy (async where applicable).
- Backend returns order/proxy details; Agent Layer updates session (proxy_config, status
active). - Agent polls
GET /sessions/{session_id}or receives webhook until active, then usesproxy.full_url.