Code Example: How to create a prompt template

This folder contains the code for the Guides » Gateway » Create a prompt template page in the documentation.

Running the Example

  1. Set the OPENAI_API_KEY environment variable:
export OPENAI_API_KEY="sk-..." # Replace with your OpenAI API key
  1. Launch the TensorZero Gateway and a local Postgres database:
docker compose up
  1. Run the example:

Install the Python dependencies. We recommend using uv:

uv sync

Run the example:

uv run openai_sdk.py