Unified online infrastructure SDK for the AI-agent era — one key, one wallet, one bill across the 14 GA business modules.
| Group | Modules |
|---|---|
| AI & content | ai_runtime, ai_video, pdf, image_process, realtime |
| Messaging | email, sms |
| Integrity | captcha |
| Storage & billing | storage, billing |
| Ops | scheduling, observability, analytics, public_url |
auth/db/deployare not part of the current GA surface.
<dependency>
<groupId>io.infrailab</groupId>
<artifactId>infrai-sdk</artifactId>
<version>0.2.0</version>
</dependency>Requires Java 17+.
import io.infrailab.Client;
import io.infrailab.Infrai;
import com.fasterxml.jackson.databind.JsonNode;
Client client = Infrai.builder()
.apiKey(System.getenv("INFRAI_API_KEY"))
.build();
JsonNode resp = client.aiRuntime().chat()
.model("gpt-4o-mini")
.system("Be terse.")
.user("Hello, infrai!")
.send();
System.out.println(resp);- Java 17 records + pattern matching throughout.
- Byte-exact canonical JSON in
io.infrailab.canonical.CanonicalSerializer— interoperable with the Python / TS / Go / Rust SDKs. - 267 server-side error codes baked in (
ErrorCatalog.ERROR_CODES,ErrorCatalog.ERROR_REGISTRY). Per the "errors never deleted" axiom the generated catalog may still embed archived code strings; the active SSOT count is 267. - 98 enums generated from
infrai-spec/enums/*.yaml. Idempotency-Keyauto-UUID on every write request.- Streaming via
io.infrailab.streaming.SseParser+StreamChunk(works with any HTTP body source). - BYOK — attach a vendor key via
defaultByok()or per-request header. - Retry with exponential backoff + ±20 % jitter, gated on the registry.
- Thread-safe:
Clientholds an immutableClientConfigplus a singlejava.net.http.HttpClient(itself thread-safe). Zero mutable state.
See examples/:
BasicChat.java— one-shot LLM completionStreamChat.java— build a streaming request body + parse mocked SSEUploadImage.java—image_processpipelineSendEmail.java— transactional emailByokSetup.java— attach a BYOK credentialWebhookHandler.java— verify webhook signatures withCanonicalSerializerCanonicalDemo.java— canonical JSON + idempotency hashSpringBootApp/— a minimal Spring Boot REST gateway
The examples/SpringBootApp/README.md shows a 3-file skeleton: an
@Configuration bean for Client, an @RestController that proxies to two
modules, and an @ExceptionHandler mapping InfraiException to
Spring's ProblemDetail.
Client is safe to share across threads / async pipelines. Every per-call
state (idempotency key, BYOK override) lives on the immutable RequestSpec,
not on the client itself.
src/main/java/io/infrailab/enums/Enums.java and
src/main/java/io/infrailab/errors/ErrorCatalog.java are machine-generated
from infrai-spec/enums/*.yaml and infrai-spec/errors/registry.yaml.
Refresh with:
python3 infrai-spec/codegen/generate.py --langs javaMIT.