Java

ai.hanzo:hanzo-java-cloud on Maven Central — the generated client for every /v1 capability, on OkHttp and Gson.

The Java client is generated from the API's own document onto OkHttp and Gson — the same HTTP and JSON stack the Kotlin client uses, so a JVM project that pulls both pulls one stack.

Install

ai.hanzo:hanzo-java-cloud is on Maven Central. Java 11 or newer.

// build.gradle.kts
repositories { mavenCentral() }
dependencies { implementation("ai.hanzo:hanzo-java-cloud:8.5.156") }
<dependency>
  <groupId>ai.hanzo</groupId>
  <artifactId>hanzo-java-cloud</artifactId>
  <version>8.5.156</version>
</dependency>

The shape

One ApiClient, one class per capability:

import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AiApi;
import ai.hanzo.cloud.model.AiModelList;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

AiModelList models = new AiApi(client).getModels();

setBearerToken also takes a Supplier<String>, which is what you want when the credential is an IAM access token that refreshes rather than a static sk-. See Authentication.

The class is the capability and the method is the operation, both derived from the document — the reference prints the pair per operation. Every call throws ApiException, which carries the status code and the response body.

Resources

Was this page useful?
Last updated Oct 12, 2026