Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/prompt-history/request-id.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ icon: "id-card"

Every PromptLayer log has a unique PromptLayer Request ID (`pl_id`).

All tracking in PromptLayer is based on the `pl_request_id`. This identifier is needed to enrich logs with [metadata](/features/prompt-history/metadata), [scores](/features/prompt-history/scoring-requests), [associated prompt templates](/features/prompt-history/tracking-templates), and more.
All tracking in PromptLayer is based on the `pl_request_id`. This identifier is needed to enrich logs with [metadata](/features/prompt-history/metadata), [scores](/features/prompt-history/scoring-requests), [associated prompt templates](/features/prompt-history/tracking-templates), and more. You can also use it to [retrieve the full request payload](/reference/get-request) as a prompt blueprint.

You can quickly grab a request ID from the web UI as shown below.

Expand Down
1 change: 1 addition & 0 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
{
"group": "Tracking",
"pages": [
"reference/get-request",
"reference/log-request",
"reference/track-prompt",
"reference/track-score",
Expand Down
119 changes: 119 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,125 @@
}
}
},
"/api/public/v2/request/{request_id}": {
"get": {
"summary": "Get Request",
"operationId": "getRequest",
"tags": [
"tracking"
],
"parameters": [
{
"name": "X-API-KEY",
"in": "header",
"required": true,
"schema": {
"type": "string"
},
"description": "API key for authentication."
},
{
"name": "request_id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"minimum": 1
},
"description": "The ID of the request to retrieve."
}
],
"responses": {
"200": {
"description": "Successfully retrieved request as a prompt blueprint.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"description": "Indicates the request was successful."
},
"prompt_blueprint": {
"type": "object",
"description": "The request converted to a prompt blueprint format.",
"properties": {
"prompt_template": {
"type": "object",
"description": "The prompt template with type and messages."
},
"metadata": {
"type": "object",
"description": "Metadata including model provider, name, and parameters."
},
"inference_client_name": {
"type": "string",
"nullable": true,
"description": "The inference client name if one was used."
}
}
},
"request_id": {
"type": "integer",
"description": "The ID of the request."
},
"provider": {
"type": "string",
"description": "The LLM provider (e.g. openai, anthropic)."
},
"model": {
"type": "string",
"description": "The model name (e.g. gpt-4, claude-3-sonnet)."
}
}
}
}
}
},
"401": {
"description": "Authentication failed.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"403": {
"description": "Invalid workspace.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"404": {
"description": "Request not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"500": {
"description": "Internal server error.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/public/v2/evaluations": {
"get": {
"summary": "List Evaluations",
Expand Down
60 changes: 60 additions & 0 deletions reference/get-request.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "Get Request"
openapi: "GET /api/public/v2/request/{request_id}"
description: "Retrieve a request's payload as a prompt blueprint."
---

Retrieve the full payload of a logged request by its ID, returned as a [prompt blueprint](/running-requests/prompt-blueprints). This is useful for:

- **Request replay**: Re-run a request with the same input and parameters
- **Debugging**: Inspect the exact prompt and model configuration used
- **Dataset creation**: Extract request data for use in evaluations

The response includes the prompt blueprint (input messages, model configuration, and parameters) along with the provider and model used.

### Authentication

This endpoint requires API key authentication via the `X-API-KEY` header, or JWT authentication via the `Authorization: Bearer` header.

### Example

```bash
curl -H "X-API-KEY: your_api_key" \
https://api.promptlayer.com/api/public/v2/request/12345
```

### Response

```json
{
"success": true,
"prompt_blueprint": {
"prompt_template": {
"type": "chat",
"messages": [
{
"role": "user",
"content": [{ "type": "text", "text": "Hello, world!" }]
}
]
},
"metadata": {
"model": {
"provider": "openai",
"name": "gpt-4",
"parameters": {}
}
},
"inference_client_name": null
},
"request_id": 12345,
"provider": "openai",
"model": "gpt-4"
}
```

### Related

- [Request IDs](/features/prompt-history/request-id) - How to obtain request IDs
- [Prompt Blueprints](/running-requests/prompt-blueprints) - Understanding the blueprint format
- [Log Request](/reference/log-request) - Log new requests
1 change: 1 addition & 0 deletions reference/rest-api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Here are the calls you can make via our REST API:

### Tracking

- [Get Request](/reference/get-request)
- [Log Request](/reference/log-request)
- [Track Prompt](/reference/track-prompt)
- [Track Score](/reference/track-score)
Expand Down