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.
What It Does
When you create a RhesisClient, it:
- Resolves project scope - Determines the project from explicit config or token introspection
- Initializes telemetry - Sets up OpenTelemetry for tracing
- Registers as default - Becomes the default client for
@endpointand@observedecorators - Lazy-loads connector - WebSocket connector is initialized only when
@endpointis used
The RhesisClient must be initialized before using @observe or @endpoint decorators. Without it, a RuntimeError is raised.
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 |
Changes in production take effect immediately. Always test in development or staging first.
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: