Install & Compatibility
Where this runs
tested against v1.4.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.624s · 46.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.2s · import 1.186s · 49MB
48MB installed
● package 48MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
promptlayer
✓ import promptlayer
The main module is imported directly; no submodule needed.
PromptLayerOpenAI
✓ from promptlayer.openai import PromptLayerOpenAI
✗ from promptlayer import PromptLayerOpenAI
PromptLayerOpenAI is a class in the openai submodule, not top-level.
Initializes PromptLayer, sets API key, and uses the PromptLayerOpenAI client to track an OpenAI call.
import promptlayer
# Initialize PromptLayer with your API key
promptlayer.api_key = os.environ.get('PROMPTLAYER_API_KEY', '')
# Wrap OpenAI client for tracking
from promptlayer.openai import PromptLayerOpenAI
import openai
# Option 1: Use PromptLayerOpenAI client directly
client = PromptLayerOpenAI(api_key=os.environ.get('OPENAI_API_KEY', ''), pl_tags=['test'])
response = client.chat.completions.create(
model='gpt-3.5-turbo',
messages=[{'role': 'user', 'content': 'Hello!'}]
)
print(response.choices[0].message.content)
# Option 2: Patch the default OpenAI module (deprecated in v1.0)
# promptlayer.openai.patch()
# response = openai.ChatCompletion.create(...)
promptlayer --version
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'promptlayer'
PromptLayer not installed or installed in wrong environment.
fixRun `pip install promptlayer` in your current Python environment.
AttributeError: module 'promptlayer' has no attribute 'openai'
Outdated version of promptlayer that does not have the openai submodule (pre-1.0).
fixUpgrade promptlayer: `pip install --upgrade promptlayer`
InvalidRequestError: API key not provided. Set your PromptLayer API key via promptlayer.api_key or environment variable.
PromptLayer API key missing.
fixSet `promptlayer.api_key = 'your_key'` or export `PROMPTLAYER_API_KEY` environment variable.
Upgrade
Version history
1.4.6latest on PyPI · released Jun 1, 2026
Audit
Dependencies
No dependency data recorded yet.