Skip to main content

Dottle SDK — Instrument your AI agents in 3 lines of code. See every LLM call, tool, cost, and failure in real time.

Project description

Dottle SDK

Monitor your AI agents in minutes. See every LLM call, tool use, cost, latency, and failure — in real time.

dottle.dev · Dashboard · Docs


Install

pip install dottle-sdk

Quickstart

import dottle

# 1. Configure once at startup
dottle.configure(api_key="dtl_live_...")

# 2. Wrap your agent run in a session
with dottle.session("my-agent", user_id="user_123") as sid:

    # 3. Track each LLM call as a span
    with dottle.span("llm", "gpt-4o reply") as s:
        response = openai_client.chat.completions.create(...)
        s.record_tokens(
            prompt_tokens=response.usage.prompt_tokens,
            completion_tokens=response.usage.completion_tokens,
            model="gpt-4o",
        )

That's it. Open app.dottle.dev to see your agent's sessions, costs, and errors live.


Get your API key

  1. Sign up at app.dottle.dev
  2. Create an organization → create a project
  3. Copy the dtl_live_... key from Project Settings

What gets tracked

Signal How
LLM calls dottle.span("llm", ...) + s.record_tokens(...)
Tool calls dottle.span("tool", ...)
Errors s.record_error(exc) or automatic on exception
Cost Calculated from token counts + model
Latency Automatic (start/end of each span)
User Pass user_id / user_email to dottle.session()

Full example with Anthropic

import anthropic
import dottle

dottle.configure(api_key="dtl_live_...")
client = anthropic.Anthropic()

def run_agent(user_message: str, user_email: str):
    with dottle.session("support-agent", user_email=user_email) as sid:
        with dottle.span("llm", "claude-3-5-sonnet") as s:
            response = client.messages.create(
                model="claude-3-5-sonnet-20241022",
                max_tokens=1024,
                messages=[{"role": "user", "content": user_message}],
            )
            s.record_tokens(
                prompt_tokens=response.usage.input_tokens,
                completion_tokens=response.usage.output_tokens,
                model="claude-3-5-sonnet-20241022",
            )
        return response.content[0].text

LangChain integration

Zero-code-change tracking for LangChain chains, agents, and LangGraph — attach one callback handler and every LLM call and tool use is automatically recorded.

from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor
from dottle.integrations.langchain import DottleCallbackHandler
import dottle

dottle.configure(api_key="dtl_live_...")
handler = DottleCallbackHandler()

llm = ChatOpenAI(model="gpt-4o", callbacks=[handler])
agent_executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])

with dottle.session("my-langchain-agent", user_id="user_123") as sid:
    result = agent_executor.invoke({"input": "What is the weather in Tokyo?"})

What gets tracked automatically: model name, input/output text, token counts, cost, latency, tool call inputs/outputs, errors, and loop detection.

Works with: ChatOpenAI, ChatAnthropic, ChatGoogleGenerativeAI, all LangChain tools, LCEL chains, LangGraph nodes.

Full LangChain integration guide


Zero performance impact

All calls are fire-and-forget (background thread). Your agent never waits for Dottle. If Dottle is unreachable, your agent keeps running — monitoring failures are silently swallowed.


License

MIT

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

dottle_sdk-0.1.4.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

dottle_sdk-0.1.4-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file dottle_sdk-0.1.4.tar.gz.

File metadata

  • Download URL: dottle_sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.11.15 HTTPX/0.28.1

File hashes

Hashes for dottle_sdk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 296e1d7898a959dfaf7639e89ba6abbae0ae71ae6696e3d3fa399592020be675
MD5 6442b4c5d6a4b112e6ff7892c3a66178
BLAKE2b-256 be79fc500743c66e181b7bb85b89c004578950940feb5308d44c6577b117a0ef

See more details on using hashes here.

File details

Details for the file dottle_sdk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: dottle_sdk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.11.15 HTTPX/0.28.1

File hashes

Hashes for dottle_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 288919a83e23ebd4eb23e753209aa48324aa9e6d9dd1ae8d3b44773424e3b089
MD5 3dd2b8d1f4f2aee3f958e6341f754880
BLAKE2b-256 3dbed1a46be592614d1e504baa4b35b5d0dc388795c9a9b20a4a8887546171c8

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