We recommend you to manage your AI prompts through Pezzo. This allows you to easily manage your prompts, and keep track of your AI requests. Click here to learn about Prompt Management in Pezzo.Below is an example of how you can use Pezzo to retrieve a prompt, and then use it to make a request to OpenAI.
Copy
Ask AI
// Fech prompt from Pezzo const prompt = await pezzo.getPrompt("PromptName"); // Provide the prompt as-is to OpenAI const response = await openai.chat.completions.create(prompt); // Or you can override specific properties if you wish const response = await openai.chat.completions.create({ ...prompt, model: "gpt-4", });
Congratulations! Youโve about to benefit from seamless prompt version management and request tracking. Your request will now be visible in the Requests page of your Pezzo project.
If you donโt want to manage your prompts through Pezzo, you can still use Pezzo to make requests to OpenAI and benefit from Pezzoโs Observability features.You will consume the make request to the OpenAI exactly as you normally would. The only difference is that you will use the PezzoOpenAI instance we created above. Here is an example:
Copy
Ask AI
const response = await openai.chat.completions.create({ model: "gpt-3.5-turbo", temperature: 0, messages: [ { role: "user", content: "Hey, how are you doing?", }, ],});
You should now be able to see your request in the Requests page of your Pezzo project.
The Pezzo client enhances your developer experience by providing additional functionality to the OpenAI API. This is done through the second argument of the createChatCompletion method.
You can specify variables that will be interpolated by the Pezzo client before sending the request to OpenAI. This is useful if you want to use the same prompt for multiple requests, but with different variables.
You can also specify custom properties that will be sent to Pezzo. This is useful if you want to add additional information to your request, such as the user ID, or the request ID. This information will be visible in the Requests page of your Pezzo project, and you will be able to filter requests based on these properties.
Utilizing request caching can sometimes save up to 90% on your API costs and execution time. You can enable cache by setting cache to true in the second argument of the createChatCompletion method.