Skip to main content

Installation

Requires Python 3.11+. The SDK depends on httpx and Pydantic v2.

Imports

AsyncPikarc

The main client. Creates an underlying httpx.AsyncClient configured with your API key.

Parameters

Methods

run(user_id, metadata?)

Async context manager that starts a guarded run and auto-ends it on exit.
Lifecycle:
  • On entry: calls POST /v1/runs/ and evaluates guardrails. Raises PikarcBlockedError if denied.
  • On clean exit: calls POST /v1/runs/{id}/end with status COMPLETED.
  • On exception: calls POST /v1/runs/{id}/end with status FAILED, then re-raises.

close()

Closes the underlying HTTP client. Call this when you’re done with the guard instance.

Async Only

The SDK is async-only for the MVP. All methods must be called with await inside an async context. If you need sync usage, wrap calls with asyncio.run():