Skip to content

Commit 3e40365

Browse files
feat: add project and project_id fields to stainless client
1 parent 35f2757 commit 3e40365

File tree

9 files changed

+108
-211
lines changed

9 files changed

+108
-211
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 116
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/letta-ai%2Fletta-sdk-a9ff341ff063b78562593283d6e7819abafbd2aa054c91b98e0e5562719b5adc.yml
33
openapi_spec_hash: 47cacb4ecc962e794d755e04b57e1222
4-
config_hash: 2f7b008679cb11cc41a33469fd412d26
4+
config_hash: 0312d0f7207b1d7f2320c478b0e84b25

src/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ export interface ClientOptions {
194194
*/
195195
apiKey?: string | undefined;
196196

197+
projectID?: string | null | undefined;
198+
197199
/**
198200
* Specifies the environment to use for the API.
199201
*
@@ -277,6 +279,7 @@ export interface ClientOptions {
277279
*/
278280
export class Letta {
279281
apiKey: string;
282+
projectID: string | null;
280283

281284
baseURL: string;
282285
maxRetries: number;
@@ -294,6 +297,7 @@ export class Letta {
294297
* API Client for interfacing with the Letta API.
295298
*
296299
* @param {string | undefined} [opts.apiKey=process.env['LETTA_API_KEY'] ?? undefined]
300+
* @param {string | null | undefined} [opts.projectID]
297301
* @param {Environment} [opts.environment=cloud] - Specifies the environment URL to use for the API.
298302
* @param {string} [opts.baseURL=process.env['LETTA_BASE_URL'] ?? https://api.letta.com] - Override the default base URL for the API.
299303
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
@@ -306,6 +310,7 @@ export class Letta {
306310
constructor({
307311
baseURL = readEnv('LETTA_BASE_URL'),
308312
apiKey = readEnv('LETTA_API_KEY'),
313+
projectID = null,
309314
...opts
310315
}: ClientOptions = {}) {
311316
if (apiKey === undefined) {
@@ -316,6 +321,7 @@ export class Letta {
316321

317322
const options: ClientOptions = {
318323
apiKey,
324+
projectID,
319325
...opts,
320326
baseURL,
321327
environment: opts.environment ?? 'cloud',
@@ -345,6 +351,7 @@ export class Letta {
345351
this._options = options;
346352

347353
this.apiKey = apiKey;
354+
this.projectID = projectID;
348355
}
349356

350357
/**
@@ -362,6 +369,7 @@ export class Letta {
362369
fetch: this.fetch,
363370
fetchOptions: this.fetchOptions,
364371
apiKey: this.apiKey,
372+
projectID: this.projectID,
365373
...options,
366374
});
367375
return client;
@@ -832,6 +840,7 @@ export class Letta {
832840
'X-Stainless-Retry-Count': String(retryCount),
833841
...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
834842
...getPlatformHeaders(),
843+
'X-Project': this.projectID,
835844
},
836845
await this.authHeaders(options),
837846
this._options.defaultHeaders,

0 commit comments

Comments
 (0)