@@ -21,7 +21,7 @@ import * as API from './resources/index';
21
21
import { APIPromise } from './core/api-promise' ;
22
22
import { type Fetch } from './internal/builtin-types' ;
23
23
import { isRunningInBrowser } from './internal/detect-platform' ;
24
- import { HeadersLike , NullableHeaders , buildHeaders , isEmptyHeaders } from './internal/headers' ;
24
+ import { HeadersLike , NullableHeaders , buildHeaders } from './internal/headers' ;
25
25
import { FinalRequestOptions , RequestOptions } from './internal/request-options' ;
26
26
import {
27
27
Completion ,
@@ -307,32 +307,22 @@ export class BaseAnthropic {
307
307
) ;
308
308
}
309
309
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 ) ] ) ;
322
312
}
323
313
324
- protected apiKeyAuth ( opts : FinalRequestOptions ) : Headers | undefined {
314
+ protected apiKeyAuth ( opts : FinalRequestOptions ) : NullableHeaders | undefined {
325
315
if ( this . apiKey == null ) {
326
316
return undefined ;
327
317
}
328
- return new Headers ( { 'X-Api-Key' : this . apiKey } ) ;
318
+ return buildHeaders ( [ { 'X-Api-Key' : this . apiKey } ] ) ;
329
319
}
330
320
331
- protected bearerAuth ( opts : FinalRequestOptions ) : Headers | undefined {
321
+ protected bearerAuth ( opts : FinalRequestOptions ) : NullableHeaders | undefined {
332
322
if ( this . authToken == null ) {
333
323
return undefined ;
334
324
}
335
- return new Headers ( { Authorization : `Bearer ${ this . authToken } ` } ) ;
325
+ return buildHeaders ( [ { Authorization : `Bearer ${ this . authToken } ` } ] ) ;
336
326
}
337
327
338
328
/**
0 commit comments