Overview
When working with OpenAI’s API, it’s important to set up your environment and client correctly to ensure secure and efficient API calls. This guide shows you how to create a basic integration using Galileo’s OpenAI client wrapper. In this guide you will:The Galileo OpenAI wrapper currently only supports the synchronous chat completions API.
Before you start
To complete this how-to, you will need:- An OpenAI API key
- A Galileo project configured
- Your Galileo API key
Install dependencies
To use Galileo, you need to install some package dependencies, and configure environment variables.1
Install Required Dependencies
Install the required dependencies for your app. If you are using Python, create a virtual environment using your preferred method, then install dependencies inside that environment:
2
Create a .env file, and add the following values
This assumes you are using a free Galileo account. If you are using a custom deployment, then you will also need to add the URL of your Galileo Console:
.env
Create a chat client using the Galileo OpenAI wrapper
1
Create a file for your application called app.py or app.ts.
2
Add code to call OpenAI
Add the following code to your application file:
3
Run the app
prompt
, the output as the returned response
. The duration and number of tokens will also be logged.4
View the logged trace
From the Galileo Console, open the Log stream for your project. You will see a trace with a single span containing the logged function call.