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

VariablePurpose
TESTRELIC_API_KEYYour TestRelic API key
TESTRELIC_BASE_URLOverride the full evals URL (used as-is, e.g. https://<host>/api/v1/evals)
TESTRELIC_CLOUD_ENDPOINTOverride the cloud endpoint shared with the other TestRelic SDKs (/evals is appended for you). Ignored when TESTRELIC_BASE_URL is set
TESTRELIC_PROJECTProject identity to attach the run to
TESTRELIC_REPO_GIT_IDRepository 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:

  1. Explicit arguments to testrelic.configure()
  2. Environment variables
  3. Credentials file (~/.testrelic/credentials.toml)
  4. 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():

run_eval.py
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 to testrelic.configure() — the full evals URL,
  • the TESTRELIC_BASE_URL environment variable — the full evals URL,
  • the TESTRELIC_CLOUD_ENDPOINT environment variable — the API base; /evals is appended for you,
  • the --base-url flag at login (saved to the credentials file; the full evals URL):
Terminal
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 to deepeval.evaluate() (for example hyperparameters=).

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.

Next steps

Was this page helpful?

On this page