[ Docs ]
Java SDK
Planned IdonAI Java / JVM client — Maven coordinates, chat completions, and streaming notes.
Status
Maven coordinates com.idonai:sdk are reserved. Public install lands when API keys ship. Until then, treat the snippets below as the intended client shape and validate prompts in Quark or against the REST contract.
Install (planned)
Gradle:
implementation 'com.idonai:sdk:0.1.0'
Maven:
<dependency>
<groupId>com.idonai</groupId>
<artifactId>sdk</artifactId>
<version>0.1.0</version>
</dependency>
Versions will be published with the first public release. Pin a stable version in production builds.
Client init
import ai.idonai.IdonAI;
var client = IdonAI.builder()
.apiKey(System.getenv("IDONAI_API_KEY"))
.build();
Prefer environment or vault injection over hardcoded strings. See Authentication.
Chat completion
import ai.idonai.models.GenerateRequest;
var response = client.models().generate(
GenerateRequest.builder()
.model("origin")
.message("user", "Explain quantum entanglement.")
.maxTokens(1024)
.build()
);
System.out.println(response.content());
Use "nextgen" for higher-capability work. Model ids match Quark and the API reference.
Streaming
Streaming will expose a subscriber or iterator over completion chunks. Close the stream on cancellation, and surface partial output only when your product UX requires it.
// Sketch — exact helper names may refine at publish time
try (var stream = client.models().generateStream(
GenerateRequest.builder()
.model("origin")
.message("user", "Outline three steps.")
.stream(true)
.build()
)) {
stream.forEach(event -> System.out.print(event.content()));
}
Errors
Map HTTP status codes to your application errors. Retry 429 with Retry-After / exponential backoff; fail fast on 401 / 403 after logging a safe message (never the key). See Rate limits.