Skip to content

AsyncClearTrace Client

Attributes

Name Type Description
model_id str \| None Model ID for the current job.
feature_names list[str] \| None Column names captured during fit.
status StatusResult Current job status.

Methods

outerproduct.async_client.AsyncClearTrace

Async client for the OuterProduct ClearTrace API.

Mirrors ClearTrace but uses httpx.AsyncClient and asyncio.sleep for non-blocking I/O. Intended for use in async contexts such as MCP servers, FastAPI handlers, and notebooks.

Parameters:

Name Type Description Default
base_url str

API server URL. Defaults to OUTERPRODUCT_API_URL env var, then https://cleartrace-api.onrender.com.

None
api_key str

Bearer token. Defaults to OUTERPRODUCT_API_KEY env var.

None
timeout float

Max seconds for HTTP requests and async job polling.

300
poll_interval float

Initial delay between status polls (exponential backoff).

2.0
max_retries int

Retries on transient HTTP errors (502/503/504).

3

Methods:

Name Description
aclose

Close the underlying HTTP connection pool.

get_status

Current job status.

create_upload

Request a presigned upload URL from the API.

upload_fileobj

Upload data to S3 using a presigned URL.

upload_file

Upload a data file to S3 via a presigned URL.

fit

Train a ClearTrace model on labelled data.

fit_distill

Distill a black-box model via its predict URL.

predict

Batch predictions for X. Returns a numpy array.

explain

Batch prediction + AGOP-based explanation.

predict_and_explain

Batch predict and explain in one call.

interpret

Global feature importance via AGOP.

get_schema

Retrieve the persisted schema manifest for the loaded model.

scenario

Counterfactual search with constraints.

segment

Supervised segmentation (async).

get_segments

Retrieve completed segmentation results.

narrative

LLM-generated natural language summary (async).

get_narrative

Retrieve completed narrative results.

health

Check API server health.

load

Attach to an existing model by ID.

aclose() async

Close the underlying HTTP connection pool.

get_status(*, model_id=None) async

Current job status.

create_upload(file_format, *, model_id=None) async

Request a presigned upload URL from the API.

See ClearTrace.create_upload for full documentation.

upload_fileobj(upload, fileobj) async

Upload data to S3 using a presigned URL.

See ClearTrace.upload_fileobj for full documentation.

upload_file(path) async

Upload a data file to S3 via a presigned URL.

See ClearTrace.upload_file for full parameter documentation.

fit(data=None, *, target, feature_fields=None, feature_schema=None, wait=True, **config) async

Train a ClearTrace model on labelled data.

See ClearTrace.fit for full parameter documentation.

fit_distill(data=None, predict_url=None, *, target=None, predict_headers=None, labels=None, feature_fields=None, feature_schema=None, wait=True, **config) async

Distill a black-box model via its predict URL.

See ClearTrace.fit_distill for full parameter documentation.

predict(X, *, model_id=None) async

Batch predictions for X. Returns a numpy array.

explain(X, *, model_id=None, feature_names=None, use_sqrt=True, raw_gradient=True) async

Batch prediction + AGOP-based explanation.

See ClearTrace.explain for full parameter documentation.

predict_and_explain(X, *, model_id=None, feature_names=None, use_sqrt=False, raw_gradient=True, with_persona=False, rule_kwargs=None) async

Batch predict and explain in one call.

See ClearTrace.predict_and_explain for full parameter documentation.

interpret(*, model_id=None) async

Global feature importance via AGOP.

get_schema(*, model_id=None) async

Retrieve the persisted schema manifest for the loaded model.

scenario(queries, *, model_id=None, feature_names=None, desired_class=1, n_walks=500, max_steps=30, epsilon=0.2, random_state=42, constraints=None) async

Counterfactual search with constraints.

See ClearTrace.scenario for full parameter documentation.

segment(*, model_id=None, data=None, target_values=None, feature_names=None, min_clusters=4, max_clusters=10, n_search_steps=50, use_agent=None, kpi_field=None, problem_context=None, wait=True) async

Supervised segmentation (async).

See ClearTrace.segment for full parameter documentation.

get_segments(*, model_id=None) async

Retrieve completed segmentation results.

narrative(data, *, model_id=None, feature_names=None, kpi_name, context=None, max_tool_calls=6, wait=True) async

LLM-generated natural language summary (async).

See ClearTrace.narrative for full parameter documentation.

get_narrative(*, model_id=None) async

Retrieve completed narrative results.

health() async

Check API server health.

load(model_id)

Attach to an existing model by ID.