To use Letta with Azure OpenAI, set the environment variables AZURE_API_KEY and AZURE_BASE_URL. You can also optionally specify AZURE_API_VERION (default is 2024-09-01-preview)

You can use Letta with OpenAI if you have an OpenAI account and API key. Once you have set your AZURE_API_KEY and AZURE_BASE_URL specified in your environment variables, you can select what model and configure the context window size

Currently, Letta supports the following OpenAI models:

  • gpt-4 (recommended for advanced reasoning)
  • gpt-4o-mini (recommended for low latency and cost)
  • gpt-4o
  • gpt-4-turbo (not recommended, should use gpt-4o-mini instead)
  • gpt-3.5-turbo (not recommended, should use gpt-4o-mini instead)

Enabling Azure OpenAI models

To enable the Azure provider, set your key as an environment variable:

$export AZURE_API_KEY="..."
>export AZURE_BASE_URL="..."
>
># Optional: specify API version (default is 2024-09-01-preview)
>export AZURE_API_VERSION="2024-09-01-preview"

Now, Azure OpenAI models will be enabled with you run letta run or the letta service.

Using the docker run server with OpenAI

To enable Azure OpenAI models, simply set your AZURE_API_KEY and AZURE_BASE_URL as an environment variables:

$# replace `~/.letta/.persist/pgdata` with wherever you want to store your agent data
>docker run \
> -v ~/.letta/.persist/pgdata:/var/lib/postgresql/data \
> -p 8283:8283 \
> -e AZURE_API_KEY="your_azure_api_key" \
> -e AZURE_BASE_URL="your_azure_base_url" \
> letta/letta:latest

Using letta run and letta server with Azure OpenAI

To chat with an agent, run:

$export AZURE_API_KEY="..."
>export AZURE_BASE_URL="..."
>letta run

To run the Letta server, run:

$export AZURE_API_KEY="..."
>export AZURE_BASE_URL="..."
>letta server

To select the model used by the server, use the dropdown in the ADE or specify a LLMConfig object in the Python SDK.

Built with