AWS Developer Tools Blog

Smithy Kotlin client code generation now generally available

Smithy Kotlin client code generation is now generally available. With Smithy Kotlin, you can keep client libraries in sync with evolving service APIs. By using client code generation, you can reduce repetitive work and instead, automatically create type-safe Kotlin clients from your service models. In this post, you will learn what Smithy Kotlin client generation is, how it works, and how you can use it.

Modern service development increasingly relies on strong contracts, automation, and consistency. Smithy provides a model-driven approach to defining services and enables code generation from those definitions, helping you to produce reliable clients from a single source of truth.

How it works

At a high level, Smithy Kotlin client code generation transforms Smithy service models into strongly typed Kotlin clients. This process bridges the gap between API design and implementation, producing code that handles serialization, protocol details, and request/response lifecycles automatically.

Model-driven development

At the core of the workflow is modeling services using Smithy. You can define services, operations, and data shapes in a declarative format that captures structure, constraints, and protocol bindings. These models specify the canonical definition of the API surface. For example:

namespace com.example

use aws.api#service
use smithy.protocols#rpcv2Cbor

@title("Coffee Shop Service")
@rpcv2Cbor
@service(sdkId: "CoffeeShop")
service CoffeeShop {
    version: "2024-08-23"
    operations: [
        GetMenu
    ]
}

@http(method: "GET", uri: "/menu")
@readonly
operation GetMenu {
    output := {
        items: CoffeeItems
    }
}

Smithy Kotlin consumes the models and produces Kotlin client code. The generated output includes typed operations, serializers, and deserializers, maintaining alignment between the model and client implementation.

For more information about writing Smithy models, see Smithy’s quick start documentation.

Clients

The generated clients support a range of features typical for service communication, including request/response handling, serialization, protocols, and error mapping. You only need to define them in the model and Smithy Kotlin writes the code for you. Because Smithy Kotlin targets Kotlin and generated clients run on the Java Virtual Machine (JVM), they integrate naturally with existing language tools. You can incorporate them into modern build systems, use concurrency features, and combine them with established libraries and frameworks already used in Kotlin. An example of a generated Kotlin client:

CoffeeShopClient {
    endpointProvider = CoffeeShopEndpointProvider {
        endpointUrl = Url.parse("http://localhost:8888")
    }
}.use { client ->
    val menu = client.getMenu()
}

For more information about how to start generating Kotlin clients from Smithy models, see the client generation guide.

What does general availability mean?

Smithy Kotlin has been in development and available in developer preview for a few years. This milestone reflects production readiness, stability, and broader confidence in adopting the generated clients as part of standard development workflows.

Conclusion

In this blog post, we covered what Smithy Kotlin client generation is, how it works, and how you can use it. To get started with Smithy Kotlin client code generation see the quick start example and documentation page. If you’d like to share feedback, ask a question, or discuss, you can reach us through GitHub issues and GitHub discussions.


About the author

TAGS: ,
Omar Perez

Omar Perez

Omar is a Software Development Engineer on the AWS SDK for Kotlin team at AWS. You can find him on GitHub as @0marperez.