MCPcopy Index your code
hub / github.com/codeaashu/claude-code / createBedrockRuntimeClient

Function createBedrockRuntimeClient

src/utils/model/bedrock.ts:96–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94}
95
96export async function createBedrockRuntimeClient() {
97 const { BedrockRuntimeClient } = await import(
98 '@aws-sdk/client-bedrock-runtime'
99 )
100 const region = getAWSRegion()
101 const skipAuth = isEnvTruthy(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)
102
103 const clientConfig: ConstructorParameters<typeof BedrockRuntimeClient>[0] = {
104 region,
105 ...(process.env.ANTHROPIC_BEDROCK_BASE_URL && {
106 endpoint: process.env.ANTHROPIC_BEDROCK_BASE_URL,
107 }),
108 ...(await getAWSClientProxyConfig()),
109 ...(skipAuth && {
110 // BedrockRuntimeClient defaults to HTTP/2 without fallback
111 // proxy servers may not support this, so we explicitly force HTTP/1.1
112 requestHandler: new (
113 await import('@smithy/node-http-handler')
114 ).NodeHttpHandler(),
115 httpAuthSchemes: [
116 {
117 schemeId: 'smithy.api#noAuth',
118 identityProvider: () => async () => ({}),
119 signer: new (await import('@smithy/core')).NoAuthSigner(),
120 },
121 ],
122 httpAuthSchemeProvider: () => [{ schemeId: 'smithy.api#noAuth' }],
123 }),
124 }
125
126 if (!skipAuth && !process.env.AWS_BEARER_TOKEN_BEDROCK) {
127 // Only refresh credentials if not using API key authentication
128 const cachedCredentials = await refreshAndGetAwsCredentials()
129 if (cachedCredentials) {
130 clientConfig.credentials = {
131 accessKeyId: cachedCredentials.accessKeyId,
132 secretAccessKey: cachedCredentials.secretAccessKey,
133 sessionToken: cachedCredentials.sessionToken,
134 }
135 }
136 }
137
138 return new BedrockRuntimeClient(clientConfig)
139}
140
141export const getInferenceProfileBackingModel = memoize(async function (
142 profileId: string,

Callers 1

countTokensWithBedrockFunction · 0.85

Calls 3

getAWSRegionFunction · 0.85
isEnvTruthyFunction · 0.85
getAWSClientProxyConfigFunction · 0.85

Tested by

no test coverage detected