Configuration
Configure testrelic-deepeval with environment variables, the credentials file, base-url overrides, and project/repo identity.
testrelic-deepeval is configured through environment variables, the credentials file, or explicit arguments. You rarely need more than testrelic login to get started — this page covers the full set of options.
Environment variables
| Variable | Purpose |
|---|---|
TESTRELIC_API_KEY | Your TestRelic API key |
TESTRELIC_BASE_URL | Override the full evals URL (used as-is, e.g. https://<host>/api/v1/evals) |
TESTRELIC_CLOUD_ENDPOINT | Override the cloud endpoint shared with the other TestRelic SDKs (/evals is appended for you). Ignored when TESTRELIC_BASE_URL is set |
TESTRELIC_PROJECT | Project identity to attach the run to |
TESTRELIC_REPO_GIT_ID | Repository git identity for the run |
Create an API key from your org — see API keys.
Authentication precedence
When the SDK resolves a setting, it uses the first source that provides a value:
- Explicit arguments to
testrelic.configure() - Environment variables
- Credentials file (
~/.testrelic/credentials.toml) - Defaults
The credentials file is only read when no API key comes from an argument or the environment — so with TESTRELIC_API_KEY set, a base_url saved by testrelic login is not used.
Configuring in code
testrelic.configure() sets the active configuration for the process — useful in notebooks or scripts that call evaluate():
import testrelic
testrelic.configure(
api_key="tr_live_...", # or leave unset to use env / credentials file
project="rag-experiments",
repo_git_id="my-org/llm-pipeline",
timeout_seconds=30.0, # request timeout (default 30)
)It also accepts base_url= and enabled=. If no API key resolves from any source, uploads are disabled and become no-ops. The endpoint must use https (plain http is accepted only for localhost).
Credentials file
testrelic login writes credentials to ~/.testrelic/credentials.toml (mode 0600 on POSIX; restricted to the current user on Windows). Remove them with testrelic logout.
Endpoint override
The cloud endpoint defaults to the TestRelic production endpoint (https://platform.testrelic.ai/api/v1/evals), and your tr_* key authenticates against it — you normally never change this. To point the SDK at a different endpoint, use any of the following (highest priority first):
- the
base_url=argument totestrelic.configure()— the full evals URL, - the
TESTRELIC_BASE_URLenvironment variable — the full evals URL, - the
TESTRELIC_CLOUD_ENDPOINTenvironment variable — the API base;/evalsis appended for you, - the
--base-urlflag at login (saved to the credentials file; the full evals URL):
testrelic login --api-key <key> --base-url <url>Project and repo identity
Use TESTRELIC_PROJECT and TESTRELIC_REPO_GIT_ID to control which project and repository a run is attached to. The SDK also auto-detects CI context — branch, commit, and CI URL — for GitHub Actions, GitLab, Jenkins, CircleCI, and Buildkite, so these are usually inferred automatically in CI.
Offline queue location
Undeliverable uploads are written to ~/.testrelic/queue/ and replayed with testrelic drain, which needs an API key and exits non-zero if any entry still fails.
evaluate() wrapper options
The programmatic wrapper is a drop-in for deepeval.evaluate():
from testrelic import evaluate
results = evaluate(test_cases, metrics, **kwargs)test_cases— your DeepEval test cases.metrics— the DeepEval metrics to evaluate against.**kwargs— forwarded unchanged todeepeval.evaluate()(for examplehyperparameters=).
The wrapper takes no TestRelic-specific arguments; to change the endpoint or credentials, call testrelic.configure() first. Authentication and identity follow the precedence rules above. An upload failure is logged as a warning and never raises. The return value is whatever deepeval.evaluate() returns; the upload happens automatically.