Skip to content

Commit a8343ef

Browse files
stainless-botRobertCraigie
authored andcommitted
feat(client): send X-Stainless-Timeout header
chore: unknown commit message
1 parent 893d5ec commit a8343ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,11 +655,12 @@ export class OpenAI {
655655
options: FinalRequestOptions,
656656
{ retryCount = 0 }: { retryCount?: number } = {},
657657
): { req: FinalizedRequestInit; url: string; timeout: number } {
658+
options = { ...options };
658659
const { method, path, query } = options;
659660

660661
const url = this.buildURL(path!, query as Record<string, unknown>);
661662
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
662-
const timeout = options.timeout ?? this.timeout;
663+
options.timeout = options.timeout ?? this.timeout;
663664
const { bodyHeaders, body } = this.buildBody({ options });
664665
const reqHeaders = this.buildHeaders({ options, method, bodyHeaders, retryCount });
665666

@@ -674,7 +675,7 @@ export class OpenAI {
674675
...((options.fetchOptions as any) ?? {}),
675676
};
676677

677-
return { req, url, timeout };
678+
return { req, url, timeout: options.timeout };
678679
}
679680

680681
private buildHeaders({
@@ -700,6 +701,7 @@ export class OpenAI {
700701
Accept: 'application/json',
701702
'User-Agent': this.getUserAgent(),
702703
'X-Stainless-Retry-Count': String(retryCount),
704+
...(options.timeout ? { 'X-Stainless-Timeout': String(options.timeout) } : {}),
703705
...getPlatformHeaders(),
704706
'OpenAI-Organization': this.organization,
705707
'OpenAI-Project': this.project,

0 commit comments

Comments
 (0)