@@ -21,7 +21,7 @@ import * as API from './resources/index';
2121import { APIPromise } from './core/api-promise' ;
2222import { type Fetch } from './internal/builtin-types' ;
2323import { isRunningInBrowser } from './internal/detect-platform' ;
24- import { HeadersLike , NullableHeaders , buildHeaders , isEmptyHeaders } from './internal/headers' ;
24+ import { HeadersLike , NullableHeaders , buildHeaders } from './internal/headers' ;
2525import { FinalRequestOptions , RequestOptions } from './internal/request-options' ;
2626import {
2727 Completion ,
@@ -307,32 +307,22 @@ export class BaseAnthropic {
307307 ) ;
308308 }
309309
310- protected authHeaders ( opts : FinalRequestOptions ) : Headers | undefined {
311- const apiKeyAuth = this . apiKeyAuth ( opts ) ;
312- const bearerAuth = this . bearerAuth ( opts ) ;
313-
314- if ( apiKeyAuth != null && ! isEmptyHeaders ( apiKeyAuth ) ) {
315- return apiKeyAuth ;
316- }
317-
318- if ( bearerAuth != null && ! isEmptyHeaders ( bearerAuth ) ) {
319- return bearerAuth ;
320- }
321- return undefined ;
310+ protected authHeaders ( opts : FinalRequestOptions ) : NullableHeaders | undefined {
311+ return buildHeaders ( [ this . apiKeyAuth ( opts ) , this . bearerAuth ( opts ) ] ) ;
322312 }
323313
324- protected apiKeyAuth ( opts : FinalRequestOptions ) : Headers | undefined {
314+ protected apiKeyAuth ( opts : FinalRequestOptions ) : NullableHeaders | undefined {
325315 if ( this . apiKey == null ) {
326316 return undefined ;
327317 }
328- return new Headers ( { 'X-Api-Key' : this . apiKey } ) ;
318+ return buildHeaders ( [ { 'X-Api-Key' : this . apiKey } ] ) ;
329319 }
330320
331- protected bearerAuth ( opts : FinalRequestOptions ) : Headers | undefined {
321+ protected bearerAuth ( opts : FinalRequestOptions ) : NullableHeaders | undefined {
332322 if ( this . authToken == null ) {
333323 return undefined ;
334324 }
335- return new Headers ( { Authorization : `Bearer ${ this . authToken } ` } ) ;
325+ return buildHeaders ( [ { Authorization : `Bearer ${ this . authToken } ` } ] ) ;
336326 }
337327
338328 /**
0 commit comments