Skip to main content

Aigentic helps you buildproduction-readyAI agents faster

A Kotlin DSL for typed AI agents that work with any model, and a platform that shows how often they're right

Intuitive Kotlin DSL

Describe the task, give the agent tools, and get a Kotlin data class back. Here's a complete agent and what happens when it runs.

  • agent<I, O>Typed input in, typed output out. Your data classes tell the model what to return.
  • addToolTools are plain Kotlin lambdas. The agent decides when to call them.
  • run.outcomeEvery run ends as Finished, Stuck or Fatal, so errors come back as values.
Provider
WeatherAgent.kt
@AigenticParameter
data class Weather(val celsius: Double, val summary: String)
@AigenticParameter
data class WeatherRequest(val city: String)
val weatherAgent = agent<String, Weather> {
geminiModel {
apiKey("YOUR_API_KEY")
modelIdentifier(GeminiModelIdentifier.Gemini3_5Flash)
}
task("Answer questions about the weather") {
addInstruction("Use getWeather for live data")
}
addTool("getWeather") { req: WeatherRequest ->
currentWeather(req.city)
}
}
suspend fun main() {
val run = weatherAgent.start("Weather in Amsterdam?")
when (val outcome = run.outcome) {
is Outcome.Finished -> println(outcome.response)
is Outcome.Stuck -> println(outcome.reason)
is Outcome.Fatal -> println(outcome.message)
}
}
Run
  1. Input

    “Weather in Amsterdam?”

  2. Model
    Gemini 3.5 Flashcalls getWeather
  3. Tool call
    getWeather(city = "Amsterdam")"14.0°C, light rain in Amsterdam"
  4. Outcome.Finished
    Weather(celsius = 14.0, summary = "Light rain")

run.tokenUsage()412 input, 38 output tokens

Pick a provider or let it cycle. Each step lights up the code that drives it, and only the model block changes.

Why Aigentic

Most agent libraries help you build the demo. Aigentic is built for what comes after: typed agents in your existing Kotlin code, any provider, and a platform that measures how often they're right. Here's how the two work together, from your first agent to its next version.

  1. Build
  2. Run
  3. Record
  4. Evaluate
  5. Improve

Each step has its own page in the docs. To follow one agent through all of them, read From prototype to production

Built by Flock, in the open

Aigentic is open source. Watch the talk for a walkthrough, or start from the Initializr to get a project with the right dependencies.

Know how often it's right

A demo shows your agent can get it right. The Aigentic Platform shows how often it does, field by field, and whether your last change made it better or worse.

Did the change make it better?

Every run your agent publishes is recorded with its config version. Confirm the right answers once, and each new version is scored on the same inputs: which fields got better, which got worse, and what a run costs.

Hosted by Flock in the EU, or set up in your own environment.

Request access opens an email to aigentic@flock.community. Tell us what your agent does and where you'd like the platform to run, and we'll help you connect your first agent.

Version 3 → version 4 of an invoice extractorExample · ground truth for 120 invoices with 412 invoice lines
FieldAccuracy of version 3 and version 4, on a scale from 80% to 100%Result
$.invoiceNumber91% to 98%7 pts better10 fixed · 1 regressed(109 of 120 correct before, 118 after)
$.total95% to 88%7 pts worse1 fixed · 9 regressed(114 of 120 correct before, 106 after)
$.dueDate98% to 98%2 fixed · 1 regressedcould be chance(117 of 120 correct before, 118 after)
$.lines[*].amount88% to 93%5 pts better24 fixed · 4 regressed(363 of 412 correct before, 383 after)

Cost per run: $0.0052 to $0.0055 (+6%)

What a real agent needs

Connect your APIs, read documents, chain agents and measure the results.

Tools from your API

Already have an API? Point openApiTools at its OpenAPI spec and every operation becomes a tool the agent can call. Add authentication headers once, for every call.

Read about integrations
OrderAgent.kt
val orderAgent = agent<String, Answer> {
geminiModel {
apiKey("YOUR_API_KEY")
modelIdentifier(GeminiModelIdentifier.Gemini3_5Flash)
}
task("Answer questions about customer orders") {
addInstruction("Look up the order before you answer")
}
openApiTools(File("orders-api.json").readText()) {
addHeader(Header.Bearer("YOUR_API_TOKEN"))
}
}
val run = orderAgent.start("Where is order 1042?")

Structured data from documents

Pass a PDF or an image to start() and get a typed data class back. Use @Description to tell the model what a field means. There's no JSON to parse and no tool to write. PDFs work with Gemini and VertexAI today.

Read about attachments
InvoiceExtractor.kt
@AigenticParameter
data class InvoiceLine(val description: String, val total: Double)
@AigenticParameter
data class Invoice(
val invoiceNumber: String,
val lines: List<InvoiceLine>,
@Description("Total amount before tax")
val totalAmount: Double,
val tax: Double,
)
val invoiceExtractor = agent<Unit, Invoice> {
geminiModel {
apiKey("YOUR_API_KEY")
modelIdentifier(GeminiModelIdentifier.Gemini3_5Flash)
}
task("Extract the invoice from the attached PDF") {
addInstruction("Include every line item")
}
}
val run = invoiceExtractor.start(Attachment.Base64.pdf(invoicePdf))
val invoice = (run.outcome as? Outcome.Finished)?.response

Workflows

Chain agents with thenProcess. The output type of one agent is the input type of the next, so the compiler catches a broken chain before you run it. Each agent can use its own model.

Explore workflows
DocumentWorkflow.kt
@AigenticParameter
data class Document(val content: String)
@AigenticParameter
data class Analysis(val topics: List<String>, val tone: String)
@AigenticParameter
data class Summary(val text: String)
val analyzer = agent<Document, Analysis> {
geminiModel {
apiKey("YOUR_API_KEY")
modelIdentifier(GeminiModelIdentifier.Gemini3_5Flash)
}
task("Find the key topics and the overall tone") {}
}
val summarizer = agent<Analysis, Summary> {
openAIModel {
apiKey("YOUR_API_KEY")
modelIdentifier(OpenAIModelIdentifier.GPT5_5)
}
task("Summarize the analysis in under 100 words") {}
}
val workflow = analyzer thenProcess summarizer
val run = workflow.start(Document("Raw document text..."))

Measure before you ship

Run the agent on real inputs you already know the answers to: your ground truth. The Aigentic Platform scores every output field, so you see how often the agent is right, and whether your next prompt or model makes it better or worse.

Follow an agent from prototype to production
GroundTruth.kt
val invoiceExtractor = agent<Unit, Invoice> {
// model and task as above
platform {
name("invoice-extractor")
secret("YOUR_PLATFORM_SECRET")
}
}
// Real invoices, with the answers you already know
groundTruth.forEach { (pdf, expected) ->
invoiceExtractor.start(
null,
Attachment.Base64.pdf(pdf),
expected = Expected("invoices-ground-truth", expected),
)
}
OrderAgent.kt
val orderAgent = agent<String, Answer> {
geminiModel {
apiKey("YOUR_API_KEY")
modelIdentifier(GeminiModelIdentifier.Gemini3_5Flash)
}
task("Answer questions about customer orders") {
addInstruction("Look up the order before you answer")
}
openApiTools(File("orders-api.json").readText()) {
addHeader(Header.Bearer("YOUR_API_TOKEN"))
}
}
val run = orderAgent.start("Where is order 1042?")