Requirements
- Java 17 or newer
Installation
Set up the client
Create an API key in Settings, then construct the client once and reuse it (it is thread-safe):https://promptjuggler.com. Point the SDK at another
host (e.g. for testing) with the two-argument constructor: new PromptJuggler(apiKey, baseUrl).
Per-endpoint usage
Every endpoint in the API reference includes a Java SDK code sample showing the exact call — that’s the place to look for how to invoke each operation and what it returns. A typical flow:RunOptions builder passed as the last argument:
Methods return typed model objects with validated fields. They are read-only data — read
the fields, don’t write them back.
Error handling
When the API responds with an error status, the SDK throws anApiError carrying the HTTP
status code and the server’s message. When the request never reaches the API (DNS failure,
timeout, offline), it throws a NetworkError. Both extend PromptJugglerException, which is
checked — every call that reaches the API declares throws PromptJugglerException, so the
compiler makes you handle (or propagate) the failure. Catch the base to handle the whole surface
at once, or catch ApiError first when you need the status code:
Webhooks
PromptJuggler signs every webhook with thePromptJuggler-Signature header. Verify it against
the raw request body, before any JSON parsing:
Webhooks.verifySignature recomputes the HMAC-SHA256 of {timestamp}.{raw_body}, compares it
in constant time, and rejects deliveries whose timestamp falls outside a tolerance window
(default 300s) to prevent replay. Widen or narrow it with the five-argument overload.