Use the official LLMWise Java SDK to call multiple AI models with one API key. CompletableFuture async, SSE streaming, Spring Boot integration, and built-in failover.
Credit-based pay-per-use with token-settled billing. No monthly subscription. Paid credits never expire.
Replace multiple AI subscriptions with one wallet that includes routing, failover, and optimization.
<!-- Maven --> <dependency> <groupId>ai.llmwise</groupId> <artifactId>llmwise-java</artifactId> <version>1.0.0</version> </dependency>
// Maven: ai.llmwise:llmwise-java:1.0.0
import ai.llmwise.LLMWiseClient;
import ai.llmwise.model.ChatRequest;
import ai.llmwise.model.ChatResponse;
import ai.llmwise.model.Message;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class QuickStart {
public static void main(String[] args) throws Exception {
var client = LLMWiseClient.builder()
.apiKey(System.getenv("LLMWISE_API_KEY"))
.build();
// Synchronous chat request
var request = ChatRequest.builder()
.model("auto")
.messages(List.of(
Message.user("Explain the Java memory model in simple terms.")
))
.maxTokens(512)
.build();
ChatResponse resp = client.chat(request);
System.out.println(resp.getContent());
// Async streaming with CompletableFuture
var streamReq = ChatRequest.builder()
.model("claude-sonnet-4.5")
.messages(List.of(
Message.user("Write a thread-safe singleton in Java.")
))
.stream(true)
.build();
client.chatStream(streamReq, event -> {
if (event.getDelta() != null) {
System.out.print(event.getDelta());
}
if (event.isDone()) {
System.out.printf("%nCredits charged: %d%n",
event.getCreditsCharged());
}
}).get(); // block until stream completes
}
}Everything you need to integrate LLMWise's multi-model API into your Java project.
Add the official LLMWise Java SDK to your pom.xml or build.gradle. Requires Java 17 or later.
<!-- Maven --> <dependency> <groupId>ai.llmwise</groupId> <artifactId>llmwise-java</artifactId> <version>1.0.0</version> </dependency> // Gradle implementation 'ai.llmwise:llmwise-java:1.0.0'
Store your API key as an environment variable or in application.properties for Spring Boot.
export LLMWISE_API_KEY="your_api_key_here" # Or in application.properties (Spring Boot): # llmwise.api-key=your_api_key_here
Build a client using the builder pattern. The client is thread-safe and should be created once and shared across your application.
var client = LLMWiseClient.builder()
.apiKey(System.getenv("LLMWISE_API_KEY"))
.build();Build a ChatRequest with a model ID and messages. The response includes content, token counts, latency, and credits metadata.
var request = ChatRequest.builder()
.model("gpt-5.2")
.messages(List.of(
Message.system("You are a senior Java architect."),
Message.user("When should I use records vs classes in Java?")
))
.maxTokens(512)
.build();
ChatResponse resp = client.chat(request);
System.out.println(resp.getContent());Use client.chatStream() with a callback to receive SSE events as they arrive. The method returns a CompletableFuture that completes when the stream ends.
var streamReq = ChatRequest.builder()
.model("deepseek-v3")
.messages(List.of(Message.user("Implement a LRU cache in Java.")))
.stream(true)
.build();
client.chatStream(streamReq, event -> {
if (event.getDelta() != null) {
System.out.print(event.getDelta());
}
}).get();Send the same prompt to multiple models and compare their outputs. Useful for A/B testing and evaluation pipelines.
var compareReq = CompareRequest.builder()
.models(List.of("gpt-5.2", "claude-sonnet-4.5", "gemini-3-flash"))
.messages(List.of(
Message.user("Explain the SOLID principles with Java examples.")
))
.build();
var compareResp = client.compare(compareReq);
for (var r : compareResp.getResponses()) {
System.out.printf("[%s]: %s%n%n", r.getModel(), r.getContent());
}Credit-based pay-per-use with token-settled billing. No monthly subscription. Paid credits never expire.
Replace multiple AI subscriptions with one wallet that includes routing, failover, and optimization.
Pricing changes, new model launches, and optimization tips. No spam.