The Synth Anthropic clients provide the same functionality as the original Anthropic clients, but automatically track all AI messages when used within methods decorated with trace_event.

Usage

from synth_sdk import AsyncAnthropic, Anthropic
import uuid

class Agent:
    def __init__(self):
        self.system_instance_id = str(uuid.uuid4())
        self.system_name = "Example_System"
        self.client = AsyncAnthropic()  # or Anthropic() for sync

    @trace_event_async(
        event_type="solve_problem",
    )
    async def solve_problem(self, problem: str):
        # Messages are automatically tracked - no need for track_messages
        response = await self.client.messages.create(
            model="claude-3-haiku-20240307",
            system="You are a problem solver.",
            messages=[{"role": "user", "content": problem}],
            temperature=0.7
        )
        return response.content[0].text

The client automatically tracks:

  • Input messages
  • Output messages
  • Model parameters
  • Tool calls and responses

Note: When using these clients within trace_event decorated methods, you don’t need to use track_messages as all interactions are automatically tracked.