Skip to main content

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

preclinical-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

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

Hashes for preclinical-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f2a44dbed954cbec1b2e93617b98c5bdcc60ba710cb84a79ff8bf7588d0d3dc6
MD5 0c8ca5e5f2ee206e0de16309359c6cbe
BLAKE2b-256 3733ec883e8da6bb0db8517e74e29dee38b7336400a81b8d4f5b0d668144da81

See more details on using hashes here.

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

Hashes for preclinical-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c4003609836f8167a83a992e01851cf27eaea890ee58c303784fa1427daf79a
MD5 52e534667d987d432c494570dcc3e858
BLAKE2b-256 540183ebbb37d9e96fbd909039f96fa8b59a075794cb2df5ef09d07437b2785f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page