Skip to main content
Production targets let you point an EvalSuite at a system that’s actually serving users. Each target is just a callable that takes a string and returns a string, so you can pass it directly to suite.run() anywhere a model_fn is accepted. Install the extras you need:
After installing the browser extra, also run playwright install chromium once.

DeployedAPITarget

Wraps a deployed REST endpoint as an eval target. Handles auth, retries, rate limiting, and response extraction from nested JSON.

Parameters

Behavior

  • Auth. BearerAuth(token) sends Authorization: Bearer <token>. APIKeyAuth(key, header="X-API-Key") sends a custom header. Pass either one to the auth argument; their headers are merged with headers.
  • Retries. 429 and 5xx responses are retried with exponential backoff using (2 ** attempt) * 0.5 seconds between attempts. After all retries are exhausted, a RuntimeError is raised with the last status code and attempt count, e.g. DeployedAPITarget failed after 3 attempt(s): HTTP 503 after 3 attempt(s).
  • Missing dependency. If the requests package isn’t installed, the constructor raises ImportError immediately rather than failing on the first call.
  • Response extraction. output_path walks the JSON response. Each segment is treated as a list index when the current value is a list, otherwise as a dict key. Missing keys return an empty string.

MultiTurnAPITarget

Session-aware target for evaluating multi-turn conversations. Initializes a session (optional), sends the running history on each turn, and supports EvalCase.conversation.

Parameters

Behavior

  • Calling target(input) is a single-turn shortcut — it wraps run_conversation for suite.run() compatibility.
  • run_conversation(turns, evaluators=None) returns (final_response, eval_results). Each user turn is sent with the running history; assistant turns in the input are appended directly without making a request.
  • On error after all retries, the turn’s response is set to the literal string "[API ERROR]" and the conversation continues.

BrowserTarget

Experimental. API and behavior may change. Known limitations:
  • No page state reset between eval cases. The page stays open across calls; a chat UI that accumulates history will work, but anything with per-session state will not.
  • Login uses hard-coded selectors (input[type='email'], input[type='password']). OAuth, SSO, and CAPTCHA are not supported.
  • wait_for_load_state("networkidle") is unreliable for SPAs with long-polling or WebSocket connections. Pass a wait_for= selector to wait on a specific response element instead.
  • No context manager support. Call close() explicitly or wrap usage in try/finally to avoid leaking browser processes on failure.
Playwright-based target for browser-rendered AI applications. Opens a real browser, optionally logs in, submits input via a CSS selector, waits for the response, and extracts the response text.

Parameters

When a call fails, the target returns the literal string "[BROWSER ERROR: <message>]" so that the eval continues. Always call target.close() when finished.

simulate_users

Generate synthetic adversarial and edge-case user personas, run each one against any target, and evaluate the responses.

Parameters

Persona types

Return value

A list of dicts, one per persona:
If target invocation raises, output is set to "[TARGET ERROR: <message>]" and evaluation continues.

Auth helpers

Both targets accept the same auth helpers. You can also implement your own — anything with a headers() -> dict[str, str] method works.