Authentication¶
Deeplake uses API tokens for authentication. All SDK and REST operations require a valid token.
Get your API token¶
- Sign in at deeplake.ai
- Go to Settings → API Tokens
- Click Create API Token
- Copy the token
Setup¶
Store credentials in environment variables:
The Python SDK reads DEEPLAKE_API_KEY and DEEPLAKE_WORKSPACE from the environment automatically. Once exported, you can create a client with no arguments:
You can also pass them explicitly — useful when managing multiple tokens or workspaces:
How the token works¶
The API token is a JWT. The SDK automatically extracts org_id from the token claims - you don't need to pass it explicitly.
Error handling¶
from deeplake import Client
from deeplake.managed import AuthError, TokenError
try:
client = Client()
except TokenError as e:
print(f"Token error: {e}")
except AuthError as e:
print(f"Auth error: {e}")
| Error | Cause | Fix |
|---|---|---|
Token required |
No token or DEEPLAKE_API_KEY env var set |
Export DEEPLAKE_API_KEY or pass token= |
Token does not contain org_id |
Missing claim | Ensure token is an API token from deeplake.ai |
Unauthorized: invalid or expired |
Token expired | Generate a new token |