npm.
OpenAI
In the JavaScript file where the OpenAI APIs are integrated, include the following lines. They enable PromptLayer to track your requests without additional code modifications.openai as you would if you had imported it directly.
Your OpenAI API Key is never sent to our servers. All OpenAI requests are
made locally from your machine, PromptLayer just logs the request.
Adding PromptLayer tags: pl_tags
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!
Returning request id: return_pl_id
PromptLayer provides an option to retrieve the request id using the return_pl_id argument. When set to true, it returns a tuple where the second element is the request id.
TypeScript
The PromptLayer JavaScript library also supports TypeScript. You can type cast theOpenAI class to typeof BaseOpenAI to get the correct typings.
pl_tags and return_pl_id with TypeScript. You will need to add the @ts-ignore comment to ignore the TypeScript error.
pl_tags and return_pl_id arguments are not part of the OpenAI API.
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:
Want to say hi 👋 , submit a feature request, or report a bug? ✉️ Contact us

