Anthropic
JournaledAnthropic — drop-in replacement for anthropic.Anthropic.
Usage
from tokenid import JournaledAnthropic
client = JournaledAnthropic(
api_key="sk-ant-…", # your Anthropic key
session_id="my-session", # groups calls in your dashboard
)
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
)
JournaledAnthropic accepts every argument that anthropic.Anthropic accepts. All methods are available.
Prompt caching
Prompt cache tokens (cache_read, cache_creation) are captured automatically from response.usage.
Tool use
Tool calls and tool results are captured as separate event fields: tool_name, tool_input, tool_output.
Streaming
with client.messages.stream(
model="claude-opus-4-7",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key |
string | Yes | Your Anthropic API key |
session_id |
string | No | Groups calls into a named session in your dashboard |
enforcement_config |
dict | No | Local enforcement rules (see Enforcement) |