Back to Tensorzero

Example: Tool Use (Function Calling)

examples/guides/tool-use/README.md

2026.4.1998 B
Original Source

Example: Tool Use (Function Calling)

This directory contains the code for the Tool Use (Function Calling) guide.

Getting Started

TensorZero

We provide a simple TensorZero configuration with a weather_chatbot chat function that has access to a get_temperature tool.

Prerequisites

  1. Install Docker.
  2. Generate an API key for OpenAI (OPENAI_API_KEY).

Setup

  1. Set the OPENAI_API_KEY environment variable in your shell (not in your .env file).
  2. Launch the TensorZero Gateway with docker compose up.

Running the Example

Python (OpenAI SDK)

  1. Install the Python dependencies. We recommend using uv: uv sync
  2. Run the example with python openai_sdk.py.

Node / TypeScript (OpenAI SDK)

  1. Install the dependencies with npm install.
  2. Run the example with npx tsx openai_sdk.ts.

HTTP (cURL)

  1. Run the example with bash curl.sh.