Plugin
plugins: [pluginClient()]Officialv6.2.0kubb >=5.19.0node >=22.22
OpenAPI to TypeScript API client generator
@kubb/plugin-client
Generates typed operation functions from your OpenAPI spec that call a client module you own, so you decide the transport, auth, and error handling.
kubb add plugin-client
api-clienthttp-clientcodegenopenapi
- Downloads594.3K/ monthnpm, last 30 days
- GitHub stars12kubb-labs/plugins
- Unpacked size791.1kBv6.2.0 on npm
- Latest release1d agov6.2.0 · Nov 18, 2026
The Client plugin turns each OpenAPI operation into a typed function that calls your own client module, with no Fetch, axios, or Kubb runtime dependency.
- Each function takes grouped
path,query,headers,cookies, andbodyparameters, and passes your client the operation's auth requirements assecurity. - A call can pass its own
clientto replace the default. - The query plugins and
@kubb/plugin-mcpcan call the generated functions. - For a ready-made client, use
@kubb/plugin-fetch,@kubb/plugin-axios, or@kubb/plugin-kyinstead.
Installation
kubb add plugin-clientbun add -d @kubb/plugin-clientpnpm add -D @kubb/plugin-clientnpm install --save-dev @kubb/plugin-clientyarn add -D @kubb/plugin-clientkubb add installs the version the Kubb registry pins and adds pluginClient() to kubb.config.ts. It needs a kubb.config.ts, so run kubb init first in a new project.
Setup
- Set the required
importPathto your client module. - Add
@kubb/plugin-tsfor the operation types, or@kubb/plugin-zodwithinferred: true. - When you set
validator, add@kubb/plugin-zodand installzodv4. Generation fails without the plugin.
Options worth knowing
| Option | What it does |
|---|---|
importPath | Your client module, resolved from each generated file. |
returnType | 'plain' returns what your client returns. 'full' adds .unwrap(). 'data' resolves to the body. |
validator | Passes Zod schemas to your client. |
throwOnErrorDefault | The throwOnError value each call passes. Defaults to true. |
See Options for every option. Next, write your client.
Example
This config groups the functions by tag and points them at src/client.ts.
kubb.config.ts
import { defineConfig } from 'kubb/config'
import { adapterOas } from '@kubb/adapter-oas'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginClient } from '@kubb/plugin-client'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
adapter: adapterOas({ integerType: 'number' }),
plugins: [
pluginTs(),
pluginClient({
output: { path: 'clients', mode: 'directory', barrel: { type: 'named' } },
group: { type: 'tag' },
// resolved from each generated file: src/gen/clients/<tag>/ to src/client.ts
importPath: '../../../client',
}),
],
})Dependencies
No extension dependencies.
Optional dependencies
Extensions Client works with when they are in the config.
