Skip to main content
The Go SDK requires Go 1.22 or later. Install it with:

Create a client

When the key argument is blank or only whitespace, New reads the NOZLE_SECRET_KEY environment variable. It panics with nozle: apiKey must not be empty (pass it or set NOZLE_SECRET_KEY) when both are blank, so check the environment before calling it. The default Engine and Core URLs are https://api.nozle.app/engine and https://api.nozle.app/core, both derived from the default host https://api.nozle.app. For a local deployment behind one proxy, set the host. WithBaseURL and WithEventsURL still set one service on its own and win over WithHost; if you set only one of them, the other service still uses the host, so set WithHost too:
All methods accept context.Context. Reuse one client and keep sk_ credentials on your server.

Authentication and transport

Plans accepts pk_ or sk_; all other operations require sk_. Wrong key types fail locally. A transport failure returns TransportError; a non-success HTTP response returns a structured APIError. See Errors and retries. By default the SDK makes one HTTP attempt per request. Set WithMaxRetries(n) for the SDK’s own retries (see Errors and retries), or pass an *http.Client whose transport retries. The SDK sets GetBody on each request, so the body can be replayed, and the Idempotency-Key header is sent again with every attempt:
WithTimeout still bounds all attempts together. Retry only after a network error, a 429, or a 5xx, and only operations that carry an idempotency key or a stable transaction ID.

API surface

Usage reads, invoices, alerts, webhooks, WrapHTTPClient and RecordUsage require v0.12.0. Ping returns a PingResult with OK and Engine.

Next steps

Choosing credit and provider methods

Use TrackUsage for atomic product-credit consumption, and the documented provider wrappers or manual capture for provider telemetry. A separate Can plus Track is not an atomic reservation; telemetry capture does not provide synchronous provider pricing. Consume and LLM were removed in v0.9.1. Their routes did not exist on the hosted service and always returned 404; use the methods above instead.