Generating and Using an API Key in h2oGPTe
- Generative AI
- Enterprise h2oGPTe
This lesson walks through creating and using an API key to access Enterprise h2oGPTe programmatically. It covers the difference between a global API key, which has full access to all API calls, and a collection-specific key, which is restricted to one collection. It then shows how to generate a new key from the user menu, copy the secret value before it disappears, and use it in Python by importing the h2ogpte library and initializing a client with the API address and key. It closes with a reminder to store the key as an environment or global variable rather than hardcoding it in a shared notebook.
Key takeaways
- The difference between a global API key and a collection-specific key that restricts access to one collection
- How to generate a new API key from the user menu and copy the secret value before closing the dialog
- How to initialize the h2ogpte Python client with the API address and secret key
- Why storing an API key as an environment variable is safer than hardcoding it in a shared notebook
Start owning your AI