Try the new W&B Inference service free. It gives you access to AI models through an API and the Weave Playground.
Follow these steps to track your first call. You can also Open In Colab

1. Install Weave and get your API key

Install weave First, install the weave library:
pip install weave
Get your API key Create a W&B account at https://wandb.ai. Then copy your API key from https://wandb.ai/authorize.

2. Log a trace to a new project

Follow these steps to track your first project:
  • Import the weave library
  • Call weave.init('project-name') to start tracking
    • The system asks for your API key if you haven’t logged in yet
    • To log to a team, use team-name/project-name
    • Set the WANDB_API_KEY environment variable to skip the login prompt
  • Add @weave.op() to the functions you want to track
This example uses OpenAI. You need an OpenAI API key.
import weave
from openai import OpenAI

client = OpenAI()

# Weave tracks the inputs, outputs and code of this function
@weave.op()
def extract_dinos(sentence):
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {
                "role": "system",
                "content": """Extract dinosaurs from the text. Return JSON with:
- dinosaurs: list of dinosaurs
- name: scientific name  
- common_name: nickname
- diet: herbivore or carnivore."""
            },
            {
                "role": "user",
                "content": sentence
            }
        ],
        response_format={ "type": "json_object" }
    )
    return response.choices[0].message.content


# Start the weave project
weave.init('jurassic-park')

sentence = """I saw a T. rex chase a Triceratops. 
The T. rex eats meat. The Triceratops eats plants.
A Brachiosaurus ate leaves from tall trees nearby."""

result = extract_dinos(sentence)
print(result)
When you call extract_dinos, Weave shows a link to view your trace.

3. Automatic AI library logging

Weave tracks calls to many AI services: Weave logs:
  • AI model info
  • Token usage
  • Cost
To track other AI tools, wrap them with @weave.op().

4. See traces in your project

Great job. Now Weave captures data every time you call your function. It also tracks code changes. Weave Trace Outputs 1

Next steps