Skip to content

Commit b661c5f

Browse files
committed
feat(bedrock): support skipAuth on Bedrock client to bypass local auth requirements
1 parent d96bded commit b661c5f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/bedrock-sdk/src/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type ClientOptions = Omit<CoreClientOptions, 'apiKey' | 'authToken'> & {
2222
*/
2323
awsRegion?: string | undefined;
2424
awsSessionToken?: string | null | undefined;
25+
skipAuth?: boolean;
2526
};
2627

2728
/** API Client for interfacing with the Anthropic Bedrock API. */
@@ -30,6 +31,7 @@ export class AnthropicBedrock extends BaseAnthropic {
3031
awsAccessKey: string | null;
3132
awsRegion: string;
3233
awsSessionToken: string | null;
34+
skipAuth: boolean = false;
3335

3436
/**
3537
* API Client for interfacing with the Anthropic Bedrock API.
@@ -46,6 +48,7 @@ export class AnthropicBedrock extends BaseAnthropic {
4648
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
4749
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
4850
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
51+
* @param {boolean} [opts.skipAuth=false] - Skip authentication for this request. This is useful if you have an internal proxy that handles authentication for you.
4952
*/
5053
constructor({
5154
awsRegion = readEnv('AWS_REGION') ?? 'us-east-1',
@@ -64,6 +67,7 @@ export class AnthropicBedrock extends BaseAnthropic {
6467
this.awsAccessKey = awsAccessKey;
6568
this.awsRegion = awsRegion;
6669
this.awsSessionToken = awsSessionToken;
70+
this.skipAuth = opts.skipAuth ?? false;
6771
}
6872

6973
messages: MessagesResource = makeMessagesResource(this);
@@ -78,6 +82,9 @@ export class AnthropicBedrock extends BaseAnthropic {
7882
request: FinalizedRequestInit,
7983
{ url, options }: { url: string; options: FinalRequestOptions },
8084
): Promise<void> {
85+
if (this.skipAuth) {
86+
return;
87+
}
8188
const regionName = this.awsRegion;
8289
if (!regionName) {
8390
throw new Error(

0 commit comments

Comments
 (0)