Python SDK for the Ashr Labs API
Project description
Ashr Labs Python SDK
A Python client library for evaluating AI agents against Ashr Labs test datasets.
Documentation
- Testing Your Agent — start here
- Quick Start Guide
- Installation
- Authentication
- API Reference
- Error Handling
- Examples
Installation
pip install ashr-labs
Quick Start
from ashr_labs import AshrLabsClient, EvalRunner
# Only need your API key — base_url and tenant_id are automatic
client = AshrLabsClient(api_key="tp_your_api_key_here")
# Fetch a dataset and run your agent against it
runner = EvalRunner.from_dataset(client, dataset_id=42)
run = runner.run(my_agent)
# Inspect results
metrics = run.build()["aggregate_metrics"]
print(f"Passed: {metrics['tests_passed']}/{metrics['total_tests']}")
print(f"Avg similarity: {metrics['average_similarity_score']}")
# Submit results
run.deploy(client, dataset_id=42)
Your agent just needs two methods:
class MyAgent:
def respond(self, message: str) -> dict:
# Call your LLM, return {"text": "...", "tool_calls": [...]}
return {"text": "response", "tool_calls": []}
def reset(self) -> None:
# Clear conversation history between scenarios
pass
See Testing Your Agent for a full end-to-end guide.
Available Methods
All methods that accept tenant_id auto-resolve it from your API key if omitted.
Datasets
| Method | Description |
|---|---|
get_dataset(dataset_id, ...) |
Get a dataset by ID |
list_datasets(limit, offset, ...) |
List datasets |
Runs
| Method | Description |
|---|---|
create_run(dataset_id, result, ...) |
Create a new test run |
get_run(run_id) |
Get a run by ID |
list_runs(dataset_id, limit, offset) |
List runs |
delete_run(run_id) |
Delete a run |
EvalRunner
| Method | Description |
|---|---|
EvalRunner.from_dataset(client, dataset_id) |
Create a runner from a dataset |
runner.run(agent) |
Run agent against all scenarios, return RunBuilder |
runner.run_and_deploy(agent, client, dataset_id) |
Run and submit in one call |
RunBuilder
| Method | Description |
|---|---|
RunBuilder() |
Create a new run builder |
run.start() |
Mark the run as started |
run.add_test(test_id) |
Add a test and get a TestBuilder |
run.complete(status) |
Mark the run as completed |
run.build() |
Serialize to a result dict |
run.deploy(client, dataset_id) |
Build and submit via the API |
TestBuilder
| Method | Description |
|---|---|
test.start() |
Mark the test as started |
test.add_user_file(file_path, description) |
Record a user file upload |
test.add_user_text(text, description) |
Record a user text input |
test.add_tool_call(expected, actual, match_status) |
Record an agent tool call |
test.add_agent_response(expected_response, actual_response, match_status) |
Record an agent response |
test.complete(status) |
Mark the test as completed |
Requests
| Method | Description |
|---|---|
create_request(request_name, request, ...) |
Create a new request |
get_request(request_id) |
Get a request by ID |
list_requests(status, limit, offset) |
List requests |
API Keys & Session
| Method | Description |
|---|---|
init() |
Validate credentials and get user/tenant info |
list_api_keys(include_inactive) |
List API keys for your tenant |
revoke_api_key(api_key_id) |
Revoke an API key |
health_check() |
Check if the API is reachable |
Error Handling
from ashr_labs import AshrLabsClient, NotFoundError, AuthenticationError
client = AshrLabsClient(api_key="tp_...")
try:
dataset = client.get_dataset(dataset_id=999)
except AuthenticationError:
print("Invalid API key")
except NotFoundError:
print("Dataset not found")
Configuration
# All defaults — just pass API key
client = AshrLabsClient(api_key="tp_...")
# From environment (reads ASHR_LABS_API_KEY)
client = AshrLabsClient.from_env()
# Custom timeout
client = AshrLabsClient(api_key="tp_...", timeout=60)
# Custom base URL (for self-hosted)
client = AshrLabsClient(api_key="tp_...", base_url="https://your-api.example.com")
Requirements
- Python 3.10+
- No external dependencies (uses only standard library)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ashr_labs-0.1.1.tar.gz
(25.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ashr_labs-0.1.1-py3-none-any.whl
(20.5 kB
view details)
File details
Details for the file ashr_labs-0.1.1.tar.gz.
File metadata
- Download URL: ashr_labs-0.1.1.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f3165eafe6e3bce5addfb8b86ab20d711b5c7edad700d2a498dfe4ee225928b
|
|
| MD5 |
8674bb4cd1a1e1145d3848ae3e71b10f
|
|
| BLAKE2b-256 |
22bd92d5afe6505e81456f9d797de3dcd4d0612ab5d7316924e39c450a48459a
|
File details
Details for the file ashr_labs-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ashr_labs-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
222d5950a2c0cad569f910e7008ab5a2cb321ea251e0496d37cb8b35774f6f29
|
|
| MD5 |
1bf966b35c11f358be18fafd842b4630
|
|
| BLAKE2b-256 |
7b7740a3cf543e51034fe2945ea83616ec1094b91b09cbbe12ff6b7bfca0afeb
|