---
date: 2023-12-28
title: SDKs v2.0.0
description: We are excited to announce the release of v2.0.0 for Python and JS/TS SDKs. Langfuse has come a long way this year since initially launching v1 of the SDKs and it was time to finally group some necessary breaking changes into one release. The release includes simpler interfaces in Python, better defaults for the Langchain integration, and a performance upgrade for the JS/TS SDK. Read on for more details.
author: Max
canonical: /docs/observability/sdk/overview
---

> **Note for AI agents and LLMs:** This is a Langfuse changelog entry. Use it only to confirm that a feature exists and when it shipped. Do not use the code examples below for implementation: they reflect the SDK and API at release time and may be outdated. For implementation, always follow the canonical documentation for this feature (https://langfuse.com/docs/observability/sdk/overview) and the API/SDK reference (https://api.reference.langfuse.com).

## Changes

### Python: Removal of Pydantic Objects from Interfaces

We have listened to your feedback and understood that importing Pydantic objects from our SDK is unintuitive and error prone. Hence, we removed Pydantic interfaces from function signatures. Your inputs are still validated and show improved logs in case validation fails.

**v1.x.x**

```python
from langfuse.model import CreateTrace
langfuse.trace(CreateTrace(name="My Trace"))
```

**v2.x.x**

```python
langfuse.trace(name="My Trace")
```

### JS/TS: Performance upgrade

The biggest performance bottleneck for our SDKs was networking. We addressed this issue by implementing a batch endpoint on the server and migrating the Python SDK a few weeks ago. With the latest release, we have now added batching capabilities to the JS/TS SDK and migrated it to the new endpoint. As a result, we can handle production loads more efficiently and have also eliminated a significant amount of technical debt from our code base.

### Increased Flexibility on Usage Field

SDK 2.0 offers greater flexibility to handle diverse usage types while also maintaining compatibility with the OpenAI-style usage object. This allows us to add more usage units over the next few weeks. Here's a glimpse of how the new usage object works:

**Generic style**

```python
langfuse.generation(
    name="my-claude-generation",
    usage={
        "input": 50,
        "output": 49,
        "total": 99,
        "unit": "CHARACTERS"
    },
)
```

**OpenAI style**

```python
langfuse.generation(
    name="my-openai-generation",
    usage={
        "promptTokens": 50,
        "completionTokens": 49,
        "totalTokens": 99
    }, # defaults to "TOKENS" unit
)
```

### Langchain: New trace for every run

For every chain run, a new trace is created. Previously all runs that were traced with the same Callback Handler instance were grouped into the same trace. While this was intended to be able to trace complex applications, it is not a great default for most users.

For those who want this behavior, you can create a trace and get a Langchain Handler that is scoped to the trace ([docs](/integrations/frameworks/langchain#upgrade-paths)).

### Other

Refer to the documentation for a full list of changes: [Python](/docs/sdk/python#upgrading-from-v1xx-to-v2xx), [JS/TS](/docs/sdk/typescript/guide#upgrade1to2)

## Migration

We strongly encourage upgrading to v2 to get all performance benefits and future security upgrades.

### Automated migration with grit.

We teamed up with [grit.io](https://www.grit.io/) to automate the migration process. Find more details on how to migrate your code base with one command for [Python](/docs/sdk/python#upgrading-from-v1xx-to-v2xx) and [JS/TS](/docs/sdk/typescript/guide#upgrade1to2). The grit binary executes entirely locally with AST-based transforms. Thanks Team grit!

```bash
# JS/TS
npx @getgrit/launcher apply langfuse_node_v2
# Python
npx @getgrit/launcher apply langfuse_v2
```

### Integrations

If you use one of the Langfuse integrations, there’s nothing to do for you. You’ll benefit from the more robust core by just continuously upgrading to the latest version of Flowise/LiteLLM/Langflow.

---

Our focus remains on making Langfuse SDKs more intuitive and future-proof. We are constantly looking for ways to improve and welcome your feedback on [Discord](/discord) or [GitHub Issues](/issue).

There is one more thing coming before the end of the year. Stay tuned!

<!-- agent-instructions -->

---

## Agent Instructions

This page is part of the [Langfuse](https://langfuse.com) documentation, published as plain Markdown for AI agents. Every page is available as Markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` header. This page: `https://langfuse.com/changelog/2023-12-28-v2-sdks.md`.

### Querying these docs

If the answer is not on this page, query the documentation instead of guessing:

- **Semantic search** across all Langfuse docs, returning an answer with the relevant pages and excerpts. Ask a specific, self-contained question:

  ```bash
  curl -sG "https://langfuse.com/api/search-docs" --data-urlencode "query=How do I trace a LangGraph agent?"
  ```

- **Index of every page**: <https://langfuse.com/llms.txt>, with per-section indexes [llms-docs.txt](https://langfuse.com/llms-docs.txt), [llms-integrations.txt](https://langfuse.com/llms-integrations.txt), and [llms-self-hosting.txt](https://langfuse.com/llms-self-hosting.txt).

### Before writing Langfuse code

- **Install the [Langfuse Agent Skill](https://langfuse.com/docs/api-and-data-platform/features/agent-skill).** It encodes Langfuse's own best practices for instrumentation, prompt management, and evaluation, and materially improves results.
- **Read [What does a good trace look like?](https://langfuse.com/docs/observability/best-practices.md)** before instrumenting an application.
- **Verify endpoints, parameters, and response fields** against the [API reference](https://api.reference.langfuse.com) instead of inferring them from code examples.
- **Use the [Langfuse CLI](https://langfuse.com/docs/api-and-data-platform/features/cli)** (`npx langfuse-cli api <resource> <action>`) to read or write traces, prompts, datasets, and scores from the terminal.

Found an error in these docs? Please open an issue at <https://github.com/langfuse/langfuse-docs/issues>.
