Python toolkit from Weights & Biases for tracing and evaluating AI agents and LLM applications.
MagnivOrg/prompt-layer-library
Python SDK for PromptLayer, logging, versioning, tracing and evaluating prompts and LLM requests across OpenAI, Anthropic and other providers.
Open-source alternative to:LangSmith
- Stars
- 786
- Forks
- 99
- Open issues
- 26
- Last commit
- 8 days ago
What is it?
PromptLayer is a Python SDK for managing prompts and LLM traffic. It fetches versioned prompt templates from PromptLayer and renders them with input variables, and it can act as a drop-in proxy around the OpenAI and Anthropic clients so every request is logged.
With tracing enabled, the SDK exports OpenTelemetry spans to PromptLayer and auto-instruments installed OpenAI, Anthropic, Google GenAI and AWS Bedrock clients. It also provides helpers for manual request logging, running prompts and workflows, and a decorator for tracing your own functions. Async clients mirror the synchronous API.
The SDK includes table scorecard APIs for configuring evaluation criteria, recalculating results and fetching per-row breakdowns, plus optional integrations for the openai-agents and claude-agent-sdk packages. An in-memory template cache with stale fallback is available as an opt-in setting.
Key features
- 01Fetches versioned prompt templates and renders them with input variables.
- 02Proxies OpenAI and Anthropic clients so requests are logged to PromptLayer.
- 03Exports OpenTelemetry traces with auto-instrumentation for several provider SDKs.
- 04Offers scorecard APIs for configuring, recalculating and inspecting evaluation results.
- 05Provides sync and async clients with matching methods.
Use cases
- Keeping prompt templates versioned and fetching them at runtime instead of hardcoding them.
- Logging and debugging OpenAI or Anthropic requests in an existing Python application.
- Tracing LLM calls and custom functions to monitor production behavior.
- Running regression-style evaluations on prompt outputs stored in PromptLayer tables.
Quick start
- 1
Install the SDK with pip
pip install promptlayer - 2
Create a client with your API key and fetch a prompt template
- 3
Optionally install the OpenTelemetry tracing extra with provider SDKs
pip install "promptlayer[otel-genai-instrumentation]" openai anthropic google-genai boto3
Things to know
- You need a PromptLayer account and API key to use most features.
- Full auto-instrumentation of provider SDKs requires Python 3.10 or newer.
In collections
Topics
FAQ
- What is prompt-layer-library?
- Python SDK for PromptLayer, logging, versioning, tracing and evaluating prompts and LLM requests across OpenAI, Anthropic and other providers. PromptLayer is a Python SDK for managing prompts and LLM traffic. It fetches versioned prompt templates from PromptLayer and renders them with input variables, and it can act as a drop-in proxy around the OpenAI and Anthropic clients so every request is logged.
- Is prompt-layer-library free to use? What license does it have?
- prompt-layer-library is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is prompt-layer-library still maintained?
- Actively maintained. The last commit to prompt-layer-library was on Oct 29, 2026.
- What can I use prompt-layer-library for?
- Keeping prompt templates versioned and fetching them at runtime instead of hardcoding them. Logging and debugging OpenAI or Anthropic requests in an existing Python application. Tracing LLM calls and custom functions to monitor production behavior. Running regression-style evaluations on prompt outputs stored in PromptLayer tables.
- How do I install prompt-layer-library?
- Install the SDK with pip: pip install promptlayer Create a client with your API key and fetch a prompt template Optionally install the OpenTelemetry tracing extra with provider SDKs: pip install "promptlayer[otel-genai-instrumentation]" openai anthropic google-genai boto3
- Where can I get prompt-layer-library?
- The source code and installation instructions are on GitHub: https://github.com/MagnivOrg/prompt-layer-library
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A suite of developer tools for building, testing, evaluating and deploying LLM-based applications, with a VS Code flow designer and a pf CLI.
A TypeScript library of typed building blocks (prompts, LLM providers, parsers, executors) for building LLM-powered functions.
Open-source platform for tracing, testing, routing and governing LLM calls, agents and coding assistants across a company.
Open source LLM engineering platform for tracing, evaluating, managing prompts, and debugging LLM applications, self-hostable.
Open-source LLM observability and evaluation platform for tracing AI agents, scoring LLM outputs, managing prompts, and monitoring production.