Python SDK for the Preclinical healthcare AI safety testing platform
Project description
Preclinical Python SDK
Python SDK for the Preclinical healthcare AI safety testing platform.
Installation
pip install preclinical
Quick Start
from preclinical import Preclinical
client = Preclinical(api_key="sk_live_...")
# Start a test
test = client.tests.run_and_wait(
CreateTestParams(agent_id="your-agent-id", test_mode="demo")
)
print(f"Status: {test.status}")
print(f"Pass rate: {test.pass_rate}%")
# Get detailed results
results = client.tests.results(test.id)
for r in results.data:
status = "PASS" if r.passed else "FAIL"
print(f"[{status}] {r.scenario_name}")
Usage
from preclinical import Preclinical, CreateAgentParams, CreateTestParams
# Initialize (context manager closes the HTTP client)
with Preclinical(api_key="sk_live_...") as client:
# Agents
agents = client.agents.list()
agent = client.agents.create(CreateAgentParams(
name="My Agent",
provider="openai",
config={"api_key": "sk-...", "base_url": "https://api.openai.com/v1", "target_model": "gpt-4o"},
))
client.agents.validate(agent.id)
# Tests
created = client.tests.create(CreateTestParams(agent_id=agent.id))
test = client.tests.get(created.id)
results = client.tests.results(created.id)
# Scenario runs (with transcript)
run = client.scenario_runs.get(results.data[0].id)
for entry in run.transcript:
print(f"[{entry['role']}]: {entry['content']}")
# Scenarios
scenarios = client.scenarios.list()
# Webhooks
webhooks = client.webhooks.list()
Documentation
Full API docs at docs.preclinical.co
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
preclinical-0.1.0.tar.gz
(5.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
File details
Details for the file preclinical-0.1.0.tar.gz.
File metadata
- Download URL: preclinical-0.1.0.tar.gz
- Upload date:
- Size: 5.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 |
f2a44dbed954cbec1b2e93617b98c5bdcc60ba710cb84a79ff8bf7588d0d3dc6
|
|
| MD5 |
0c8ca5e5f2ee206e0de16309359c6cbe
|
|
| BLAKE2b-256 |
3733ec883e8da6bb0db8517e74e29dee38b7336400a81b8d4f5b0d668144da81
|
File details
Details for the file preclinical-0.1.0-py3-none-any.whl.
File metadata
- Download URL: preclinical-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 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 |
1c4003609836f8167a83a992e01851cf27eaea890ee58c303784fa1427daf79a
|
|
| MD5 |
52e534667d987d432c494570dcc3e858
|
|
| BLAKE2b-256 |
540183ebbb37d9e96fbd909039f96fa8b59a075794cb2df5ef09d07437b2785f
|