Registry / llm-agents / promptlayer

promptlayer

JSON →
library1.4.6pypypi✓ verified 86d ago

PromptLayer is a platform for prompt engineering and tracking LLM requests. It provides middleware to log, debug, and analyze prompts for OpenAI, Anthropic, and other providers. Current version 1.4.3, actively maintained with regular releases.

pip install promptlayer
INSTALL
IMPORT
SIG · PROMPTLAYER
P
promptlayer
llm-agentspythonv1.4.6
Install
7.2s avg
Import
1405ms
Disk
48MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.624s · 46.2MB
glibc
py 3.103.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
Debug
Known issues
breakingIn version 1.0, the default import changed. Previously `import promptlayer` would patch modules automatically; now you must explicitly use the wrapper classes (e.g., PromptLayerOpenAI) or call `promptlayer.openai.patch()`.
fix
Use `from promptlayer.openai import PromptLayerOpenAI` and instantiate it, or call `promptlayer.openai.patch()` after import.
affects: >=1.0.0
deprecatedThe method `promptlayer.openai.patch()` is deprecated. Direct class instantiation is preferred.
fix
Use `PromptLayerOpenAI` wrapper class instead of patching.
affects: >=1.0.0
gotchaThe `api_key` must be set for PromptLayer to log requests. If not set, requests will fail silently or raise an error depending on the version.
fix
Set `promptlayer.api_key = 'your_api_key'` or export `PROMPTLAYER_API_KEY` environment variable.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'promptlayer'
PromptLayer not installed or installed in wrong environment.
fix
Run `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).
fix
Upgrade 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.
fix
Set `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.

Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
promptlayer — pip install promptlayer · libregistry