Skip to main content

Synchronous Usage

from anthropic import Anthropic
import dokumetry

client = Anthropic(
  api_key="YOUR_ANTHROPIC_API_KEY",
)

# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all Anthropic calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")

message = client.messages.create(
  messages=[{ "role": "user", "content": "Hello, Explain LLM Monitoring in one sentence"}],
  model="claude-3-opus-20240229",
  max_tokens=1024
)
print(message.content)

Asynchronous usage

import asyncio
from anthropic import AsyncAnthropic
import dokumetry

client = AsyncAnthropic(
  api_key="YOUR_ANTHROPIC_API_KEY",
)

# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all Anthropic calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")

async def main() -> None:
  message = await client.messages.create(
    messages=[{"role": "user","content": "Hello, How to monitor LLM Applications?"}],
    model="claude-3-opus-20240229",
  )
  print(message.content)

asyncio.run(main())