Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add API keys to memgpt server REST API #1014

Merged
merged 11 commits into from
Feb 16, 2024
Merged

feat: Add API keys to memgpt server REST API #1014

merged 11 commits into from
Feb 16, 2024

Conversation

cpacker
Copy link
Collaborator

@cpacker cpacker commented Feb 16, 2024

Please describe the purpose of this pull request.

  • Remove use of user_id in REST API requests in favor of API keys passed as bearer tokens
  • Instead, each user can have API keys (stored in the Tokens table)
    • Format: same as OAI, len 52 string with prefix sk-
  • When the client makes a REST API request, they are required to pass an API key as a bearer token, which the server then looks up and "decodes" to a user_id

How should the API keys be generated? TODO

  • Currently, when memgpt server is run a new API key for the system user is generated for easy testing
  • We still need to figure out a proper way to generate these API keys
  • Some options:
    • Password-protected REST API route (POST /create/key)
    • memgpt api-key generate command
    • ^Note how in both cases the "server admin" will be able to generate keys only
% memgpt server
new_key = sk-96905f3b39...0f7bce7d06
INFO:     Started server process [96408]
INFO:     Waiting for application startup.
Writing out openapi.json file
INFO:     Application startup complete.
INFO:     Uvicorn running on http://localhost:8283 (Press CTRL+C to quit)
^CINFO:     Shutting down

How to test

  • test_metadata_store.py was updated to test creation/deletion of API keys

Have you tested this PR?

  • Partially (have not tested all routes)

Copy link
Collaborator

@sarahwooders sarahwooders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@cpacker cpacker merged commit c816280 into main Feb 16, 2024
4 checks passed
@cpacker cpacker deleted the chatui-feats branch February 16, 2024 21:14
mattzh72 pushed a commit that referenced this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants