Skip to content

[feature] Amazon Bedrock LLM provider backend #358

Description

@saygenie

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 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.
  • Docs updates (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 (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):

    import { createBedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
    const bedrock = createBedrockAnthropic({ region: 'us-east-1' });

    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.

  • 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): KtxLlmBackend union + KtxLlmConfig in llm/types.ts, the factory branch in llm/model-provider.ts, the zod provider schema in context/project/config.ts, reference resolution in context/llm/local-config.ts, and the setup wizard in setup-models.ts.

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageNeeds maintainer review before work begins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions