Hoi hoi!
I'm @nyaomaru, a frontend engineer who loves TypeScript, OSS, and getting lost in forests of generated code. 🌳
Six months ago, I compared four OpenAPI code generators in this article 👇
I chose Hey API.
I'm still using it in production, and I'm pretty happy with it.
But Kubb has changed a lot with v5! 🚀
Faster generation? Better clients? A new plugin architecture?
Oh no. Time to go back into the forest. 🌳🌳🌳
Let's see what has changed!
🎯 TL;DR
| Library | Why I would choose it |
|---|---|
| openapi-typescript | Types with minimal generated code |
| Hey API | Clean SDKs and comfortable DX |
| Orval | Flexible client, query, and mock generation |
| Kubb v5 | Extensible code generation with much-improved clients |
I'm keeping Hey API in my existing projects.
But for my next project? Kubb looks quite tempting. 👀
🕰️ Six months later
Here are the versions I tested (Kubb plugins have their own versions) 👇
| Library | May 2026 | November 2026 |
|---|---|---|
| openapi-typescript | 7.13.0 | 7.13.0 |
| Hey API | 0.96.1 | 0.99.0 |
| Orval | 8.8.1 | 8.48.0 |
| Kubb | 4.37.2 | 5.20.2 |
Kubb had a major architectural overhaul, while Hey API and Orval continued improving their existing ecosystems.
Let's see what that actually means for us.
🏎️ How fast are they now?
For this investigation, I generated a synthetic OpenAPI specification using drf-spectacular.
- 1,200 operations
- 484 component schemas
- 51,878 lines
- Approximately 1.28 MB
I reran the previous versions using this new specification.
All measurements below are from the same Ryzen 9 7900 machine running WSL2 and Node.js 26. Each result is the median of eight measured executions after one warm-up.
Types only
Generating 484 shared component schemas
| Library | Time | Peak RSS (max) |
|---|---|---|
| openapi-typescript | 438 ms | 191 MiB |
| Hey API | 527 ms | 240 MiB |
| Orval | 866 ms | 145 MiB |
| Kubb | 337 ms | 156 MiB |
Wait, Kubb?! 😳
Types + Fetch SDK
I benchmarked both old and current versions on the same synthetic schema and machine.
| Library | Old version | Current version | Reduction |
|---|---|---|---|
| Hey API | 7,406 ms | 1,329 ms | 82.1% |
| Orval | 3,457 ms | 1,723 ms | 50.2% |
| Kubb | 6,236 ms | 1,155 ms | 81.5% |
That's a massive improvement for both Hey API and Kubb.
openapi-typescript took 751 ms to generate the full operation types, but it uses a generic runtime client rather than generating an SDK for every endpoint, so I've kept it separate.
Generation scopes and output structures still differ, and these aren't measurements against the original production API.
Also, generation isn't everything. A single TypeScript compilation took approximately 2.44 seconds for Hey API and 3.80 seconds for Kubb.
Fast generation doesn't necessarily mean faster everything.
Still, impressive work! 🚀
🌳 How big is the forest?
Here's the generated output for the full specification.
| Library | Files | Source size |
|---|---|---|
| openapi-typescript | 1 | 1.45 MB |
| Hey API | 16 | 1.78 MB |
| Orval | 1,926 | 2.18 MB |
| Kubb | 2,897 | 3.13 MB |
A house, a small town, a forest, and a very ambitious forest.
openapi-typescript/ types.ts hey-api/ types.gen.ts sdk.gen.ts client.gen.ts client/ core/ orval/ api.ts schemas/ kubb/ clients/ types/ .kubb/ I still prefer Hey API's relatively compact structure.
But Kubb's distributed files aren't necessarily a bad thing. Smaller individual files can make generated code easier to navigate and review.
These are generated source sizes, by the way—not application bundle sizes.
🧑💻 Let's actually call an API
Suppose we have three endpoints 👇
GET /users GET /users/{id} POST /users openapi-typescript
Using its official companion, openapi-fetch
const client = createClient<paths>({ baseUrl: BASE_URL, }); client.GET("/users", { params: { query: { limit: 2 } }, }); client.GET("/users/{id}", { params: { path: { id: "1" } }, }); client.POST("/users", { body: { id: "1", name: "Ada" }, }); No generated function for every endpoint.
Just typed URLs, HTTP methods, and a generic client.
Small. Simple. Useful. 👍
Hey API
getUsers({ query: { limit: 2 }, }); getUser({ path: { id: "1" }, }); createUser({ body: { id: "1", name: "Ada" }, }); This is one of the main reasons I chose Hey API.
I don't need to remember the argument order of 1,200 functions.
Just query, path, and body.
My little brain is happy. 😸🧠
Orval
With useNamedParameters: true
getUsers({ limit: 2 }); getUser({ id: "1" }); createUser({ id: "1", name: "Ada", }); Request options can be passed separately, and custom mutators allow you to centralize transport logic. 👍
Kubb v5
getUsers({ query: { limit: 2 }, }); getUser({ path: { id: "1" }, }); createUser({ body: { id: "1", name: "Ada" }, }); This looks familiar. 👀
Kubb now gives me the consistent request structure I like in Hey API.
One of my previous concerns is gone. 😸🚀
⚠️ What happens when things explode?
Let's say our API returns
-
200:User[] -
400:{ message: string } -
409:{ conflict: string }
I like result-based error handling, but sometimes I also want exceptions.
More importantly, I want TypeScript to know which error I'm dealing with.
openapi-fetch
const result = await list(); if ( result.response.status === 400 && result.error !== undefined && "message" in result.error ) { console.log(result.error.message); } Hey API
const result = await list(); if ( result.response?.status === 400 && result.error !== undefined && "message" in result.error ) { console.log(result.error.message); } You get typed error responses, but checking the nested HTTP status alone doesn't narrow the error body.
Orval
const result = await list(); if (result.status === 400) { console.log(result.data.message); } if (result.status === 409) { console.log(result.data.conflict); } Nice!
The top-level status acts as a discriminant. 😸
Kubb v5
const result = await getUsers({ throwOnError: false, }); if (result.status === 400) { if ("message" in result.error) { console.log(result.error.message); } } Kubb also provides status-based narrowing. The additional guard handles the possible empty error body. 👍
To throw or not to throw
-
Hey API
await getUsers({ throwOnError: true, }); -
Kubb
await getUsers({ throwOnError: true, }); Hey API defaults to result-style HTTP errors in the tested SDK; Kubb defaults to throwing. Both let me choose.
Or, with Kubb
const users = await getUsers({ throwOnError: false, }).unwrap(); I particularly like this little .unwrap().
Give me the data or reject. Thank you very much!
There are still differences in what each client considers an error.
| Behavior | Hey API | Kubb |
|---|---|---|
| Result-style HTTP errors | ✅ | ✅ |
| Configurable throwing | ✅ | ✅ |
| Status-discriminated result | — | ✅ |
.unwrap() | — | ✅ |
| Network failure in nonthrowing mode | Returned error in tests | Rejected in tests |
Nonthrowing HTTP mode doesn't mean nothing can throw!
🪝 What about TanStack Query?
All four have a way to integrate with TanStack Query.
// openapi-react-query $api.queryOptions("get", "/users"); // Hey API getUsersOptions(); // Orval getGetUsersQueryOptions(); // Kubb getUsersQueryOptions(); One interesting difference appeared in the runtime tests:
| Library | HTTP 400 in tested query configuration |
|---|---|
| openapi-react-query | Rejects |
| Hey API | Rejects |
| Orval | Resolves by default |
| Kubb | Rejects by default |
TanStack Query needs a rejected promise to recognize a failed request.
For Orval's tested Fetch configuration, enabling override.fetch.forceSuccessResponse: true changes that behavior.
Not a deal-breaker. Just something worth configuring before your query happily reports that everything is fine while your API is on fire. 🔥
🤯 The enum problem, again
Remember those little enums that caused so much trouble last time?
They're back.
Consider these schema fragments:
BlankEnum: type: string enum: [""] NullEnum: enum: [null] Here's what happened:
| Case | openapi-typescript | Hey API | Orval | Kubb |
|---|---|---|---|---|
| Empty-string enum (3.0 fixture) | ✅ | ✅ | ✅ | ✅ |
| Null-only enum (3.1 fixture) | ✅ | ❌ | ✅ | ✅ |
Kubb's previous blank-enum issue is fixed! 🎉
Its v4 already handled the tested null-only case correctly, so that isn't a new v5 improvement.
Interestingly, Hey API still has a problem with the null-only enum.
type NullEnum = never; Oops.
Adding type: 'null' fixes the TypeScript type, but the generated Zod validator can still accept unrelated values.
The verified workaround for this OpenAPI 3.1 case is:
NullEnum: type: "null" Now we get the correct type and validator:
type NullEnum = null; const zNullEnum = z.null(); There's also an existing upstream issue.
It's a specific edge case, not a general problem with nullable properties.
But this is why I test generated types instead of simply trusting them.
🛡️ Type safety at runtime
TypeScript is wonderful. Unfortunately, my backend doesn't care. 😹
All four default clients accepted invalid response data in my tests. With runtime validation, all four rejected it.
| Library | Validation |
|---|---|
| openapi-typescript | Manual |
| Hey API | Generated Zod |
| Orval | Generated Zod |
| Kubb | Generated Zod |
Encoding and decoding
Kubb has another interesting feature: directional transformations.
const result = await postTimestamp({ body: { at: new Date() }, }); const date: Date = result.data.at; With inferred: 'codec' and a custom datetime printer, Kubb generated the ISO string ↔ Date transformations and integrated them into the client.
These are directional Zod transforms, not native bidirectional z.codec objects.
Less glue code. Happy cats. 🐈
Server-Sent Events
Both Hey API and Kubb handled typed SSE in my tests.
// Hey API const { stream } = await heyEvents(); for await (const event of stream) { console.log(event.value); } // Kubb const { stream } = await kubbEvents(); for await (const event of stream) { console.log(event.data.value); } Different wrappers, same typed streaming goodness.
🧰 The ecosystem
| Feature | openapi-typescript | Hey API | Orval | Kubb |
|---|---|---|---|---|
| Fetch | ✅ | ✅ | ✅ | ✅ |
| Axios | — | ✅ | ✅ | ✅ |
| React Query | ✅ | ✅ | ✅ | ✅ |
| SWR | — | ✅ | ✅ | ✅ |
| Zod generation | — | ✅ | ✅ | ✅ |
| Faker / MSW | — | ✅ | ✅ | ✅ |
| Native custom plugins | — | ✅ | — | ✅ |
These are official integrations and companions, not necessarily built-in features. Other extension mechanisms exist.
One correction from my previous comparison: Hey API also supports Faker, MSW, and SWR. I verified Faker/MSW behavior and SWR generation.
The ecosystems are getting crowded. In a good way! 😸
🏗️ Kubb v5: More than an OpenAPI generator?
This is where Kubb gets interesting.
OpenAPI ↓ Unified AST ↓ Plugins + Resolvers + Macros ↓ Generated code Kubb v5 lets plugins share a normalized AST instead of independently parsing the specification.
But what does that actually give us?
Resolvers
Let's say my project requires an Api prefix and .model.ts filenames.
import { pluginTs, resolverTs } from '@kubb/plugin-ts'; pluginTs({ resolver: { name(name) { return `Api${resolverTs.name(name)}`; }, file: { baseName({ name, extname }) { return `${name}.model${extname}`; }, }, }, }); The result?
- GetUsersOptions + ApiGetUsersOptions Even better, the Fetch plugin automatically imports the renamed type from the renamed file.
No regex magic. No broken imports. Strict TypeScript compilation passed.
Macros
I also tested removing descriptions from TypeScript output while preserving them in Zod output.
It worked. Each plugin can transform its own AST without affecting the others.
Kubb Kit and Registry
Kubb Kit lets developers build custom generators using the same infrastructure as official plugins.
And the Kubb Registry lets the community distribute extensions.
Hey API also supports custom plugins, so extensibility isn't unique to Kubb.
But the combination of shared AST, resolvers, macros, and Kit makes Kubb particularly interesting for building a company-wide generation platform.
🤖 AI can grow a forest overnight
AI makes generating code faster. Keeping it consistent? Not so much.
Imagine five AI agents building five features, each inventing different API wrappers and error handling.
Congratulations! Five different forests. 🌳🌴🌲🎋🌵
Why keep telling AI the same rules when we can encode them into a shared generator?
Let AI help build the plugins. Let deterministic codegen enforce the conventions.
One shared plugin can serve ten projects instead of ten AI agents reinventing the same thing.
Maybe the best use of AI isn't generating more code. It's building better tools that generate code for us.
And that's exactly why Kubb's architecture caught my attention.
🌱 Maintaining the forest
I also tested how generated code changes when the API evolves.
| Library | Changed files | Added / removed lines |
|---|---|---|
| openapi-typescript | 1 | +2 / −2 |
| Hey API | 3 | +9 / −9 |
| Orval | 3 | +14 / −14 |
| Kubb | 6 | +59 / −59 |
These results are from renaming one operationId.
All four generated identical output with unchanged input, and breaking schema changes were caught by application type checks.
More files aren't necessarily worse. Just keep your forest under control! 🌳
🤝 Kubb Studio
Kubb also introduced Kubb Studio, a separate collaboration service.
It offers UI-based plugin configuration, generated-file comments, and npm snapshots through GitHub Actions.
That could help frontend teams work against upcoming backend contracts before release.
I haven't tested it hands-on yet, but it's an interesting direction!
📓 Side by side
| openapi-typescript | Hey API | Orval | Kubb v5 | |
|---|---|---|---|---|
| Approach | Types | SDK | Configurable generators | Extensible generators |
| Request style | Typed URL | Named options | Configurable | Named options |
| Output | Minimal | Compact | Configurable | Distributed |
| Errors | Result | Result / Throw | Status / Throw | Result / Throw / Unwrap |
| Validation | Manual | Generated | Generated | Generated |
| Extensions | Scripts / AST | Plugins | Transformers / hooks | Kit / Resolvers / Macros |
🚀 Back out of the forest
Six months ago, I chose Hey API. And I'm keeping it.
But Kubb v5 surprised me.
It's faster, its clients have improved, and its architecture offers something beyond a ready-made SDK.
In the AI era, I think shared development foundations matter more than ever.
For my next large frontend project, I'd love to give Kubb a try.
Six months ago, I wanted a smaller forest.
Now, I want to design how it grows.
Before AI plants another million trees. 🌳🤖
Thanks for reading! 🙌💚





