Skip to main content

Python SDK for Introspection — continuously improve your AI systems with production feedback and frontier practices

Project description

Build frontier AI systems that self-improve.

Website PyPI version License Follow on X

Introspection continuously improves your AI systems with production feedback and frontier practices. This is the Python SDK.

Install

uv add introspection-sdk
# or
pip install introspection-sdk

The default install is everything you need for the Introspection API (runtimes, tasks, files, conversations) — no OpenTelemetry pulled in. To also emit analytics events and export traces, add the [otel] extra; see OpenTelemetry below.

Introspection API (runtimes, tasks, files)

The main Introspection API. Open a Runner against a runtime, spawn tasks, and stream their output; manage files and read conversations on the same Runner. AsyncIntrospectionClient is the recommended entry point — everything that touches the network is awaitable, and run output streams with async for:

import asyncio

from introspection_sdk import AsyncIntrospectionClient


async def main() -> None:
    async with AsyncIntrospectionClient() as client:  # token from INTROSPECTION_TOKEN
        runner = await client.runtimes("customer-agent").run()

        async with runner:
            run = await runner.tasks.start(prompt="Say hello in one sentence.")

            async for event in run.stream():
                print(f"[{event.event}] {event.data}")


asyncio.run(main())

A Runner exposes three DP-bound namespaces side by side: runner.tasks, runner.files, and the read-only runner.conversations. The conversations namespace lists conversation summaries (runner.conversations.list()), loads the latest LLM turn of a conversation as a Responses-API-style view (await runner.conversations.retrieve(conversation_id)), and walks a conversation's per-turn items (runner.conversations.items.list(...)).

Every list() returns an AsyncPager: async for it to stream every item across pages (fetched lazily), or await it for the first page with its envelope metadata (counts, cursors):

# Stream every summary across all pages.
async for summary in runner.conversations.list(limit=20):
    response = await runner.conversations.retrieve(
        summary.conversation_id or summary.trace_id
    )
    if response is not None:
        print(response.model, len(response.input_messages))

# Or just the first page, with totals.
first = await runner.files.list(include_total=True)
print(first.total_count, len(first.records))

See examples/api/async_runtimes.py for an end-to-end walkthrough.

Sync client

Not on asyncio? IntrospectionClient is the synchronous twin with an identical surface — drop the awaits, use for instead of async for, and with instead of async with (examples/api/runtimes.py):

from introspection_sdk import IntrospectionClient

client = IntrospectionClient()  # token from INTROSPECTION_TOKEN
runner = client.runtimes("customer-agent").run()

run = runner.tasks.start(prompt="Say hello in one sentence.")
for event in run.stream():
    print(f"[{event.event}] {event.data}")

runner.close()
client.shutdown()

OpenTelemetry (analytics & tracing)

Two optional OTel-based surfaces live behind the [otel] extra, independent of the Introspection API above:

pip install 'introspection-sdk[otel]'
  • Analytics eventstrack / feedback / identify via IntrospectionLogs.
  • Traces — auto-instrument Anthropic, Gemini, OpenAI Agents, Claude Agent, LangChain, and Logfire with a single introspection_sdk.init().

Both are documented in docs/otel.md; advanced/manual wiring lives in docs/advanced.md. For complete integration patterns (including dual-export with Arize, Langfuse, Braintrust, and LangSmith) see examples/.

Environment variables

# Introspection API (IntrospectionClient / AsyncIntrospectionClient)
export INTROSPECTION_TOKEN="intro_xxx"
export INTROSPECTION_BASE_API_URL="https://api.introspection.dev"   # optional
export INTROSPECTION_PROJECT_ID="proj_…"                            # optional

# OTel (IntrospectionLogs + span processors + instrumentors) — see docs/otel.md
export INTROSPECTION_BASE_OTEL_URL="https://otel.introspection.dev" # optional
export INTROSPECTION_SERVICE_NAME="my-service"                      # optional

Documentation

Full documentation is available at docs.introspection.dev.

License

Apache-2.0

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

introspection_sdk-0.5.1.tar.gz (93.6 kB view details)

Uploaded Source

Built Distribution

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

introspection_sdk-0.5.1-py3-none-any.whl (125.7 kB view details)

Uploaded Python 3

File details

Details for the file introspection_sdk-0.5.1.tar.gz.

File metadata

  • Download URL: introspection_sdk-0.5.1.tar.gz
  • Upload date:
  • Size: 93.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for introspection_sdk-0.5.1.tar.gz
Algorithm Hash digest
SHA256 1f2142a32bd309f64646d28ad4731c84b26dd01701be3af23832383575104913
MD5 6ff5f91ef639a1ab19507babe0dc8eab
BLAKE2b-256 8601343a38051fe314be560d23a739be387c8a58d772efe0ed023c7ea736018e

See more details on using hashes here.

Provenance

The following attestation bundles were made for introspection_sdk-0.5.1.tar.gz:

Publisher: publish.yml on introspection-org/introspection-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file introspection_sdk-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for introspection_sdk-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16d370aa81c4ee0c67dd61d01230252b868e41c8a3e4c7907ff68ab489d29a69
MD5 875809028a0a1ac6cae2c272c3de6466
BLAKE2b-256 dae7d5b6482a79ca05130b7339fadef20947b8da30860485a1be217f6032a17a

See more details on using hashes here.

Provenance

The following attestation bundles were made for introspection_sdk-0.5.1-py3-none-any.whl:

Publisher: publish.yml on introspection-org/introspection-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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