Skip to content

Commit ee58772

Browse files
committed
chore(bedrock): add skipAuth option to allow users to let authorization be handled elsewhere
1 parent 4a32091 commit ee58772

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

packages/bedrock-sdk/examples/demo.ts

100644100755
File mode changed.

packages/bedrock-sdk/examples/streaming.ts

100644100755
File mode changed.

packages/bedrock-sdk/src/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type ClientOptions = Omit<API.ClientOptions, 'apiKey' | 'authToken'> & {
1616
*/
1717
awsRegion?: string | undefined;
1818
awsSessionToken?: string | null | undefined;
19+
skipAuth?: boolean;
1920
};
2021

2122
/** API Client for interfacing with the Anthropic Bedrock API. */
@@ -24,6 +25,7 @@ export class AnthropicBedrock extends Core.APIClient {
2425
awsAccessKey: string | null;
2526
awsRegion: string;
2627
awsSessionToken: string | null;
28+
skipAuth: boolean = false;
2729

2830
private _options: ClientOptions;
2931

@@ -41,6 +43,7 @@ export class AnthropicBedrock extends Core.APIClient {
4143
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
4244
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
4345
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
46+
* @param {boolean} [opts.skipAuth=false] - Skip authentication for this request. This is useful if you have an internal proxy that handles authentication for you.
4447
*/
4548
constructor({
4649
baseURL = Core.readEnv('ANTHROPIC_BEDROCK_BASE_URL'),
@@ -72,6 +75,7 @@ export class AnthropicBedrock extends Core.APIClient {
7275
this.awsAccessKey = awsAccessKey;
7376
this.awsRegion = awsRegion;
7477
this.awsSessionToken = awsSessionToken;
78+
this.skipAuth = opts.skipAuth ?? false;
7579
}
7680

7781
messages: MessagesResource = makeMessagesResource(this);
@@ -93,6 +97,9 @@ export class AnthropicBedrock extends Core.APIClient {
9397
request: RequestInit,
9498
{ url, options }: { url: string; options: Core.FinalRequestOptions },
9599
): Promise<void> {
100+
if (this.skipAuth) {
101+
return;
102+
}
96103
const regionName = this.awsRegion;
97104
if (!regionName) {
98105
throw new Error(

0 commit comments

Comments
 (0)