Skip to content

Commit a0011b6

Browse files
feat: Add project_id SDK client option mapped to X-Kernel-Project-Id
1 parent 5a9b47d commit a0011b6

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 119
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-c6458d9c6cb5d7e3d8309c79b69eba3a22269e0ecc0bdafbaee00fde4b302e99.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-51549f813f3002e18c6ca8d850cc0c7932828d511c151e0412c73b6798d19e30.yml
33
openapi_spec_hash: ee77b293c4bda91c1a32cfdd12b8739e
4-
config_hash: 80eef1b592110714ea55cd26c470fabb
4+
config_hash: 57567e00b41af47cef1b78e51b747aa0

src/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
259261
export 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

Comments
 (0)