Python
To get started, create an account by clicking “Log in” on PromptLayer. Once logged in, click the button to create an API key and save this in a secure location (Guide to Using Env Vars).
Once you have that all set up, install PromptLayer using pip
.
PromptLayer python library has support for both OpenAI and Anthropic LLMs!
Set up a PromptLayer client in your python file.
Optionally, you can specify the API key in the client.
OpenAI
In the Python file where you use OpenAI APIs, add the following. This allows us to keep track of your requests without needing any other code changes.
You can then use openai
as you would if you had imported it directly.
There is only one difference… PromptLayer allows you to add tags through the pl_tags
argument. This allows you to track and group requests in the dashboard.
Tags are not required but we recommend them!
After making your first few requests, you should be able to see them in the PromptLayer dashboard!
Here is a complete code snippet:
Anthropic
Using Anthropic with PromptLayer is very similar to how to one would use OpenAI.
Below is an example code snippet of the one line replacement:
Here is how it would look like on the dashbaord:
Want to say hi 👋 , submit a feature request, or report a bug? ✉️ Contact us
Was this page helpful?