Parameters & Experiments
Manage typed configuration for your AI application. Define a schema once, create experiments with different values, and resolve the active configuration at runtime.
For the conceptual overview (schemas, versions, environments, visibility), see Parameters and Experiments. This page covers the SDK API.
Quick start
Defining schemas
A schema declares the typed slots your project supports. Each field has a name, a type, and an optional default.
You can pass bare Python values as defaults — the SDK wraps them automatically:
Push the schema with Parameters.put_schema():
Read it back:
Supported types
| Type | Python type | Example default |
|---|---|---|
text | str | Multi-line prompt text |
string | str | "gpt-4o" |
number | float | 0.7 |
integer | int | 1024 |
boolean | bool | True |
enum | str | "text" (requires options) |
model_ref | UUID | Reference to a Rhesis model |
secret_ref | UUID | Reference to a stored secret |
Resolving parameters
Parameters.get() accepts a project name or UUID and returns a ResolvedParameters mapping:
Resolution order
Parameters.get() resolves from the most specific pin to the broadest environment pointer. Use this order when you need predictable deployment behavior:
| Source | How to request it | When to use it |
|---|---|---|
| Explicit version | Parameters.get("My Project", version="v3") | Immutable deploy pins and reproducing a past run |
| Explicit experiment | Parameters.get("My Project", experiment_id="exp-uuid") | Latest version of one experiment |
| Explicit environment | Parameters.get("My Project", environment="production") | Runtime routing through an environment pointer |
| Environment variable | RHESIS_PARAMETERS_ENVIRONMENT=production | Code-free deployment routing when no explicit argument is passed |
| Default environment | No version, experiment_id, or environment | The implicit default environment |
The SDK also accepts the legacy RHESIS_PARAMETERS_LABEL environment variable as an alias for RHESIS_PARAMETERS_ENVIRONMENT.
Accessing values
Values are unwrapped to native Python types automatically based on the schema. Use dot access, dictionary access, or .get() with a fallback:
Explicit typed accessors
For runtime type validation, typed accessors are also available. These raise TypeError on a type mismatch and return None (or your default) for missing keys:
get_str() accepts both text and string types, useful when you don’t care about the distinction.
Provenance
Every ResolvedParameters carries metadata about where the values came from:
Caching
- Version lookups are cached forever (versions are immutable).
- Environment and experiment lookups are cached with a 60-second TTL.
Force a re-fetch:
Managing environments
Rhesis always recognizes the built-in environments exported by BuiltInEnvironment. Environment names are still free-form strings, but using the constants avoids typos in application code.
| Constant | Value | Typical use |
|---|---|---|
BuiltInEnvironment.DEFAULT | default | The implicit fallback used by Parameters.get() |
BuiltInEnvironment.DEVELOPMENT | development | Local or development deployments |
BuiltInEnvironment.STAGING | staging | Pre-production validation |
BuiltInEnvironment.PRODUCTION | production | Production traffic |
Older SDK and API payloads may still contain labels, source_label, or
parameter_source_label. The v0.8.0 SDK normalizes those names to
environments on read. Use environment and RHESIS_PARAMETERS_ENVIRONMENT in
new code.
Experiments
See Experiments entity for the full CRUD reference. The most common workflows:
Step-by-step
One-liner with publish()
publish() does create, commit, share, and promote in a single call.
Viewing results
Retrieve aggregated test-run statistics for an experiment:
Running tests with parameters
Pass an Experiment object, or raw experiment_id / version / environment strings, to TestSet.execute() to pin a test run to a specific configuration:
When you pass only experiment_id without a version, the backend automatically resolves to the experiment’s latest version. You don’t need to look up the version identifier yourself.
The resolved values are snapshotted at queue time. Moving an environment after the run is queued does not affect it.
Reading parameters from a test run
Connector injection
When the platform runs tests against your @endpoint-decorated function, resolved parameters are available in the request_mapping as \{\{ params.<name> \}\} — the same syntax used for REST endpoints.
Request mapping (recommended)
Parameters are rendered through the same Jinja2 template engine as input, test_id, and other platform variables. During a test run with an experiment, params.model resolves to the experiment’s value. Without an experiment, the default() filter provides the fallback.
Context-resolved fetch
For production code that calls Parameters.get() internally, the platform also sets a context variable so the same call returns the experiment snapshot during test runs — no network request, no branching:
If you only need the current test-run snapshot and do not want fallback API resolution, use get_parameters():
Next Steps
- Experiments entity reference for the full CRUD API
- Connector Injection for protocol details
- Experiments concepts for the mental model (versions, environments, visibility)