NewClient, or falls back to the PHALA_CLOUD_API_KEY environment variable. If neither is set, NewClient returns an error.
API Key via Option
The most explicit way to authenticate is passingWithAPIKey when creating the client.
API Key via Environment Variable
For production deployments, storing the key in an environment variable is the standard approach. The SDK readsPHALA_CLOUD_API_KEY automatically when no explicit key is provided.
If you pass
WithAPIKey explicitly, it always takes priority over the environment variable.Custom Base URL
You can override the API endpoint withWithBaseURL or the PHALA_CLOUD_API_PREFIX environment variable. The SDK defaults to https://cloud-api.phala.com/api/v1.
Custom Headers
UseWithHeader to attach additional headers to every request. This is useful for tracing, correlation IDs, or internal routing.
WithHeader adds one header. You can call it multiple times to set several headers.
API Versioning
The SDK sends an API version header with every request. The default is"2026-01-21". Override it if you need to target a different version.
Custom HTTP Client
For advanced scenarios like custom TLS configuration, proxies, or instrumented transports, pass your own*http.Client with WithHTTPClient.
User Agent
The SDK sends aUser-Agent header like phala-cloud-sdk-go/0.1.0 by default. Override it to identify your application in server logs.
Resolution Priority
The client resolves configuration in this order (first match wins):- Explicit option passed to
NewClient(e.g.,WithAPIKey,WithBaseURL) - Environment variable (
PHALA_CLOUD_API_KEY,PHALA_CLOUD_API_PREFIX) - Built-in default (base URL:
https://cloud-api.phala.com/api/v1)

