Anthropic
Neatlogs offers seamless integration with Anthropic, allowing you to track and analyze all your Claude model interactions automatically.
Installation
To get started with Anthropic, you'll need to install the package:
pip install neatlogs anthropic
Setting Up API Keys
Before using Anthropic with Neatlogs, you need to set up your API keys. You can obtain:
ANTHROPIC_API_KEY
: From your Anthropic ConsolePROJECT_API_KEY
: From your Neatlogs Dashboard
Then to set them up, you can either export them as environment variables or set them in a .env
file:
ANTHROPIC_API_KEY="your_anthropic_api_key_here"
Then load the environment variables in your Python code:
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
os.getenv("ANTHROPIC_API_KEY")
Usage
Once you've set up your Anthropic integration, integrating Neatlogs takes just two lines of code:
import neatlogs
neatlogs.init(api_key="<YOUR_API_KEY>")
Examples
Here's a simple example of how to use Anthropic with Neatlogs:
import neatlogs
from anthropic import Anthropic
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
# Initialize Neatlogs
neatlogs.init(api_key="YOUR_API_KEY")
# Initialize Anthropic client
client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
# Make a message request
response = client.messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=[
{"role": "user", "content": "What is the capital of France?"}
]
)
print(response.content[0].text)
After that, every API call is automatically traced and visualized in Neatlogs, perfect for debugging, evaluating and collaborating.
For more information on Anthropic, check out their comprehensive documentation.