PRODUCT — APR 17, 2025

Announcing Letta Client SDKs for Python and TypeScript

Announcing Letta Client SDKs for Python and TypeScript artwork

We've officially released our auto-generated client SDKs and unified documentation platform built with Fern. For developers using Letta, this means more reliable libraries, TypeScript support (in addition to Python), and a significantly improved developer experience across all our APIs.

Letta: The OS for Agents

Letta is the operating system for AI agents, managing state, context, and execution so developers can build intelligent applications that actually learn and improve with experience. Unlike traditional frameworks that rely on stateless APIs, Letta functions as a complete agent operating system where agents run as persistent services that maintain state across interactions, intelligently manage their context window, and access both in-context and external memory—transforming them from simple responders into systems that genuinely learn over time.

Letta’s Agents API

Letta works as a managed API service (rather than a library), so everything from creating, modifying, and interacting with agents is through a REST API that interact with a Letta server (either a self-deployed Docker image or Letta Cloud).

pip install letta-client
from letta_client import Letta

# connect to a local server
client = Letta(base_url="http://localhost:8283")

# create an agent with two basic self-editing memory blocks
agent_state = client.agents.create(
    memory_blocks=[
        {
          "label": "human",
          "value": "name: Chad"
        },
        {
          "label": "persona",
          "value": "You are a helpful assistant that loves emojis"
        }
    ],
    model="openai/gpt-4o-mini",
    embedding="openai/text-embedding-3-small"
)

# send a message to the agent
response = client.agents.messages.create(
    agent_id=agent_state.id,
    messages=[
        {
            "role": "user",
            "content": "hows it going????"
        }
    ]
)

Since agents are lightweight services, they can easily be connected to your end-application. Letta agents can even create, modify, or invoke other Letta agents through connecting to the Letta API through their tools.

Building SDKs for the Agents API

While many early users of Letta (previously MemGPT) build applications interacting with our REST API service, we knew that most developers expected to use SDKs for building AI applications – especially given the complexity of the API.

Previously, we manually implemented our Python SDK on top of our REST API, resulting in:

The result? You were likely hitting limitations, writing workarounds, or falling back to direct REST API calls rather than using our SDK.

What We Did

We took an API-first approach and now generate all client libraries and documentation from a single OpenAPI specification using Fern:

  1. Defined our complete API with OpenAPI as the single source of truth
  2. Set up Fern to generate our REST API docs, TypeScript SDK, and Python SDK
  3. Configured generators for our specific requirements, including streaming (server-sent events) support

See our TypeScript and Python SDK repositories and API reference.

What's Changed

For you as a developer, this means:

How It Works Now

Developers can use the Python or Node SDKs to interact with the Letta service, and easily toggle between a local Letta service or Letta Cloud:

npm install @letta-ai/letta-client
import { LettaClient } from '@letta-ai/letta-client';

// connect to a local server
const client = new LettaClient({
  baseUrl: "http://localhost:8283",
});

// create an agent with two basic self-editing memory blocks
const agentState = await client.agents.create({
    memoryBlocks: [
        {
            label: "human",
            value: "name: Chad"
        },
        {
            label: "persona",
            value: "You are a helpful assistant that loves emojis"
        }
    ],
    model: "openai/gpt-4o-mini",
    embedding: "openai/text-embedding-3-small"
});

// send a message to the agent
const response = await client.agents.messages.create(agentState.id, {
    messages: [
        {
            role: "user",
            content: "hows it going????"
        }
    ]
});

Streaming, which was particularly complex to implement manually, now looks like this:

// send a message to the agent (streaming)
const stream = await client.agents.messages.createStream(agentState.id, {
    messages: [
        {
            role: "user",
            content: "hows it going????"
        }
    ],
    // if stream_tokens is false, each "chunk" will have a full piece
    // if stream_tokens is true, the chunks will be token-based (and may need to be accumulated client-side)
    streamTokens: true,
});

// print the chunks coming back
for await (const chunk of stream) {
    console.log(chunk);
}

Both token and step streaming are supported now, as well as async messages for long-running agent invocations.

Benefits We're Seeing

For our engineering team, auto-generated SDKs have eliminated hours of manual work and bugs:

  1. No more SDK drift - when we update the API, SDKs automatically update
  2. Faster feature development - we can focus on building the API, not maintaining client libraries
  3. Better QA - consistent behavior across all platforms means fewer edge cases
  4. Improved developer feedback - we're hearing that the new SDKs "just work"

What's Next

With our Fern integration established, we're planning to:

Check It Out