DEV Community

Cover image for I Built a Local-First Alternative to LangSmith in Python (No Cloud, No Setup)-Shivnath Tathe
Shivnath Tathe
Shivnath Tathe

Posted on

I Built a Local-First Alternative to LangSmith in Python (No Cloud, No Setup)-Shivnath Tathe

LLM apps are getting more complex. A simple prompt call turns into a pipeline: embed the query, retrieve documents, call a model, parse the answer, maybe call tools, then run a second model pass. When something breaks, terminal logs are not enough.

That is where tracing tools help. LangSmith does this well — but it requires a cloud account, works best inside LangChain, and sends your trace data to a hosted service.

For a lot of projects, that is more than I need. I wanted something closer to this:

pip install opensmith
Enter fullscreen mode Exit fullscreen mode

No Docker. No account. No config. No data leaving my machine.

So I built opensmith.


What is opensmith?

opensmith is a local-first LLM pipeline tracer for Python.

It stores traces in SQLite at ~/.opensmith/traces.db and serves a local dashboard at localhost:7823. The dashboard shows traces, nested steps, inputs, outputs, errors, latency, token usage, cost estimates, and live updates via WebSocket.

LangSmith opensmith
Setup Cloud account required pip install opensmith
Data privacy Sends traces to cloud 100% local, SQLite only
Framework Best with LangChain Works with any Python code
Cost Free tier then paid Free forever, open source
Offline No Yes
Dashboard Hosted localhost:7823

opensmith is to LangSmith what Ollama is to OpenAI — the local-first, privacy-first alternative.


How to use it

1. Decorator

The simplest way is the @trace decorator:

from opensmith import trace

@trace(tags=["production", "rag"])
def rag_pipeline(question: str):
    docs = search_docs(question)
    return call_llm(docs + question)
Enter fullscreen mode Exit fullscreen mode

It captures function name, inputs, output, errors, latency, and parent-child relationships for nested traced functions automatically.

2. Async support

Async functions work exactly the same way:

from opensmith import trace

@trace(tags=["async", "openai"])
async def call_llm(prompt: str):
    response = await openai.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": prompt}],
    )
    return response
Enter fullscreen mode Exit fullscreen mode

3. Context manager

For manual logging:

from opensmith import trace

with trace("my_pipeline", tags=["debug"]) as t:
    t.log("query", query)
    response = call_model(query)
    t.log("response", response)
Enter fullscreen mode Exit fullscreen mode

4. Zero-code autopatch

For existing codebases, autopatch monkey-patches supported SDKs with zero code changes:

from opensmith import autopatch

# Patch everything
autopatch()

# Patch only specific backends
autopatch(only=["openai", "qdrant"])

# Patch everything except specific backends
autopatch(exclude=["chromadb"])
Enter fullscreen mode Exit fullscreen mode

Supported autopatch targets:

  • OpenAI
  • Anthropic
  • LiteLLM
  • Qdrant
  • ChromaDB
  • Pinecone

If a package is not installed, opensmith skips it silently.

5. Console mode

For terminal-first workflows:

from opensmith import set_console_mode, trace

set_console_mode(True)

@trace
def classify_intent(text: str):
    return classifier(text)
Enter fullscreen mode Exit fullscreen mode

This prints traces as they finish:

✓ classify_intent  245ms  [42 tokens  $0.000105]
✗ extract_entities  300ms  ERROR: ValueError: response exceeded max tokens
Enter fullscreen mode Exit fullscreen mode

6. Project config

Add an opensmith.json to your project root:

{
  "db_path": "./my_traces.db",
  "console_mode": false,
  "autopatch": ["openai", "qdrant"]
}
Enter fullscreen mode Exit fullscreen mode

opensmith reads this on import and applies it automatically.


The Dashboard

Start the dashboard with:

opensmith ui
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:7823.

opensmith dashboard

v0.1.2 dashboard includes:

  • Live WebSocket updates via SQLite polling
  • Search bar
  • Filter by status (OK / ERR)
  • Filter by tags
  • Model column
  • Token and cost rollups from steps
  • Latency SVG bar chart
  • Token SVG bar chart
  • Inline trace detail with input/output JSON
  • Nested step timeline
  • LIVE indicator

Everything runs locally. No data leaves your machine.


CLI reference

opensmith ui        # Start dashboard at localhost:7823
opensmith traces    # List recent traces in terminal
opensmith stats     # Show aggregate stats
opensmith clear     # Clear all traces
Enter fullscreen mode Exit fullscreen mode

Install

pip install opensmith
Enter fullscreen mode Exit fullscreen mode

Requires Python 3.10+.


What's next

opensmith is still early. Some things I want to explore:

  • Better cost tables for more model providers
  • More SDK autopatch targets
  • Trace export and import
  • OpenTelemetry-compatible export without requiring cloud
  • Better support for long-running and streaming traces
  • Trace comparison views

Links

If you are building LLM apps in Python and want tracing without sending data to a hosted service, I would love your feedback. And if this looks useful, a ⭐ on GitHub would mean a lot — it helps others discover the project.

What would you want from a local-first tracing tool for AI pipelines?

Top comments (0)