
Multifaceted AI tooling library delivering typed agent and tool contracts, streaming text and structured outputs, provider/gateway adapters, embeddings and media primitives, telemetry, mocks, and utilities.
Kotlin Multiplatform port of Vercel AI SDK v6 patterns and public feature areas.
This is a green-room Kotlin rewrite of the architectural contracts, not a TypeScript source translation and not an official Vercel package.
iosX64, iosArm64, and iosSimulatorArm64 published through Maven; the XCFramework is CI-built but not distributed.linuxX64 artifact for server-side Kotlin/Native and CLI consumers.Use the published beta from Maven Central:
dependencies {
implementation("ai.torad:torad-aisdk:0.3.0-beta01")
}For local development against a checkout, use a source dependency or publishToMavenLocal:
./gradlew publishToMavenLocalimport ai.torad.aisdk.LanguageModel
import ai.torad.aisdk.StepCountIs
import ai.torad.aisdk.Tool
import ai.torad.aisdk.ToolLoopAgent
import ai.torad.aisdk.ToolSet
import ai.torad.aisdk.providers.MockLanguageModelTextOnly
import kotlinx.coroutines.flow.first
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
@Serializable
data class EmptyInput(val unused: String = "")
val helloTool = Tool<EmptyInput, String, Unit>(
name = "hello",
description = "Return a greeting.",
inputSerializer = serializer(),
outputSerializer = serializer(),
) { _ -> "Hello from a tool." }
class HelloAgent(model: LanguageModel, tools: ToolSet<Unit>) :
ToolLoopAgent<Unit, String>(
model = model,
instructions = "Be brief.",
tools = tools,
stopWhen = StepCountIs(3),
)
suspend fun main() {
val agent = HelloAgent(
model = MockLanguageModelTextOnly("Welcome."),
tools = ToolSet(helloTool),
)
val result = agent.generate(prompt = "Say hi").first()
println(result.text)
}Send application prompts through Agent.generate / Agent.stream, or use
TextGenerator(model).generate(...), TextGenerator(model).stream(...), and
TextGenerator(model).streamResult(...) for direct text calls. Direct
LanguageModel.generate, LanguageModel.stream, and LanguageModel.streamResult
calls are still supported for provider authors and low-level integrations, but
they require @OptIn(LowLevelLanguageModelApi::class).
Agent and ToolLoopAgent.Tool() definitions, DynamicTool(), schemas, and ToolSet.TextGenerator(model).generate(...), TextGenerator(model).stream(...), and cold Flow<StreamEvent> streaming.Output.obj, Output.array, Output.choice, and Output.json.TextGenerator.streamResult(...) and StreamTextResult.Provider(...) routing.Gateway(), gateway, gateway metadata APIs, gateway errors, provider-executed gateway tool descriptors, and a Ktor-backed KtorGatewayTransport.OpenAICompatible(...).LiteRTLanguageModel, preserving SDK-owned generate, stream, reasoning-channel, and tool-loop routing.DefaultGeneratedFile, pruneMessages, experimental media aliases, and v6 public error types.Provider facades for the AI SDK v6 package ecosystem are folded into this root artifact for now. Future aisdk-provider-* artifacts can split publication boundaries without changing the common contracts.
Use JDK 21 to build the project. JVM and Android bytecode target JVM 17.
Run tools/bootstrap once in a fresh clone to activate the committed pre-commit gates.
./gradlew jvmTest
./gradlew check publishToMavenLocalAndroid publication requires an Android SDK with compile SDK 36 installed.
Apache-2.0. See LICENSE.
Kotlin Multiplatform port of Vercel AI SDK v6 patterns and public feature areas.
This is a green-room Kotlin rewrite of the architectural contracts, not a TypeScript source translation and not an official Vercel package.
iosX64, iosArm64, and iosSimulatorArm64 published through Maven; the XCFramework is CI-built but not distributed.linuxX64 artifact for server-side Kotlin/Native and CLI consumers.Use the published beta from Maven Central:
dependencies {
implementation("ai.torad:torad-aisdk:0.3.0-beta01")
}For local development against a checkout, use a source dependency or publishToMavenLocal:
./gradlew publishToMavenLocalimport ai.torad.aisdk.LanguageModel
import ai.torad.aisdk.StepCountIs
import ai.torad.aisdk.Tool
import ai.torad.aisdk.ToolLoopAgent
import ai.torad.aisdk.ToolSet
import ai.torad.aisdk.providers.MockLanguageModelTextOnly
import kotlinx.coroutines.flow.first
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
@Serializable
data class EmptyInput(val unused: String = "")
val helloTool = Tool<EmptyInput, String, Unit>(
name = "hello",
description = "Return a greeting.",
inputSerializer = serializer(),
outputSerializer = serializer(),
) { _ -> "Hello from a tool." }
class HelloAgent(model: LanguageModel, tools: ToolSet<Unit>) :
ToolLoopAgent<Unit, String>(
model = model,
instructions = "Be brief.",
tools = tools,
stopWhen = StepCountIs(3),
)
suspend fun main() {
val agent = HelloAgent(
model = MockLanguageModelTextOnly("Welcome."),
tools = ToolSet(helloTool),
)
val result = agent.generate(prompt = "Say hi").first()
println(result.text)
}Send application prompts through Agent.generate / Agent.stream, or use
TextGenerator(model).generate(...), TextGenerator(model).stream(...), and
TextGenerator(model).streamResult(...) for direct text calls. Direct
LanguageModel.generate, LanguageModel.stream, and LanguageModel.streamResult
calls are still supported for provider authors and low-level integrations, but
they require @OptIn(LowLevelLanguageModelApi::class).
Agent and ToolLoopAgent.Tool() definitions, DynamicTool(), schemas, and ToolSet.TextGenerator(model).generate(...), TextGenerator(model).stream(...), and cold Flow<StreamEvent> streaming.Output.obj, Output.array, Output.choice, and Output.json.TextGenerator.streamResult(...) and StreamTextResult.Provider(...) routing.Gateway(), gateway, gateway metadata APIs, gateway errors, provider-executed gateway tool descriptors, and a Ktor-backed KtorGatewayTransport.OpenAICompatible(...).LiteRTLanguageModel, preserving SDK-owned generate, stream, reasoning-channel, and tool-loop routing.DefaultGeneratedFile, pruneMessages, experimental media aliases, and v6 public error types.Provider facades for the AI SDK v6 package ecosystem are folded into this root artifact for now. Future aisdk-provider-* artifacts can split publication boundaries without changing the common contracts.
Use JDK 21 to build the project. JVM and Android bytecode target JVM 17.
Run tools/bootstrap once in a fresh clone to activate the committed pre-commit gates.
./gradlew jvmTest
./gradlew check publishToMavenLocalAndroid publication requires an Android SDK with compile SDK 36 installed.
Apache-2.0. See LICENSE.