Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
export -- GPG_SIGNING_KEY_ID
printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD"
GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')"
./gradlew publish
./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD"
env:
SONATYPE_USERNAME: ${{ secrets.HANZO_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.HANZO_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 188
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hanzo-industries-inc%2FHanzo-AI-0a7d35addf32cac4b920117d914306cd24392e3b43a81508b72d2fe5e6a501aa.yml
openapi_spec_hash: 17b0da4e67edba72578ce5ce7f142ef7
config_hash: e1a69420db5ac10401f63a73d06e1810
config_hash: 830747463ff4d018b5633ce511e88558
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

The Hanzo Java SDK provides convenient access to the [Hanzo REST API](https://docs.hanzo.ai) from applications written in Java.

The Hanzo Java SDK is similar to the Hanzo Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions.

It is generated with [Stainless](https://www.stainless.com/).

<!-- x-release-please-start-version -->
Expand Down Expand Up @@ -350,6 +352,20 @@ HanzoClient client = HanzoOkHttpClient.builder()
.build();
```

### Environments

The SDK sends requests to the production by default. To send requests to a different environment, configure the client like so:

```java
import ai.hanzo.api.client.HanzoClient;
import ai.hanzo.api.client.okhttp.HanzoOkHttpClient;

HanzoClient client = HanzoOkHttpClient.builder()
.fromEnv()
.sandbox()
.build();
```

## Undocumented API functionality

The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.
Expand Down
13 changes: 0 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.jetbrains.dokka") version "2.0.0"
}

Expand All @@ -22,15 +21,3 @@ tasks.named("dokkaJavadocCollector").configure {
.filter { it.project.name != "hanzo-java" && it.name == "dokkaJavadocJar" }
.forEach { mustRunAfter(it) }
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))

username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}
3 changes: 3 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "1.9.20"
id("com.vanniktech.maven.publish") version "0.28.0"
}

repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
}
9 changes: 0 additions & 9 deletions buildSrc/src/main/kotlin/hanzo.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ repositories {
mavenCentral()
}

configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}

configure<SpotlessExtension> {
java {
importOrder()
Expand All @@ -38,10 +33,6 @@ tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}

tasks.named<Jar>("javadocJar") {
setZip64(true)
}

tasks.named<Jar>("jar") {
manifest {
attributes(mapOf(
Expand Down
100 changes: 47 additions & 53 deletions buildSrc/src/main/kotlin/hanzo.publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,61 +1,55 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost

plugins {
`maven-publish`
signing
id("com.vanniktech.maven.publish")
}

configure<PublishingExtension> {
publications {
register<MavenPublication>("maven") {
from(components["java"])

pom {
name.set("Hanzo API")
description.set("Call 100+ LLMs in the OpenAI format. [**Docs**](https://docs.hanzo.ai/)\n\n👉 [`Hanzo Console`](https://cloud.hanzo.ai). Create, Edit API Keys.\n\n💸 [`LLM Models`](https://models.hanzo.ai/).")
url.set("https://docs.hanzo.ai")

licenses {
license {
name.set("Apache-2.0")
}
}

developers {
developer {
name.set("Hanzo")
email.set("dev@hanzo.ai")
}
}

scm {
connection.set("scm:git:git://github.com/hanzoai/java-sdk.git")
developerConnection.set("scm:git:git://github.com/hanzoai/java-sdk.git")
url.set("https://github.com/hanzoai/java-sdk")
}

versionMapping {
allVariants {
fromResolutionResult()
}
}
}
}
}
repositories {
gradlePluginPortal()
mavenCentral()
}

signing {
val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null }
val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null }
val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null }
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(
signingKeyId,
signingKey,
signingPassword,
extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY")
extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID")
extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD")

configure<MavenPublishBaseExtension> {
signAllPublications()
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

coordinates(project.group.toString(), project.name, project.version.toString())
configure(
KotlinJvm(
javadocJar = JavadocJar.Dokka("dokkaJavadoc"),
sourcesJar = true,
)
sign(publishing.publications["maven"])
}
}
)

pom {
name.set("Hanzo API")
description.set("Call 100+ LLMs in the OpenAI format. [**Docs**](https://docs.hanzo.ai/)\n\n👉 [`Hanzo Console`](https://cloud.hanzo.ai). Create, Edit API Keys.\n\n💸 [`LLM Models`](https://models.hanzo.ai/).")
url.set("https://docs.hanzo.ai")

tasks.named("publish") {
dependsOn(":closeAndReleaseSonatypeStagingRepository")
licenses {
license {
name.set("Apache-2.0")
}
}

developers {
developer {
name.set("Hanzo")
email.set("dev@hanzo.ai")
}
}

scm {
connection.set("scm:git:git://github.com/hanzoai/java-sdk.git")
developerConnection.set("scm:git:git://github.com/hanzoai/java-sdk.git")
url.set("https://github.com/hanzoai/java-sdk")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class HanzoOkHttpClient private constructor() {
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null

fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) }

fun baseUrl(baseUrl: String) = apply {
clientOptions.baseUrl(baseUrl)
this.baseUrl = baseUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class HanzoOkHttpClientAsync private constructor() {
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null

fun sandbox() = apply { baseUrl(ClientOptions.SANDBOX_URL) }

fun baseUrl(baseUrl: String) = apply {
clientOptions.baseUrl(baseUrl)
this.baseUrl = baseUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ private constructor(

const val PRODUCTION_URL = "https://api.hanzo.ai"

const val SANDBOX_URL = "https://api.sandbox.hanzo.ai"

/**
* Returns a mutable builder for constructing an instance of [ClientOptions].
*
Expand Down