X-API-Key header. You can provide the key directly or through an environment variable.
API Key
Environment Variable (Recommended)
SetPHALA_CLOUD_API_KEY in your environment and the SDK picks it up automatically:
Explicit API Key
Pass the key directly when creating the client:api_key parameter takes precedence over the environment variable.
Environment Variables
| Variable | Description |
|---|---|
PHALA_CLOUD_API_KEY | API key for authentication |
PHALA_CLOUD_API_PREFIX | Base URL override (defaults to https://cloud-api.phala.com/api/v1) |
Cookie-Based Auth
For browser-like environments, the SDK supports cookie-based authentication instead of API keys. When enabled, theX-API-Key header is not sent, and authentication relies on cookies managed by the HTTP client.
Cookie-based auth is primarily for internal use. Most users should stick with API key authentication.
Custom Headers
You can add extra headers to every request. This is useful for tracing, debugging, or passing custom metadata.Verifying Authentication
Callget_current_user() to verify your credentials are valid:
Bring Your Own HTTP Client
If you need full control over transport settings (proxies, certificates, connection pooling), pass a pre-configuredhttpx client:
Related
- SDK Overview — installation and quick start
- Error Handling — handling
AuthError

