Skip to main content
wrap() (Python) and wrapAnthropic() (TypeScript) wrap the Anthropic client, including the Bedrock and Vertex clients of the same SDK in Python, so messages.create and messages.stream get the context and record the answer.

Install

The TypeScript integration ships with @niadra/sdk 0.3.0, ready on main and on npm when it is published; until then the npm package is 0.1.1.

The five primitives

Minimal example

The same code is in examples/anthropic_messages.py and examples/anthropic.ts.

Limits

  • Outside a conversation or task block, calls pass through untouched, and nothing the wrapper does can fail the call.
  • In TypeScript, for messages.stream() prepare the body with anthropicParams() and record the final message with recordAnthropic().
  • The wrapper adds no cache_control where you use no prompt caching: it never changes your caching strategy.
  • Tested against anthropic 1.8 and @anthropic-ai/sdk 0.128 with the transport replaced and Niadra on the emulator.

Next steps

Amazon Bedrock

the same for the Converse API.

Context and views

the target model and the cache floors.