[{"data":1,"prerenderedAt":692},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":691,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-ky\u002Findex.md",{},"Ky",{"type":8,"value":9,"toc":682},"minimark",[10,19,63,68,168,197,201,238,242,330,342,346,654],[11,12,13,14,18],"p",{},"Generates one typed async function per OpenAPI operation that sends the request with ",[15,16,6],"a",{"href":17},"https:\u002F\u002Fgithub.com\u002Fsindresorhus\u002Fky"," and returns a result keyed by status code.",[11,20,21,22,26,27,26,30,26,33,36,37,40,41,26,44,36,47,50,51,54,55,58,59,62],{},"Each function takes grouped ",[23,24,25],"code",{},"path",", ",[23,28,29],{},"query",[23,31,32],{},"headers",[23,34,35],{},"cookies",", and ",[23,38,39],{},"body"," options, plus Ky options such as ",[23,42,43],{},"retry",[23,45,46],{},"timeout",[23,48,49],{},"hooks",". The query plugins and ",[23,52,53],{},"@kubb\u002Fplugin-mcp"," call these functions. The runtime is copied into ",[23,56,57],{},".kubb\u002F",", so the generated code imports only ",[23,60,61],{},"ky",".",[64,65,67],"h2",{"id":66},"installation","Installation",[69,70,72,95,115,133,151],"code-group",{"sync":71},"install",[73,74,79],"pre",{"language":75,"filename":76,"code":77,"class":78},"shell","kubb","kubb add plugin-ky","highlights",[23,80,82],{"class":81},"language-shell",[83,84,87,91],"span",{"class":85,"style":86},"line","display: inline",[83,88,90],{"style":89},"color:#6f42c1;--hls-dark:#b392f0","kubb ",[83,92,94],{"style":93},"color:#24292e;--hls-dark:#e1e4e8","add plugin-ky",[73,96,99],{"language":75,"filename":97,"code":98,"class":78},"bun","bun add -d @kubb\u002Fplugin-ky",[23,100,101],{"class":81},[83,102,103,106,109,112],{"class":85,"style":86},[83,104,105],{"style":89},"bun ",[83,107,108],{"style":93},"add -d ",[83,110,111],{"style":93},"@",[83,113,114],{"style":93},"kubb\u002Fplugin-ky",[73,116,119],{"language":75,"filename":117,"code":118,"class":78},"pnpm","pnpm add -D @kubb\u002Fplugin-ky",[23,120,121],{"class":81},[83,122,123,126,129,131],{"class":85,"style":86},[83,124,125],{"style":89},"pnpm ",[83,127,128],{"style":93},"add -D ",[83,130,111],{"style":93},[83,132,114],{"style":93},[73,134,137],{"language":75,"filename":135,"code":136,"class":78},"npm","npm install --save-dev @kubb\u002Fplugin-ky",[23,138,139],{"class":81},[83,140,141,144,147,149],{"class":85,"style":86},[83,142,143],{"style":89},"npm ",[83,145,146],{"style":93},"install --save-dev ",[83,148,111],{"style":93},[83,150,114],{"style":93},[73,152,155],{"language":75,"filename":153,"code":154,"class":78},"yarn","yarn add -D @kubb\u002Fplugin-ky",[23,156,157],{"class":81},[83,158,159,162,164,166],{"class":85,"style":86},[83,160,161],{"style":89},"yarn ",[83,163,128],{"style":93},[83,165,111],{"style":93},[83,167,114],{"style":93},[11,169,170,173,174,178,179,182,183,186,187,189,190,196],{},[23,171,172],{},"kubb add"," installs the version the ",[15,175,177],{"href":176},"\u002Fregistry","Kubb registry"," pins and adds ",[23,180,181],{},"pluginKy()"," to ",[23,184,185],{},"kubb.config.ts",". It needs a ",[23,188,185],{},", so run ",[15,191,193],{"href":192},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit",[23,194,195],{},"kubb init"," first in a new project.",[64,198,200],{"id":199},"setup","Setup",[202,203,204,219,232],"ul",{},[205,206,207,208,211,212,215,216,62],"li",{},"Add ",[23,209,210],{},"@kubb\u002Fplugin-ts"," for the operation types, or ",[23,213,214],{},"@kubb\u002Fplugin-zod"," with ",[23,217,218],{},"inferred: true",[205,220,207,221,223,224,227,228,231],{},[23,222,214],{}," and install ",[23,225,226],{},"zod"," v4 when you set ",[23,229,230],{},"validator",". Generation fails without the plugin.",[205,233,234,235,237],{},"Install ",[23,236,61],{}," 2.0 or a later 2.x release in the app that runs the generated code.",[64,239,241],{"id":240},"options-worth-knowing","Options worth knowing",[243,244,245,258],"table",{},[246,247,248],"thead",{},[249,250,251,255],"tr",{},[252,253,254],"th",{},"Option",[252,256,257],{},"Set it to",[259,260,261,276,292,305,318],"tbody",{},[249,262,263,269],{},[264,265,266],"td",{},[23,267,268],{},"baseURL",[264,270,271,272,275],{},"The starting host. The spec's top-level ",[23,273,274],{},"servers"," URL is not used.",[249,277,278,282],{},[264,279,280],{},[23,281,230],{},[264,283,284,287,288,291],{},[23,285,286],{},"'zod'"," to check response bodies, or ",[23,289,290],{},"{ request, params, response }"," per part.",[249,293,294,299],{},[264,295,296],{},[23,297,298],{},"throwOnErrorDefault",[264,300,301,304],{},[23,302,303],{},"false"," to return non-2xx responses as values.",[249,306,307,312],{},[264,308,309],{},[23,310,311],{},"returnType",[264,313,314,317],{},[23,315,316],{},"'data'"," to resolve to the success body instead of the full result.",[249,319,320,325],{},[264,321,322],{},[23,323,324],{},"sdk",[264,326,327,328,62],{},"Classes instead of functions. Leave it unset for the query plugins and ",[23,329,53],{},[11,331,332,333,337,338,62],{},"Next, ",[15,334,336],{"href":335},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Fguides\u002Fcalling-operations","call operations",", or see every option and its default in ",[15,339,341],{"href":340},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky\u002Foptions","Options",[64,343,345],{"id":344},"example","Example",[69,347,348,552,616],{},[73,349,352],{"language":350,"filename":185,"code":351,"class":78},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { adapterOas } from '@kubb\u002Fadapter-oas'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { pluginKy } from '@kubb\u002Fplugin-ky'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  adapter: adapterOas({ integerType: 'number' }),\n  plugins: [pluginTs(), pluginKy({ baseURL: 'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' })],\n})",[23,353,355,378,379,378,395,378,411,378,427,378,429,378,443,378,460,378,483,378,511,378,548],{"class":354},"language-typescript",[83,356,357,361,365,368,371,374],{"class":85,"style":86},[83,358,360],{"style":359},"color:#d73a49;--hls-dark:#f97583","import ",[83,362,364],{"style":363},"color:#005cc5;--hls-dark:#79b8ff","{ ",[83,366,367],{"style":93},"defineConfig ",[83,369,370],{"style":363},"} ",[83,372,373],{"style":359},"from ",[83,375,377],{"style":376},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[83,380,381,383,385,388,390,392],{"class":85,"style":86},[83,382,360],{"style":359},[83,384,364],{"style":363},[83,386,387],{"style":93},"adapterOas ",[83,389,370],{"style":363},[83,391,373],{"style":359},[83,393,394],{"style":376},"'@kubb\u002Fadapter-oas'",[83,396,397,399,401,404,406,408],{"class":85,"style":86},[83,398,360],{"style":359},[83,400,364],{"style":363},[83,402,403],{"style":93},"pluginTs ",[83,405,370],{"style":363},[83,407,373],{"style":359},[83,409,410],{"style":376},"'@kubb\u002Fplugin-ts'",[83,412,413,415,417,420,422,424],{"class":85,"style":86},[83,414,360],{"style":359},[83,416,364],{"style":363},[83,418,419],{"style":93},"pluginKy ",[83,421,370],{"style":363},[83,423,373],{"style":359},[83,425,426],{"style":376},"'@kubb\u002Fplugin-ky'",[83,428],{"class":85,"style":86},[83,430,431,434,437,440],{"class":85,"style":86},[83,432,433],{"style":359},"export ",[83,435,436],{"style":359},"default ",[83,438,439],{"style":89},"defineConfig",[83,441,442],{"style":363},"({",[83,444,445,448,451,454,457],{"class":85,"style":86},[83,446,447],{"style":363},"  ",[83,449,450],{"style":363},"input",[83,452,453],{"style":359},": ",[83,455,456],{"style":376},"'.\u002FpetStore.yaml'",[83,458,459],{"style":359},",",[83,461,462,464,467,469,471,473,475,478,481],{"class":85,"style":86},[83,463,447],{"style":359},[83,465,466],{"style":363},"output",[83,468,453],{"style":359},[83,470,364],{"style":363},[83,472,25],{"style":363},[83,474,453],{"style":359},[83,476,477],{"style":376},"'.\u002Fsrc\u002Fgen' ",[83,479,480],{"style":363},"}",[83,482,459],{"style":359},[83,484,485,487,490,492,495,498,501,503,506,509],{"class":85,"style":86},[83,486,447],{"style":359},[83,488,489],{"style":363},"adapter",[83,491,453],{"style":359},[83,493,494],{"style":89},"adapterOas",[83,496,497],{"style":363},"({ ",[83,499,500],{"style":363},"integerType",[83,502,453],{"style":359},[83,504,505],{"style":376},"'number' ",[83,507,508],{"style":363},"})",[83,510,459],{"style":359},[83,512,513,515,518,520,523,526,529,531,534,536,538,540,543,546],{"class":85,"style":86},[83,514,447],{"style":359},[83,516,517],{"style":363},"plugins",[83,519,453],{"style":359},[83,521,522],{"style":363},"[",[83,524,525],{"style":89},"pluginTs",[83,527,528],{"style":363},"()",[83,530,26],{"style":359},[83,532,533],{"style":89},"pluginKy",[83,535,497],{"style":363},[83,537,268],{"style":363},[83,539,453],{"style":359},[83,541,542],{"style":376},"'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' ",[83,544,545],{"style":363},"})]",[83,547,459],{"style":359},[83,549,550],{"class":85,"style":86},[83,551,508],{"style":363},[73,553,556],{"language":350,"filename":554,"code":555,"class":78},"src\u002Fapp.ts","import { getPetById } from '.\u002Fgen\u002Fclients\u002FgetPetById'\n\nconst { data } = await getPetById({ path: { petId: 1 } })",[23,557,558,378,574,378,576],{"class":354},[83,559,560,562,564,567,569,571],{"class":85,"style":86},[83,561,360],{"style":359},[83,563,364],{"style":363},[83,565,566],{"style":93},"getPetById ",[83,568,370],{"style":363},[83,570,373],{"style":359},[83,572,573],{"style":376},"'.\u002Fgen\u002Fclients\u002FgetPetById'",[83,575],{"class":85,"style":86},[83,577,578,581,583,586,588,591,594,597,599,601,603,605,608,610,613],{"class":85,"style":86},[83,579,580],{"style":359},"const ",[83,582,364],{"style":363},[83,584,585],{"style":93},"data ",[83,587,370],{"style":363},[83,589,590],{"style":359},"= ",[83,592,593],{"style":359},"await ",[83,595,596],{"style":89},"getPetById",[83,598,497],{"style":363},[83,600,25],{"style":363},[83,602,453],{"style":359},[83,604,364],{"style":363},[83,606,607],{"style":363},"petId",[83,609,453],{"style":359},[83,611,612],{"style":363},"1 ",[83,614,615],{"style":363},"} })",[73,617,621],{"language":618,"filename":619,"code":620,"class":78},"text","Generated files","src\u002Fgen\u002F\n├── .kubb\u002F          # the runtime: client.ts, core.ts, config.ts, serializers\u002F, ...\n├── clients\u002F\n│   ├── getPetById.ts\n│   └── index.ts\n└── types\u002F",[23,622,624,378,629,378,634,378,639,378,644,378,649],{"class":623},"language-text",[83,625,626],{"class":85,"style":86},[83,627,628],{"style":93},"src\u002Fgen\u002F",[83,630,631],{"class":85,"style":86},[83,632,633],{"style":93},"├── .kubb\u002F          # the runtime: client.ts, core.ts, config.ts, serializers\u002F, ...",[83,635,636],{"class":85,"style":86},[83,637,638],{"style":93},"├── clients\u002F",[83,640,641],{"class":85,"style":86},[83,642,643],{"style":93},"│   ├── getPetById.ts",[83,645,646],{"class":85,"style":86},[83,647,648],{"style":93},"│   └── index.ts",[83,650,651],{"class":85,"style":86},[83,652,653],{"style":93},"└── types\u002F",[11,655,656,657,663,664,667,668,670,671,674,675,678,679,62],{},"With ",[15,658,660],{"href":659},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#integertype",[23,661,662],{},"integerType: 'number'",", an ",[23,665,666],{},"int64"," id such as ",[23,669,607],{}," is a ",[23,672,673],{},"number",". With the default ",[23,676,677],{},"bigint",", pass ",[23,680,681],{},"1n",{"title":683,"searchDepth":684,"depth":684,"links":685},"",5,[686,688,689,690],{"id":66,"depth":687,"text":67},2,{"id":199,"depth":687,"text":200},{"id":240,"depth":687,"text":241},{"id":344,"depth":687,"text":345},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-ky",1795015649596]