Skip to main content

ThinkingSDK

AI crash debugging for Python in production. One line catches every uncaught exception in your live app, ships it to ThinkingSDK's analysis service, and gives you back the root cause and a concrete fix, not just another stack trace.

PyPI version Python License: MIT

pip install thinkingsdk
import thinkingsdk as thinking

thinking.start(
    api_key="sk_live_...",
    server_url="https://api.thinkingsdk.ai",  # hosted service; the SDK otherwise defaults to localhost
)

That is it. Deploy. When your app throws an unhandled exception, in a request handler, a worker thread, or a background job, ThinkingSDK captures it with full context, analyzes it, and shows you the diagnosis in your dashboard at thinkingsdk.ai. Get your project key there.

What you get for every crash

  • Root cause in plain language. Why it happened, grounded in the actual stack and the local variables at each frame, not just where it threw.
  • A concrete fix. The specific code change to make, not a generic "handle the exception."
  • Full context. Stack trace, locals per frame, and the execution path into the failure.
  • Smart grouping. Repeated crashes are deduplicated, so one real bug is one issue, not a thousand alerts.

How it works

ThinkingSDK installs exception hooks at startup:

  • sys.excepthook for the main thread and threading.excepthook for worker threads, so no uncaught exception escapes unseen.
  • Captured events are sent asynchronously in batches on a background sender, off your request path, so reporting a crash never blocks or slows the failing request.
  • Only runtime event data leaves your process. Your source code is never uploaded.

Deeper call tracing and performance capture are available via config, off by default to keep overhead near zero.

Performance

ThinkingSDK is built to stay off your application's hot path. The capture path is cheap and bounded; the network and the AI analysis happen elsewhere. What makes that true, in the client itself:

  • Background daemon thread, sends off your request path; capture just enqueues in microseconds.
  • Bounded ring buffer (deque(maxlen=…)), drops oldest when full instead of back-pressuring, so a flood can't stall your app or grow memory.
  • Batching (50 events, or ~2s), flat network cost, not one request per event.
  • Circuit breaker, pauses sending after repeated backend failures, so a down service can't become retry pressure on you.
  • Bounded retries + exponential backoff + hard request timeout, all confined to the background thread.
  • Priority sampling, exceptions/errors always captured, routine events sampled by rate.
  • Call-stack dedup, a hot error loop collapses to one analyzed issue, not thousands of sends.
  • Idle-until-throw hooks, excepthook adds no per-call/per-line cost on the happy path; deeper tracing is opt-in.

Framework and library integrations

Awareness for the stack you already run:

  • Web: FastAPI, Flask, Django
  • Data: SQLAlchemy, psycopg2, PyMongo, Redis
  • Standard library: logging

Production example (FastAPI)

import thinkingsdk as thinking
from fastapi import FastAPI

thinking.start(api_key="sk_live_...", server_url="https://api.thinkingsdk.ai")

app = FastAPI()

@app.get("/orders/{order_id}")
def get_order(order_id: str):
    # If this raises in production, ThinkingSDK captures it with the request
    # context and returns an AI root cause plus a fix in your dashboard.
    return load_order(order_id)

When load_order blows up on a malformed id, you do not get a bare KeyError buried in your logs. You get:

KeyError in get_order -> load_order at order_store.py:42

Root cause: load_order indexes self._orders[order_id] directly, but order_id
arrives from the URL unvalidated, so any unknown id raises KeyError instead of
returning a 404.

Suggested fix:
    order = self._orders.get(order_id)
    if order is None:
        raise HTTPException(status_code=404, detail="order not found")
    return order

Configuration

thinking.start() accepts:

  • api_key: your project key from thinkingsdk.ai
  • server_url: set this to https://api.thinkingsdk.ai for the hosted service (or via THINKINGSDK_SERVER_URL). It defaults to http://localhost:8000 for local dev, so crashes won't reach the hosted dashboard unless you set it.
  • config: a dict of tuning options
thinking.start(
    api_key="sk_live_...",
    server_url="https://api.thinkingsdk.ai",
    config={
        "capture_exceptions": True,
        "capture_performance": False,
        "sample_rate": 1.0,   # e.g. 0.1 to sample 10% on a high traffic service
    },
)

Environment variables

export THINKINGSDK_API_KEY=sk_live_...
export THINKINGSDK_SERVER_URL=https://api.thinkingsdk.ai   # required for the hosted service (defaults to localhost)

Self hosting

The analysis service (the AI engine and dashboard) runs as a separate component. server_url selects which one: https://api.thinkingsdk.ai for the hosted service, or your own deployment. The SDK's built-in default is http://localhost:8000 (local dev), so set server_url for anything else. See thinkingsdk.ai for details.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thinkingsdk-0.1.1.tar.gz (101.3 kB view details)

Uploaded Source

Built Distribution

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

thinkingsdk-0.1.1-py3-none-any.whl (99.5 kB view details)

Uploaded Python 3

File details

Details for the file thinkingsdk-0.1.1.tar.gz.

File metadata

  • Download URL: thinkingsdk-0.1.1.tar.gz
  • Upload date:
  • Size: 101.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.11

File hashes

Hashes for thinkingsdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2aa8691b5135f350196a8a82780b69c1052723c1ff8d9ffca4a2e82476409539
MD5 51d93e2d295a30b3df3f2a840e1db92a
BLAKE2b-256 a2e689eba4a2a3216bfafda1384facb3a9762764b5f01758193554d7817fc682

See more details on using hashes here.

File details

Details for the file thinkingsdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: thinkingsdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 99.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.11

File hashes

Hashes for thinkingsdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f45db375fb619d6fa0c6645710e0cd17a8c1e45b1850d26eabfe58e9786dd7a
MD5 1b1c0d7212c40aff4698c46f46130bec
BLAKE2b-256 cbc52d301a334c9742c0044c186253de998f4edfa8e7c52769b203da43d12333

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