Self-hosting Letta

Learn how to run your own Letta server

The recommended way to use Letta locally is with Docker. To install Docker, see Docker’s installation guide. For issues with installing Docker, see Docker’s troubleshooting guide. You can also install Letta using pip.

Running the Letta Server

You can run a Letta server with Docker (recommended) or pip.

You can install the Letta server via pip under the letta package:

1pip install -U letta

To run the server once installed, simply run the letta server command: To add LLM API providers, make sure that the environment variables are present in your environment.

1export OPENAI_API_KEY=...
2letta server

Note that the letta package only installs the server - if you would like to use the Python SDK (to create and interact with agents on the server in your Python code), then you will also need to install letta-client package (see the quickstart for an example).

Once the Letta server is running, you can access it via port 8283 (e.g. sending REST API requests to http://localhost:8283/v1). You can also connect your server to the Letta ADE to access and manage your agents in a web interface.

Enabling model providers

The Letta server can be connected to various LLM API backends (OpenAI, Anthropic, vLLM, Ollama, etc.). To enable access to these LLM API providers, set the appropriate environment variables when you use docker run:

1# replace `~/.letta/.persist/pgdata` with wherever you want to store your agent data
2docker run \
3 -v ~/.letta/.persist/pgdata:/var/lib/postgresql/data \
4 -p 8283:8283 \
5 -e OPENAI_API_KEY="your_openai_api_key" \
6 -e ANTHROPIC_API_KEY="your_anthropic_api_key" \
7 -e OLLAMA_BASE_URL="http://host.docker.internal:11434" \
8 letta/letta:latest

The example above will make all compatible models running on OpenAI, Anthropic, and Ollama available to your Letta server.

Password protection (advanced)

To password protect your server, include SECURE=true and LETTA_SERVER_PASSWORD=yourpassword in your docker run command:

1# If LETTA_SERVER_PASSWORD isn't set, the server will autogenerate a password
2docker run \
3 -v ~/.letta/.persist/pgdata:/var/lib/postgresql/data \
4 -p 8283:8283 \
5 --env-file .env \
6 -e SECURE=true \
7 -e LETTA_SERVER_PASSWORD=yourpassword \
8 letta/letta:latest

With password protection enabled, you will have to provide your password in the bearer token header in your API requests:

1# install letta_client with `pip install letta-client`
2from letta_client import Letta
3
4# create the client with the token set to your password
5client = Letta(
6 base_url="http://localhost:8283",
7 token="yourpassword"
8)