// LANGUAGE SDK · JAVA
Java — OpenAI-compatible base-URL swap
Pattern A · full governance
Use the official openai-java client (or any OpenAI-compatible client) and point its base URL at the gateway. One builder call changes.
Pattern A — routed through the gateway. Your call travels through Agentics via a base-URL swap, so it is governed (routing, budgets, guardrails) inline and the Proof Ledger writes one verifiable receipt server-side. The receipt hash comes back in the
x-agentics-receipt response header.
Install
xml
<!-- Maven -->
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
</dependency>Swap the base URL
Point your OpenAI-compatible Java client at https://agentics.you/api/v1 with your AGENTICS_API_KEY as the key. That is the only change.
Java
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
OpenAIClient client = OpenAIOkHttpClient.builder()
.baseUrl("https://agentics.you/api/v1") // the only change
.apiKey("ak_…") // AGENTICS_API_KEY
.putHeader("x-agentics-user", "alice@acme.com")
.build();Run one call → see the receipt
No OpenAI-compatible library for your stack? A raw HTTP request works and returns the same header:
cURL
curl https://agentics.you/api/v1/chat/completions -i \
-H "Authorization: Bearer ak_…" \
-H "Content-Type: application/json" \
-H "x-agentics-user: alice@acme.com" \
-d '{"model":"@anthropic/claude-opus-4-8",
"messages":[{"role":"user","content":"hi"}]}'
# response header: x-agentics-receipt: <receipt_hash>