PromptLayer's Python SDK: a hosted prompt registry wrapped in a Python client
🍰 PromptLayer - Maintain a log of your prompts and OpenAI API requests. Track, debug, and replay old completions.
At a glance
- What is it?
- The prompt-layer-library repository ships the Python SDK for PromptLayer, a hosted service for storing prompt templates and logging OpenAI and other provider requests. The SDK is a thin client for a paid API, so adoption means accepting a network dependency for prompt retrieval and trace export.
- Who is it for?
- Adopt the promptlayer SDK if your prompts already live in PromptLayer's hosted registry and you want request logging or OpenTelemetry trace export without writing the client yourself. Do not adopt it as a standalone local prompt store: every templates.get call reaches api.promptlayer.com unless you set cache_ttl_seconds above zero, and the SDK cannot serve a template on its own.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 27 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The problem is prompt drift across environments, not prompt authoring
Editing a prompt string inside application code means the prompt ships with the deploy. Changing one sentence in a system message requires a code review, a build, and a release. PromptLayer's answer is to move the template out of the repository and into a hosted registry, then fetch it at runtime by name. The README's quick start does exactly that: pl.templates.get("support-reply", {...}) returns a prompt_template field after the client substitutes input_variables such as customer_name and question. The audience is teams running LLM features in production who want prompt edits to be a data change rather than a deploy, and who also want a record of what was sent and what came back. The repository is the client half of that arrangement. The registry, the request log, and the evaluation UI live on promptlayer.com, which the repository lists as its homepage.
What the SDK actually does at runtime
Three mechanisms are visible in the README. First, template retrieval: client.templates exposes retrieval, listing, publishing, and cache invalidation, and the client accepts cache_ttl_seconds, which enables in-memory template caching when greater than zero. That default of zero means every get is a network round trip unless you change it. Second, provider proxies: pl.openai returns a wrapped OpenAI client, and the README's example passes pl_tags=["proxy-example"] alongside model and messages to a chat.completions.create call. The same pattern exists for client.anthropic. Calls made through the proxy are logged to PromptLayer, which is how request history accumulates without you writing logging code around each call. Third, tracing: with enable_tracing=True the SDK exports spans to PromptLayer over OpenTelemetry and auto-instruments installed OpenAI, Anthropic, Google GenAI, and AWS Bedrock SDKs when the tracing extra is present. The traceable() decorator covers functions you wrote yourself, so a retrieval step or a post-processing step can appear in the same trace as the model call. The data flow is one direction: your process sends prompts requests and spans outbound to the PromptLayer API, and receives template bodies back.
Getting it installed and configured
Installation is a single pip command: pip install promptlayer. Provider-specific integrations are extras, listed in the README as promptlayer[openai-agents] and promptlayer[claude-agents], and tracing has its own extra, promptlayer[otel-genai-instrumentation], which the README pairs with openai anthropic google-genai boto3 in one install line. The README states Python 3.9+ in its badge. Configuration is split between constructor arguments and environment variables. PromptLayer(api_key=...) and AsyncPromptLayer(api_key=...) accept api_key, enable_tracing, base_url, throw_on_error, cache_ttl_seconds, tracer_provider, and tracing_providers. If api_key is omitted the SDK reads PROMPTLAYER_API_KEY. PROMPTLAYER_BASE_URL overrides the API base URL and defaults to https://api.promptlayer.com, while PROMPTLAYER_OTLP_TRACES_ENDPOINT overrides the /v1/traces endpoint used when tracing is on. Two defaults deserve attention. throw_on_error defaults to True, so SDK methods raise PromptLayer exceptions rather than returning None for many API errors; flipping it to False changes your error handling everywhere at once. tracing_providers defaults to all supported providers, and the README notes that passing an empty iterable exports spans without provider SDK auto-instrumentation. There is also promptlayer setup, a CLI that writes skill files for Cursor and Claude Code and registers the Docs MCP server at https://docs.promptlayer.com/mcp, with variants setup skills, setup mcp, --agent flags, and --force.
The hosted dependency is the design, and the limitation
Nothing in the README describes a local mode. Templates are fetched from the PromptLayer service, requests are logged to it, and spans are exported to its OTLP endpoint. If api.promptlayer.com is unreachable, template retrieval fails unless the template is already in the in-memory cache, and that cache only exists when cache_ttl_seconds is greater than zero. The cache is in-memory, so a process restart clears it. For a batch job that runs once a day, that is a cold start against a remote service on every run. There is also a versioning gap in the supplied material: the repository lists no releases, and the README describes the SDK's surface without stating a version compatibility policy, so pinning promptlayer to a known-good version is a decision you make without guidance from the repository itself. The tracing path adds another moving part, since auto-instrumentation depends on the OpenTelemetry instrumentors bundled in the extra matching the provider SDK versions in your environment. When those drift, spans can go missing without the application failing loudly. Finally, the repository's own description, maintain a log of your prompts and OpenAI API requests, is narrower than the README's current framing around evals, tracing, and regression sets; the description looks stale relative to the documented feature set.
Where a local-first alternative fits better
If the goal is prompt versioning without a hosted registry, the comparison is a file-based approach such as storing templates as YAML or JSON in the repository and loading them with a small loader, optionally tracked with a tool like DVC or Git LFS for large artifacts. The difference is not cosmetic. A file-based loader has no network call on the hot path, no API key to distribute, and no third-party service in the request path; prompt changes go through the same review and deploy process as code. What it does not give you is a request log, a shared UI for non-engineers to edit prompts, or trace export. That is the actual trade: PromptLayer converts prompt editing into a data operation and adds observability, at the cost of an outbound dependency and a service account. A team whose prompt authors are engineers and whose prompts change weekly does not need the registry half. A team where a support lead edits the tone of a reply template, and where you need to answer why a specific completion looked wrong last Tuesday, is the case the hosted model is built for. The README's client.track resource, which annotates requests with metadata, prompt linkage, scores, and groups, has no equivalent in the file-based approach without building it.
Licence, maintenance, and what you inherit
The repository is Apache-2.0, which permits commercial use and modification and includes a patent grant, with the usual requirements around preserving notices and stating changes. That covers the SDK code in this repository. It does not cover the PromptLayer service, which is a separate commercial product with its own terms and pricing; the licence on the client tells you nothing about the cost or availability of the backend it talks to. That distinction is worth stating plainly because the two are easy to conflate when a repository and a product share a name. On maintenance, the repository shows a recent push date and is not archived, and the README documents a current feature set including the setup CLI and MCP integration. There are no releases in the supplied material, so upgrade cost cannot be assessed from version notes: you would be tracking the master branch or pinning by commit. For a dependency that sits on the request path of a production service, that is a real gap. This is not legal advice; the Apache-2.0 text governs the code, and your own counsel should review the service terms separately.
Who this is for
The SDK fits teams that have already decided prompts belong in a shared registry and want the Python client to be small. The synchronous and asynchronous clients mirror each other, every method has an async version per the README, and the resource list (templates, run, run_workflow, log_request, track, group, traceable, skills, tables.sheets.scorecards, and the provider proxies) maps to distinct jobs rather than one overloaded entry point. If you are running OpenAI, Anthropic, Google GenAI, or Bedrock calls and want them logged and traced with a few lines of configuration, the auto-instrumentation path is the shortest route the documentation offers. If you are evaluating this repository as a self-contained prompt library, read the quick start again: the first code block constructs a client with an API key and fetches a template by name from a remote service. That is the shape of the project, and the rest of the SDK is built around it.
Editorial conclusion
Adopt the promptlayer SDK if your prompts already live in PromptLayer's hosted registry and you want request logging or OpenTelemetry trace export without writing the client yourself. Do not adopt it as a standalone local prompt store: every templates.get call reaches api.promptlayer.com unless you set cache_ttl_seconds above zero, and the SDK cannot serve a template on its own. Before committing, verify three things in your own environment: that pip install promptlayer resolves on your Python version against the 3.9+ claim in the README, that your API key and PROMPTLAYER_BASE_URL point at the endpoint you intend, and that the OpenTelemetry instrumentors in the otel-genai-instrumentation extra cover the provider SDK versions you already run.
Community notes