SKILL.md
PromptLayer Skill
Product summary
PromptLayer is a platform for managing prompts, workflows, and evaluations outside your application code. It provides a Prompt Registry for versioning and releasing prompts with labels (e.g., "prod", "staging"), observability tools for logging and tracing LLM requests, Tables for running evaluations and batch jobs, and Workflows for building multi-step AI systems with conditional logic. Use the Python SDK (pip install promptlayer) or JavaScript SDK (npm install promptlayer) to fetch prompts and log requests. Authenticate with X-API-Key header or environment variable PROMPTLAYERAPIKEY. Primary docs: https://docs.promptlayer.com
When to use
- Prompt management: Create, version, and release prompts without code changes using release labels
- Observability: Log and trace LLM requests, associate them with prompt templates, add tags and metadata for filtering
- Evaluations: Build Tables with datasets, run prompts against test cases, score outputs with custom logic or LLM-as-judge
- Workflows: Build multi-step AI systems combining prompts, code, conditionals, loops, and external API calls
- Batch operations: Import request history or CSV data, run prompts across rows, compare model outputs, backtest changes
- Tool management: Define reusable tools in the Tool Registry, reference them in prompts, enable auto-execution
- Team collaboration: Share prompts for review, track version history, manage workspace access and roles
Quick reference
SDK initialization
from promptlayer import PromptLayer
client = PromptLayer(api_key="pl_your_key")
import { PromptLayer } from "promptlayer";
const client = new PromptLayer({ apiKey: "pl_your_key" });
Core methods
| Task |
Python |
JavaScript |
| Run a prompt |
client.run(promptname="...", inputvariables={...}) |
await client.run({promptName: "...", inputVariables: {...}}) |
| Get template |
client.templates.get("name", {"label": "prod"}) |
await client.templates.get("name", {label: "prod"}) |
| Log request |
client.log_request(provider="openai", model="...", input={...}, output={...}) |
await client.log_request({provider: "openai", model: "...", ...}) |
| Run workflow |
client.runworkflow(workflowidorname="...", input_variables={...}) |
await client.run_workflow({workflowIdOrName: "...", inputVariables: {...}}) |
| Track score |
client.track.score(request_id, score) |
await client.track.score(requestId, score) |
| Track metadata |
client.track.metadata(request_id, {"key": "value"}) |
await client.track.metadata(requestId, {key: "value"}) |
REST API endpoints
| Resource |
Key endpoints |
| Prompts |
GET /templates, POST /templates/publish, PATCH /templates, GET /templates/{id}/labels |
| Requests |
GET /requests/{id}, POST /log-request, GET /search-request-logs |
| Workflows |
GET /workflows, POST /workflows, POST /workflows/{id}/run |
| Tables |
POST /tables, GET /tables/{id}, POST /tables/{id}/sheets, POST /sheets/{id}/rows |
| Traces |
GET /traces/{id}, POST /spans-bulk |
Template variables
Use f-string or Jinja2 syntax in prompts:
f-string: "Hello {{name}}, you have {{count}} messages"
Jinja2: "Hello {{ name }}, you have {{ count }} messages"
Release labels
Assign labels to prompt versions for deployment without code changes:
# Fetch with label
response = client.run(
prompt_name="my-prompt",
prompt_release_label="prod" # or "staging", "beta_users"
)
Observability enrichment
Add context to requests:
response = client.run(
prompt_name="my-prompt",
input_variables={...},
tags=["experiment-1", "user-test"],
metadata={"user_id": "123", "session": "abc"}
)
Decision guidance
| Scenario |
Use |
Why |
| Fetch and run a prompt |
client.run() |
Simplest path; fetches template, executes, logs in one call |
| Custom LLM client |
client.log_request() |
Use your own OpenAI/Anthropic client, log manually after |
| Supported provider SDK |
SDK auto-instrumentation |
Automatic tracing without code changes; see /features/observability/traces/auto-instrumentation |
| Unsupported provider |
Manual tracing or OpenTelemetry |
Use PromptLayer.run() spans or send OTLP traces |
| Simple evaluation |
Tables with LLM-as-judge column |
Fast setup; AI scores outputs against criteria |
| Complex evaluation |
Tables with custom code column |
Write Python/JavaScript scoring logic; supports matrices and sub-scores |
| Multi-step AI system |
Workflows |
Combine prompts, code, conditionals, loops; visual editor or API |
| Prompt A/B testing |
Dynamic Release Labels |
Split traffic between versions; analyze performance per variant |
| Batch processing |
Tables with import + computed columns |
Import CSV or request history; run prompts across rows |
Workflow
1. Create and manage a prompt
- Go to PromptLayer dashboard → New → Prompt
- Name the prompt (e.g.,
my-classifier)
- Write messages with template variables:
{{variable_name}}
- Set model and parameters
- Click Save Template to create version 1
- Test in Playground with sample inputs
- Hover over version → Add Release Label → enter
prod
- Code now fetches with
client.run(promptname="my-classifier", promptrelease_label="prod")
2. Log and observe requests
- Initialize client with API key
- Call
client.run() or client.log_request() with tags and metadata
- Go to Logs in dashboard, search by prompt name or tag
- Click a log to inspect input, output, tokens, cost, latency
- Use Search to filter by date, metadata, or content
- Use Analytics to aggregate (e.g., avg latency by model)
3. Build an evaluation
- Create a Table → Create from a prompt or Import request history
- Add text columns for inputs, expected outputs, metadata
- Add a computed column → Prompt Template → select your prompt
- Add a scoring column → LLM-as-judge or Custom code
- Configure scoring criteria (e.g., "Output contains required sections")
- Click Run to execute prompts and score all rows
- Review History to compare versions; use Analytics to track scores over time
4. Build a workflow
- Go to New → Workflow
- Drag nodes onto canvas: Prompt Template, Code, Conditional, For Loop, etc.
- Connect nodes with edges; add conditionals for branching
- Mark final node as Output Node
- Click Save to create version 1
- Add release label (e.g.,
prod)
- Run with
client.runworkflow(workflowidorname="...", input_variables={...})
- View execution trace in Traces menu
5. Integrate with CI/CD
- Create an evaluation pipeline (Table with scoring)
- When saving a prompt version, select the evaluation pipeline
- Each new version auto-runs the eval; scores appear in version history
- Use webhooks (
prompttemplateversioncreated, prompttemplatelabelmoved) to trigger external CI/CD
Common gotchas
- API key not set: Ensure
PROMPTLAYERAPIKEY environment variable or pass api_key to client. Requests fail silently if missing.
- Provider API keys required: Set
OPENAIAPIKEY, ANTHROPICAPIKEY, etc. as environment variables. PromptLayer never sends these to its servers; calls are made locally.
- Template variable mismatch: If prompt expects
{{name}} but you pass inputvariables={"username": "..."}, rendering fails. Variable names must match exactly.
- Release label not found: If you reference a label that doesn't exist, the API returns the latest version. Always verify the label is attached to the intended version.
- Stale cells in Tables: After changing a computed column's source, cells marked "stale" won't recalculate automatically. Click Run or use the API to trigger recalculation.
- Scoring requires consistent types: All cells in a score column must be boolean or all numeric. Mixed types break scoring.
- Workflow node dependencies: If a node depends on another's output, ensure the dependency is listed. Circular dependencies are rejected.
- Trace closed: Once a trace is marked closed (via
close_after=true in OTLP), no new spans can be added. Plan trace closure carefully.
- Custom logging format:
log_request() requires input and output in Prompt Blueprint format (chat messages as arrays, not strings).
- Deprecated endpoints: Datasets and Evaluations APIs are deprecated. Use Tables API for new workflows.
Verification checklist
Before submitting work with PromptLayer:
Resources
For additional documentation and navigation, see: https://docs.promptlayer.com/llms.txt