letta-ai / letta

Letta (formerly MemGPT) is a framework for creating LLM services with memory.
https://letta.com
Apache License 2.0
12.98k stars 1.42k forks source link

Docker usage, setting OpenAI Key in .env alone is not enough to get it to work. #1946

Open mcapodici opened 1 month ago

mcapodici commented 1 month ago

Describe the bug

(Following steps on https://docs.letta.com/server/docker#run-letta-server-with-docker)

  1. Clone Repo
  2. Create .env with OPENAI_API_KEY="sk-..."
  3. docker compose up
  4. visit http://localhost:8083/agents
  5. Click create agent
  6. Model list is empty

Errors in console:

letta_server-1  |   File "/app/.venv/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
letta_server-1  |     raise HTTPError(http_error_msg, response=self)
letta_server-1  | requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.openai.com/v1/models
  1. kill docker compose
  2. export OPENAI_API_KEY="sk-..."
  3. docker compose up
  4. visit http://localhost:8083/agents
  5. Click create agent
  6. Model list is populated

Please describe your setup

NOTE: I am sure the server is reading the .env file because as soon as you add the key, it removes it from the list of "missing keys" in the console log.

vojtapohunek commented 4 weeks ago

The API key in .env shouldn’t be in “ “. The key isn’t being loaded properly.

davidsells commented 4 weeks ago

The quotes will not cause the problem. I validated this by unsetting my shell variable ( unset OPENAI_API_KEY) and then used the .env file with a quoted key and it pulled in the models as normal.