Install PromptLayer
Thepromptlayer package is required to use PromptLayer with OpenAI. Install promptlayer using pip.
Imports
Set the Environment API Key
You can create a PromptLayer API Key at www.promptlayer.com by clicking the settings cog in the navbar. Set it as an environment variable calledPROMPTLAYER_API_KEY.
Use the PromptLayerOpenAI LLM like normal
You can optionally pass inpl_tags to track your requests with PromptLayer’s tagging feature.
Using PromptLayer Track
If you would like to use any of the PromptLayer tracking features, you need to pass the argumentreturn_pl_id when instantiating the PromptLayer LLM to get the request id.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.