Sonny Labs Docs
SDK ReferencePython

SonnyLabsClient

The main sonnylabs client class — constructor, scan methods, identity and API-key endpoints, and the underlying httpx transport hook.

SonnyLabsClient is the main entry point exported from sonnylabs. It wraps httpx against the v1 OpenAPI schema, layers in authentication, idempotency, retry-on-429/503, and translates application/problem+json responses into the typed exception hierarchy.

import os
from sonnylabs import SonnyLabsClient

client = SonnyLabsClient(api_key=os.environ["SONNY_API_KEY"])

The full set of constructor arguments lives on its own page: Constructor options.

Methods

Prop

Type

Methods that raise NotImplementedError correspond to API operations that the SDK does not yet expose as typed helpers. Calling them raises NotImplementedError so call sites get a clear failure mode rather than a silent AttributeError while support is added in a future release.

Lifecycle

SonnyLabsClient holds an httpx.Client connection pool. Use it as a context manager so the pool is released deterministically, or call .close() from a teardown hook:

with SonnyLabsClient(api_key=os.environ["SONNY_API_KEY"]) as client:
    scan = client.create_scan(
        surface="user_message",
        content={"type": "text", "text": user_prompt},
    )

USER_AGENT

USER_AGENT is the string the SDK sends on the User-Agent header of every request. Useful for surfacing the SDK version in your own logs:

from sonnylabs.client import USER_AGENT

print(USER_AGENT)
# sonnylabs-python/0.1.0 httpx/0.27.0

On this page