@@ -175,6 +175,8 @@ export interface ClientOptions {
175175 */
176176 apiKey ?: string | undefined ;
177177
178+ projectID ?: string | null | undefined ;
179+
178180 /**
179181 * Specifies the environment to use for the API.
180182 *
@@ -258,6 +260,7 @@ export interface ClientOptions {
258260 */
259261export class Kernel {
260262 apiKey : string ;
263+ projectID : string | null ;
261264
262265 baseURL : string ;
263266 maxRetries : number ;
@@ -277,6 +280,7 @@ export class Kernel {
277280 * API Client for interfacing with the Kernel API.
278281 *
279282 * @param {string | undefined } [opts.apiKey=process.env['KERNEL_API_KEY'] ?? undefined]
283+ * @param {string | null | undefined } [opts.projectID]
280284 * @param {Environment } [opts.environment=production] - Specifies the environment URL to use for the API.
281285 * @param {string } [opts.baseURL=process.env['KERNEL_BASE_URL'] ?? https://api.onkernel.com/] - Override the default base URL for the API.
282286 * @param {number } [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
@@ -289,6 +293,7 @@ export class Kernel {
289293 constructor ( {
290294 baseURL = readEnv ( 'KERNEL_BASE_URL' ) ,
291295 apiKey = readEnv ( 'KERNEL_API_KEY' ) ,
296+ projectID = null ,
292297 ...opts
293298 } : ClientOptions = { } ) {
294299 // Check for Bun runtime in a way that avoids type errors if Bun is not defined
@@ -311,6 +316,7 @@ export class Kernel {
311316
312317 const options : ClientOptions = {
313318 apiKey,
319+ projectID,
314320 ...opts ,
315321 baseURL,
316322 environment : opts . environment ?? 'production' ,
@@ -358,6 +364,7 @@ export class Kernel {
358364 this . _options = options ;
359365
360366 this . apiKey = apiKey ;
367+ this . projectID = projectID ;
361368 }
362369
363370 /**
@@ -375,6 +382,7 @@ export class Kernel {
375382 fetch : this . rawFetch ,
376383 fetchOptions : this . fetchOptions ,
377384 apiKey : this . apiKey ,
385+ projectID : this . projectID ,
378386 ...options ,
379387 } ) ;
380388 client . browserRouteCache = this . browserRouteCache ;
@@ -851,6 +859,7 @@ export class Kernel {
851859 'X-Stainless-Retry-Count' : String ( retryCount ) ,
852860 ...( options . timeout ? { 'X-Stainless-Timeout' : String ( Math . trunc ( options . timeout / 1000 ) ) } : { } ) ,
853861 ...getPlatformHeaders ( ) ,
862+ 'X-Kernel-Project-Id' : this . projectID ,
854863 } ,
855864 await this . authHeaders ( options ) ,
856865 this . _options . defaultHeaders ,
0 commit comments