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.3.tar.gz (17.8 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.3-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dottle_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 17.8 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.3.tar.gz
Algorithm Hash digest
SHA256 2156a5ff721b16471f71d521ca614126c681cb72aafb0f43f18841ff2ca05f6c
MD5 2a1b05f766c99f7abaf52c4579b5bdf8
BLAKE2b-256 7124aa06ff4241ab49eaacb0193a905d1a1107c875e0a6046962e3479f0230e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dottle_sdk-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f2fdf3cfd0d3549449998164dd1f5a4ecd9c4411fa83407e3aede43d47355812
MD5 43c82c00bb68dbbd78acddea1ad3c7a6
BLAKE2b-256 6209b829012d097f39047235301de324e854212ff0afbb4740d06f61d3eccdec

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