Skip to main content

Adaline

The main client class for interacting with the Adaline platform. Provides methods to fetch deployments, manage cached deployment controllers with background refresh, and initialize monitoring.

Constructor

All constructor parameters are keyword-only.

Parameters

str | None
Your Adaline API key. Defaults to the ADALINE_API_KEY environment variable.
str | None
The base URL for the Adaline API. Falls back to the ADALINE_BASE_URL environment variable, then https://api.adaline.ai/v2.
bool
default:"False"
If True, enables DEBUG-level logging on the adaline logger with a StreamHandler that outputs [Adaline] LEVEL: message.

Methods

get_deployment

Fetches a specific prompt deployment by prompt ID and deployment ID. This is an async method.

Parameters

str
required
The unique ID of the prompt.
str
required
The specific deployment ID.
Returns: A Deployment object. Raises: ApiException if the API call fails (4xx errors fail immediately, 5xx errors are retried).

get_latest_deployment

Fetches the latest deployment for a prompt in a specific environment. This is an async method.

Parameters

str
required
The unique ID of the prompt.
str
required
The deployment environment ID.
Returns: The latest Deployment object for the given environment. Raises: ApiException if the API call fails.

init_latest_deployment

Initializes a cached latest deployment with automatic background refresh. Fetches the latest deployment immediately, then starts a background loop that refreshes the cache at the given interval. This is an async method.

Parameters

str
required
The unique ID of the prompt.
str
required
The deployment environment ID.
int
default:"60"
Seconds between background refreshes. Clamped to [1, 600].
int
default:"3"
Number of consecutive failures before the background loop stops itself.
Returns: A Controller instance for retrieving and managing the cached deployment. Raises: ApiException if the initial fetch fails.

Controller

The Controller class returned by init_latest_deployment provides:

init_evaluation_results

Initializes a cached, polling fetcher for evaluation results. Mirrors init_latest_deployment but targets EvaluationsClient.get_results. Useful when an evaluation is still running server-side and you want to surface partial results without writing your own polling loop — the same query (pagination + filters) is replayed on every refresh. This is an async method.

Parameters

str
required
The unique ID of the prompt.
str
required
The unique ID of the evaluation.
str | None
Filter by grade: "pass", "fail", or "unknown".
str | None
Pass "row" to include the underlying dataset row in each result.
str | None
Sort order: "createdAt:asc", "createdAt:desc", "score:asc", or "score:desc".
int | None
Page size.
str | None
Pagination cursor from a previous response.
int
default:"60"
Seconds between background refreshes. Clamped to [1, 600].
int
default:"3"
Consecutive failures before the background loop stops itself.
Returns: An EvaluationResultsController exposing get(force_refresh=False), get_background_status(), and stop() — identical in shape to the deployment controller. Raises: ApiException if the initial fetch fails.

init_monitor

Initializes and returns a new Monitor instance for logging traces and spans. This is a synchronous method.

Parameters

str
required
Unique project identifier for grouping traces and spans.
int
default:"1"
Interval (in seconds) at which the buffer is automatically flushed.
int
default:"1000"
Maximum number of buffered entries before oldest items are dropped.
LogSpanContent | None
Default content attached to spans when none is provided. See LogSpanContent for available types. Defaults to an LogSpanOtherContent with empty input/output.

Namespace clients

Seven namespace clients are attached to every Adaline instance. Each wraps the corresponding autogen API with retry-on-5xx, abort-on-4xx, and keyword-only arguments: Raw escape hatches are also exposed:
  • adaline.deployments_api — raw DeploymentsApi from adaline_api
  • adaline.logs_api — raw LogsApi (used internally by Monitor)
If you need identical retry behavior on an arbitrary call, use the exported with_retry helper:
Returns: A Monitor instance.