You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Amazon Bedrock as an LLM provider backend for Anthropic Claude models.
ktx already supports Anthropic API, Google Vertex AI, Vercel AI Gateway, Claude Code, and Codex as LLM backends, but teams whose infrastructure lives on AWS typically consume Claude through Bedrock — IAM-based auth, AWS billing, and no separate Anthropic API key. Today those users have no first-class option (LLM configuration docs list vertex but nothing for AWS). Claude on Bedrock is reachable today via the gateway backend, but that routes through Vercel's AI Gateway and requires a Vercel API key — it doesn't serve teams that want direct IAM-authenticated, AWS-billed access.
Scope
A bedrock LLM backend, symmetric with the existing vertex backend:
llm.provider.backend: bedrock in ktx.yaml, with a bedrock.region field (supports the usual env: reference resolution).
Setup wizard entry + --bedrock-region flag, with a model health check.
Out of scope: Bedrock as an embedding backend, and non-Anthropic Bedrock models.
Key design
No new module — a fourth branch in the existing factory. All backends live in one provider (DefaultKtxLlmProvider in packages/cli/src/llm/model-provider.ts); the only backend-specific code is the branch in createModelFactory(). bedrock becomes a fourth branch alongside anthropic / vertex / gateway, using the Bedrock Anthropic entry point AI SDK v6 ships (mirroring the createVertexAnthropic import already there):
It speaks the Anthropic Messages protocol, so the existing providerOptions.anthropic.* plumbing (prompt-cache markers in message-builder.ts, thinking options) works unchanged. New dependency: @ai-sdk/amazon-bedrock.
Auth delegates to the AWS default credential chain (env vars, shared profile, IAM role), exactly as the vertex backend delegates to GCP ADC. Config carries only region — no access keys in ktx.yaml.
One real fix needed: Bedrock model IDs look like us.anthropic.claude-sonnet-4-5-20250929-v1:0. isAnthropicProtocolModel() in llm/model-provider.ts currently checks startsWith('claude-') / includes('/claude-'), so Bedrock IDs would not be recognized as Anthropic models and cache markers / thinking options would be silently dropped. The check needs to be widened (e.g. includes('claude-')).
Prompt caching: Bedrock supports both 5m and 1h cache TTLs, so no vertexFallbackTo5m-style special case is needed.
Which area?
CLI / setup
Want to contribute this?
Yes, I'd like to open a PR
Heads-up: open PR #356 adds an OpenAI-compatible backend and touches the same backend-registration files — happy to sequence this after it lands and rebase, or coordinate however is easiest for maintainers.
What do you want, and why?
Add Amazon Bedrock as an LLM provider backend for Anthropic Claude models.
ktx already supports Anthropic API, Google Vertex AI, Vercel AI Gateway, Claude Code, and Codex as LLM backends, but teams whose infrastructure lives on AWS typically consume Claude through Bedrock — IAM-based auth, AWS billing, and no separate Anthropic API key. Today those users have no first-class option (LLM configuration docs list
vertexbut nothing for AWS). Claude on Bedrock is reachable today via thegatewaybackend, but that routes through Vercel's AI Gateway and requires a Vercel API key — it doesn't serve teams that want direct IAM-authenticated, AWS-billed access.Scope
A
bedrockLLM backend, symmetric with the existingvertexbackend:llm.provider.backend: bedrockinktx.yaml, with abedrock.regionfield (supports the usualenv:reference resolution).--bedrock-regionflag, with a model health check.guides/llm-configuration,configuration/ktx-yaml,cli-reference/ktx-setup).Out of scope: Bedrock as an embedding backend, and non-Anthropic Bedrock models.
Key design
No new module — a fourth branch in the existing factory. All backends live in one provider (
DefaultKtxLlmProviderinpackages/cli/src/llm/model-provider.ts); the only backend-specific code is the branch increateModelFactory().bedrockbecomes a fourth branch alongsideanthropic/vertex/gateway, using the Bedrock Anthropic entry point AI SDK v6 ships (mirroring thecreateVertexAnthropicimport already there):It speaks the Anthropic Messages protocol, so the existing
providerOptions.anthropic.*plumbing (prompt-cache markers inmessage-builder.ts, thinking options) works unchanged. New dependency:@ai-sdk/amazon-bedrock.Auth delegates to the AWS default credential chain (env vars, shared profile, IAM role), exactly as the
vertexbackend delegates to GCP ADC. Config carries onlyregion— no access keys inktx.yaml.Touch points are the same files every backend addition has gone through (see Restore Vertex AI LLM setup #56 Vertex, feat: add claude-code llm backend with runtime port #115 claude-code, feat: add codex llm backend for ktx runtime work #253 codex):
KtxLlmBackendunion +KtxLlmConfiginllm/types.ts, the factory branch inllm/model-provider.ts, the zod provider schema incontext/project/config.ts, reference resolution incontext/llm/local-config.ts, and the setup wizard insetup-models.ts.One real fix needed: Bedrock model IDs look like
us.anthropic.claude-sonnet-4-5-20250929-v1:0.isAnthropicProtocolModel()inllm/model-provider.tscurrently checksstartsWith('claude-')/includes('/claude-'), so Bedrock IDs would not be recognized as Anthropic models and cache markers / thinking options would be silently dropped. The check needs to be widened (e.g.includes('claude-')).Prompt caching: Bedrock supports both 5m and 1h cache TTLs, so no
vertexFallbackTo5m-style special case is needed.Which area?
CLI / setup
Want to contribute this?
Heads-up: open PR #356 adds an OpenAI-compatible backend and touches the same backend-registration files — happy to sequence this after it lands and rebase, or coordinate however is easiest for maintainers.