Request Logs
Logging Anthropic Requests
Anthropic’s language models have a different API structure than those of OpenAI. To record requests made to Anthropic’s models, follow the examples below:
import time
from anthropic import Anthropic
from openpipe.client import OpenPipe
anthropic = Anthropic()
op_client = OpenPipe()
payload = {
"model": "claude-3-opus-20240229",
"messages": [{"role": "user", "content": "Hello, Claude"}],
"max_tokens": 100,
}
message = anthropic.messages.create(**payload)
op_client.report_anthropic(
requested_at=int(time.time() * 1000),
received_at=int(time.time() * 1000),
req_payload=payload,
resp_payload=message,
status_code=200,
tags={
"prompt_id": "My prompt id",
},
)
If you’re using a different programming language, you can make a raw http request to the report-anthropic enpoint.