# Kotlin

URL: https://docs.hanzo.ai/docs/sdks/kotlin

> ai.hanzo:hanzo-kotlin-cloud — the generated client for every /v1 capability, on OkHttp and Gson. Built from source until it lands on Maven Central.

Generated from the API's own document onto OkHttp and Gson — the same HTTP and
JSON stack the [Java](https://docs.hanzo.ai/docs/sdks/java) client uses, so a JVM project pulling
both pulls one stack.

> **Not on Maven Central yet**
>
> `ai.hanzo:hanzo-kotlin-cloud` resolves from no repository. Build it into your
> local Maven repository, or use the [Java](https://docs.hanzo.ai/docs/sdks/java) client, which is on
> Maven Central, from Kotlin.

## Install

Building wants a JDK 21 toolchain; the jar is Java 8 bytecode. `-PpublishLocal`
skips the GPG signing a Central upload needs.

```sh
git clone https://github.com/hanzo-kotlin/sdk hanzo-kotlin-sdk
cd hanzo-kotlin-sdk
./gradlew -PpublishLocal :hanzo-kotlin-cloud:publishToMavenLocal
```

```kotlin
// build.gradle.kts
repositories { mavenLocal() }
dependencies { implementation("ai.hanzo:hanzo-kotlin-cloud:8.5.156") }
```

## The shape

`Hanzo()` reads the endpoint and the credential from the environment
(`HANZO_API_KEY`, `HANZO_BASE_URL`, default `https://api.hanzo.ai`), and
`api(::AccountApi)` builds that generated class, or any other, against them:

```kotlin
import ai.hanzo.Hanzo
import ai.hanzo.cloud.api.AccountApi

fun main() {
    val keys = Hanzo().api(::AccountApi).getAccountKeys().propertyKeys.orEmpty()
    println("${keys.size} keys")
}
```

The classes follow the document's tags under `ai.hanzo.cloud.api`, with their
request and response types under `ai.hanzo.cloud.model`, so the
[reference](https://docs.hanzo.ai/docs/openapi) is the index. Calls block; wrap them in your own
dispatcher if you need them off a thread.

## Resources

- Source — [hanzo-kotlin/sdk](https://github.com/hanzo-kotlin/sdk)
- [Every `/v1` operation →](https://docs.hanzo.ai/docs/openapi)
