You can experiment with Google AI models on Weave without any setup using the LLM Playground.
- Google GenAI SDK, which is accessible through Python SDK, Node.js SDK, Go SDK, and REST.
- Google Vertex AI API, which provides access to Google’s Gemini models and partner models.
Weave also supports the deprecated Google AI Python SDK for the Gemini API. This support is deprecated as well and is scheduled for removal in a future version.
Get started
The following examples show how to enable tracing for each supported SDK. In both cases, callingweave.init is the only Weave-specific step required. Your existing Google GenAI or Vertex AI code stays the same.
Weave automatically captures traces for the Google GenAI SDK. To start tracking, call weave.init(project_name="[YOUR-WANDB-PROJECT-NAME]") and use the library as normal.
Weave also automatically captures traces for Vertex APIs. To start tracking, call weave.init(project_name="[YOUR-WANDB-PROJECT-NAME]") and use the library as normal.
Track your own ops
Wrap a function with@weave.op to start capturing inputs, outputs, and app logic so you can debug how data flows through your app. You can deeply nest ops and build a tree of functions that you want to track. This also starts automatically versioning code as you experiment to capture ad-hoc details that haven’t been committed to git.
Create a function decorated with @weave.op.
In the following example, the function recommend_places_to_visit is wrapped with @weave.op and recommends places to visit in a city.
Create a Model for easier experimentation
Organizing experimentation is difficult when there are many moving pieces. By using the Model class, you can capture and organize the experimental details of your app like your system prompt or the model you’re using. This helps organize and compare different iterations of your app.
In addition to versioning code and capturing inputs/outputs, Models capture structured parameters that control your application’s behavior, helping you find what parameters worked best. You can also use Weave Models with serve, and Evaluations.
In the following example, you can experiment with CityVisitRecommender. Every time you change one of these, you’ll get a new version of CityVisitRecommender. This gives you a versioned record of each configuration you try, which you can later compare or evaluate.