Arcanum.Adapters.Anthropic (arcanum v0.1.7)

Copy Markdown View Source

Inference adapter for the Anthropic Messages API.

Handles Anthropic-specific wire format:

  • System prompt as top-level parameter (not a message)
  • Content blocks for text, tool_use, tool_result, thinking
  • Tool definitions as name/description/input_schema
  • Only "user" and "assistant" roles allowed in messages
  • Tool results sent as "user" role with tool_result content blocks
  • Multimodal content blocks (text + images)

Summary

Functions

Serializes content blocks to Anthropic wire format.

Functions

serialize_content(blocks)

Serializes content blocks to Anthropic wire format.

Text-only messages are sent as a plain string (single text block optimization). Mixed content (text + images) is sent as an array of typed objects.