Client Setup
The oRPC client is initialized insrc/server/orpc/client.ts:
Key Components
- RPCLink - HTTP transport layer that connects to
/api/rpcendpoint - RouterClient - Type-safe client inferred from server router
- TanStack Query Utils - Provides
queryOptions()for data fetching
The client is typed against the server router, so TypeScript will autocomplete all available procedures and validate input/output types at compile time.
API URL Configuration
The API endpoint is determined bygetRpcUrl() in src/core/shared/api/apiConfig.ts:
Environment Priority
- Production -
VITE_API_URLpoints to remote API server (e.g.,https://api.autonome.ai) - Development - Vite proxy forwards
/api/*tohttp://localhost:8081 - Fallback - Direct connection to
http://localhost:8081
Using the oRPC Client
Theorpc utility provides the queryOptions() pattern for TanStack Query:
Basic Query
Query with No Input
Mutations (Write Operations)
For mutations, use the raw
client object instead of orpc.*.*.queryOptions(). The client provides direct procedure calls that return promises.Type Safety
The oRPC client provides full end-to-end type safety:SSE Event Streams
For real-time data, use Server-Sent Events (SSE) endpoints:Available SSE Endpoints
SSE streams send a heartbeat ping every 15 seconds to keep connections alive. The initial message contains current state, followed by incremental updates.
Error Handling
All oRPC procedures wrap handlers with Sentry spans for monitoring:Client-Side Error Handling
CORS Configuration
The API server enables CORS for local development and production origins:Production CORS Setup
SetCORS_ORIGINS environment variable on the API server:
Authentication (Future)
Currently, Autonome runs in single-user mode with no authentication. Future versions will add:- API Keys - Per-user keys for API access
- JWT Tokens - Session-based authentication
- OAuth - Third-party authentication providers
Authentication will be implemented via oRPC middleware that validates tokens before routing to procedure handlers.
Next Steps
Trading API
Fetch trades, positions, and market data
Simulator API
Paper trade with the exchange simulator
Models API
Manage AI models and view invocations
Analytics API
Access performance metrics and leaderboards

