Skip to main content
This guide shows you how to use W&B Weave with W&B Inference. Using W&B Inference, you can build and trace LLM applications using live open-source models without setting up your own infrastructure or managing API keys from multiple providers. Just obtain your W&B API key and use it to interact with all models hosted by W&B Inference.

What you’ll learn

In this guide, you’ll:
  • Set up Weave and W&B Inference
  • Build a basic LLM application with automatic tracing
  • Compare multiple models
  • Evaluate model performance on a dataset
  • View your results in the Weave UI

Prerequisites

Before you begin, you need a W&B account and an API key from https://wandb.ai/authorize. Then, in a Python environment running version 3.9 or later, install the required libraries:
The openai library is installed because you use the standard openai client to interact with W&B Inference, regardless of which hosted model you’re actually calling. This allows you to swap between supported models by only changing the slug, and make use of any existing code you have that was written to use the OpenAI API.

Step 1: Trace your first LLM call

Start with a basic example that uses Llama 3.1-8B through W&B Inference. When you run this code, Weave:
  • Traces your LLM call automatically
  • Logs inputs, outputs, latency, and token usage
  • Provides a link to view your trace in the Weave UI

Step 2: Build a text summarization application

Next, try running this code, which is a basic summarization app that shows how Weave traces nested operations:

Step 3: Compare multiple models

W&B Inference provides access to multiple models. Use the following code to compare the performance of Llama and DeepSeek’s respective responses:

Step 4: Evaluate model performance

Evaluate how well a model performs on a Q&A task using Weave’s built-in EvaluationLogger. This provides structured evaluation tracking with automatic aggregation, token usage capture, and rich comparison features in the UI. Append the following code to the script you used in step 3:
Running these examples returns links to the traces in the terminal. Click any link to view traces in the Weave UI. In the Weave UI, you can:
  • Review a timeline of all your LLM calls
  • Inspect inputs and outputs for each operation
  • View token usage and estimated costs (automatically captured by EvaluationLogger)
  • Analyze latency and performance metrics
  • Navigate to the Evals tab to see aggregated evaluation results
  • Use the Compare feature to analyze performance across different models
  • Page through specific examples to see how different models performed on the same inputs

Available models

For a complete list of available models, see the Available Models section in the W&B Inference documentation.

Next steps

Troubleshooting