Grouped request
Typed shortcut methods use a grouped request object. The grouping mirrors OpenAPI concepts while avoiding a custom runtime client model.
api.post('/uploads/{uploadId}', {
params: {
path: { uploadId: 'upload-1' },
query: { draft: true },
cookie: { session: 'type-only' },
},
headers: {
'x-upload-token': token,
},
formData: {
file,
tags: ['a', 'b'],
},
}, {
timeout: 15_000,
});Shape
params.path: values for route template placeholders.params.query: query parameters sent as kysearchParams.params.cookie: typed cookie parameters, currently type-only at runtime.headers: typed header parameters, merged with third-argument ky headers.json: JSON request body.formData: multipart request body.formUrlEncoded: URL-encoded request body.- third argument: normal ky options.
Runtime normalization
The wrapper turns the grouped object into ky options before dispatch:
- interpolate route templates from
params.path - move
params.querytosearchParams - merge grouped
headerswith explicit ky headers - choose one body source
- inject
context.openapi - delegate to
ky
Cookie parameters are present for type parity with OpenAPI, but they are not automatically serialized into a Cookie header.