RhesisClient
The RhesisClient is the central entry point for the Rhesis SDK. It initializes telemetry, manages the connector for remote testing, and provides access to the Rhesis API.
Initialization
Parameters
| Parameter | Required | Description |
|---|---|---|
api_key | No | API key for authentication. Falls back to RHESIS_API_KEY env var. |
base_url | No | API base URL. Falls back to RHESIS_BASE_URL env var. Default: https://api.rhesis.ai |
project_id | No | Project ID for endpoint registration and tracing. Falls back to RHESIS_PROJECT_ID env var, then to the project bound to the API token. |
environment | No | Environment name. Falls back to RHESIS_ENVIRONMENT env var. Default: development |
Project ID Resolution
The client resolves project_id in the following order:
- Explicit parameter passed to the constructor
RHESIS_PROJECT_IDenvironment variable- Token introspection - if the API token is scoped to a project, the client automatically resolves the project ID from the token
If a project-scoped token is used and an explicit project_id is also provided, the values must match. A project-scoped token cannot be used to access a different project.
Organization-scoped tokens (without a project boundary) require an explicit project_id via the constructor or environment variable.
The RhesisClient must be initialized before using @observe or @endpoint decorators. Without it, a RuntimeError is raised.
The WebSocket connector is lazy: it is created only when @endpoint is used.
Environment Variables
Configure the client entirely through environment variables:
Environment Values
The environment parameter determines where your endpoints and traces are registered:
| Value | Use Case |
|---|---|
development | Local development and testing |
staging | Pre-production validation |
production | Live systems |
Disabling the Client
To disable all SDK functionality (useful for CI/CD or testing):
Accepted values: true, 1, yes, on (case-insensitive)
When disabled:
@endpointand@observedecorators return functions unmodified- No telemetry initialization occurs
- No WebSocket connection is established
- All SDK method calls become no-ops
Usage Patterns
Tracing Only
For observability without remote testing:
Remote Testing
For registering functions as testable endpoints: