notebooklm-py does not use an API key. Instead, it captures your Google session cookies from a real browser login and stores them in a local file calledDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/teng-lin/notebooklm-py/llms.txt
Use this file to discover all available pages before exploring further.
storage_state.json. Every subsequent CLI command or Python API call loads those cookies automatically and uses them to authenticate requests to NotebookLM. CSRF tokens and session IDs are fetched from the NotebookLM homepage on startup and refreshed automatically when authentication errors are detected.
Initial login
Runnotebooklm login once to capture your Google session. This is the only step that requires a browser.
Install the browser extra
The
notebooklm login command requires Playwright. Install it if you have not already:Run the login command
Where credentials are stored
notebooklm-py stores all files under~/.notebooklm/, organized by profile:
Storage state format
storage_state.json uses the Playwright storage state format. It contains a list of cookies that notebooklm-py extracts and sends with every API request.
SID, HSID, SSID, APISID, SAPISID, __Secure-1PSID, __Secure-3PSID
If any of these are missing, notebooklm-py raises a ValueError and asks you to re-run notebooklm login.
Environment variables
You can control where notebooklm-py looks for credentials and which profile it uses through environment variables.| Variable | Description | Default |
|---|---|---|
NOTEBOOKLM_HOME | Base directory for all files | ~/.notebooklm |
NOTEBOOKLM_PROFILE | Active profile name | default |
NOTEBOOKLM_AUTH_JSON | Inline authentication JSON (no file needed) | — |
NOTEBOOKLM_LOG_LEVEL | Logging level: DEBUG, INFO, WARNING, ERROR | WARNING |
Auth precedence
When the client resolves credentials, it checks sources in this order (highest priority first):- Explicit
--storageCLI flag orpathargument toNotebookLMClient.from_storage() NOTEBOOKLM_AUTH_JSONenvironment variable- Explicit
profileargument toNotebookLMClient.from_storage(profile="work") NOTEBOOKLM_PROFILEenvironment variable (resolves to~/.notebooklm/profiles/<name>/storage_state.json)- Active profile from
~/.notebooklm/active_profile ~/.notebooklm/profiles/default/storage_state.json~/.notebooklm/storage_state.json(legacy fallback)
Python API authentication
The Python client loads credentials usingNotebookLMClient.from_storage(). Call it as part of an async context manager to ensure HTTP connections are properly closed.
Using AuthTokens directly
For lower-level control, constructAuthTokens with specific cookie values:
AuthTokens also supports profiles:
The client automatically refreshes CSRF tokens when authentication errors are detected. When an RPC call fails with an auth error, the client fetches fresh tokens from the NotebookLM homepage and retries the request—you do not need to handle this manually. If the underlying session cookies have fully expired, you must re-run
notebooklm login.CI/CD authentication
In CI/CD environments you cannot runnotebooklm login interactively. Use the NOTEBOOKLM_AUTH_JSON environment variable to supply the JSON contents of storage_state.json as an inline secret—no files are written to disk.
Obtaining the secret value
- Run
notebooklm loginon your local machine. - Read the contents of
~/.notebooklm/profiles/default/storage_state.json. - Store the entire JSON string as a repository secret named
NOTEBOOKLM_AUTH_JSON.
GitHub Actions example
NOTEBOOKLM_AUTH_JSON from Python:
Multiple accounts and profiles
Use named profiles to manage multiple Google accounts under a single home directory.storage_state.json, context.json, and browser_profile/ under ~/.notebooklm/profiles/<name>/.
Re-authentication
When your session expires,notebooklm list returns an authentication error. Re-authenticate by running login again: