MCPcopy Create free account
hub / github.com/TanStack/ai / build

Function build

packages/ai-bedrock/src/index.ts:66–91  ·  view source on GitHub ↗

* Shared branching used by both public factories. Constructs the adapter * classes directly so their constructors run the full auth cascade lazily * (config.apiKey → BEDROCK_API_KEY → AWS_BEARER_TOKEN_BEDROCK → SigV4). No * eager env-key fetch here, so `auth: 'sigv4'` never throws for a missing k

(
  model: BedrockConverseModels,
  config?: BedrockClientConfig & { api?: 'converse' | 'chat' | 'responses' },
)

Source from the content-addressed store, hash-verified

64 * Default path → Converse adapter; opt-in via `api: 'chat'` or `api: 'responses'`.
65 */
66function build(
67 model: BedrockConverseModels,
68 config?: BedrockClientConfig & { api?: 'converse' | 'chat' | 'responses' },
69): AnyBedrockAdapter {
70 if (config?.api === 'responses') {
71 const rest = stripApi(config)
72 if (!isResponsesModel(model)) {
73 throw new Error(
74 `Model "${model}" is not available on the Bedrock Responses API. ` +
75 `Responses-capable models: ${BEDROCK_RESPONSES_MODELS.join(', ')}.`,
76 )
77 }
78 return new BedrockResponsesTextAdapter(rest, model)
79 }
80 if (config?.api === 'chat') {
81 if (!isChatModel(model)) {
82 throw new Error(
83 `Model "${model}" is not available on the Bedrock Chat Completions API. ` +
84 `Chat-capable models: ${BEDROCK_CHAT_MODELS.join(', ')}.`,
85 )
86 }
87 return new BedrockTextAdapter(stripApi(config), model)
88 }
89 // Default + explicit 'converse'
90 return new BedrockConverseTextAdapter(config ? stripApi(config) : {}, model)
91}
92
93// --- createBedrockText: explicit key, overloaded on `api` ---
94export function createBedrockText<TModel extends BedrockConverseModels>(

Callers 4

createBedrockTextFunction · 0.70
bedrockTextFunction · 0.70
openStdioTransportMethod · 0.50
esbuild-smoke.tsFile · 0.50

Calls 3

stripApiFunction · 0.85
isResponsesModelFunction · 0.85
isChatModelFunction · 0.85

Tested by

no test coverage detected