Skip to main content
W&B Sandboxes is in private preview, available by invitation only. To request enrollment, contact support or your AISE.
In this tutorial, you will invoke an agent within a W&B Sandbox environment. To do this, you will start a sandbox with the appropriate environment variables, install the necessary dependencies, and run a Python script that creates and invokes a simple OpenAI agent that uses tool calls to get the weather for a location and respond with a punny weather forecast.
This tutorial uses OpenAI as the language model for the agent, which requires an OpenAI API key.

Prerequisites

Install W&B Python SDK

Install the W&B Python SDK. You can do this using pip:

Log in and authenticate with W&B

Run the wandb login CLI command and follow the prompts to log in to your W&B account:

Store API keys in Secret Manager

Store your OpenAI API key in the W&B Secret Manager as OPENAI_API_KEY. See Secrets for more information about using secrets in sandboxes. This allows you to securely access the API key in the sandbox without hardcoding it in your code or sandbox configuration.

Copy agent code

Copy and paste the following code into a file named demo.py in the same directory as this tutorial, then run the above code snippet to see how to invoke an OpenAI agent within a sandbox environment.
demo.py