curl --request POST \
--url https://api.promptlayer.com/log-request \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"provider": "openai",
"model": "gpt-4o",
"api_type": "chat-completions",
"input": {
"type": "chat",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello!"
}
]
}
]
},
"output": {
"type": "chat",
"messages": [
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hi there! How can I help you?"
}
]
}
]
},
"request_start_time": "2024-01-15T10:30:00Z",
"request_end_time": "2024-01-15T10:30:05Z",
"tags": [
"production"
],
"metadata": {
"session_id": "abc123"
}
}
'{
"id": 12345,
"prompt_version": null,
"status": "SUCCESS",
"error_type": null,
"error_message": null
}Tracking
Log Request
POST
/
log-request
curl --request POST \
--url https://api.promptlayer.com/log-request \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"provider": "openai",
"model": "gpt-4o",
"api_type": "chat-completions",
"input": {
"type": "chat",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello!"
}
]
}
]
},
"output": {
"type": "chat",
"messages": [
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hi there! How can I help you?"
}
]
}
]
},
"request_start_time": "2024-01-15T10:30:00Z",
"request_end_time": "2024-01-15T10:30:05Z",
"tags": [
"production"
],
"metadata": {
"session_id": "abc123"
}
}
'{
"id": 12345,
"prompt_version": null,
"status": "SUCCESS",
"error_type": null,
"error_message": null
}Log a request made outside of PromptLayer’s managed run APIs. Use this endpoint for custom providers, background jobs, or direct LLM client calls that you still want to inspect, search, score, and replay in PromptLayer.
Behavior Notes
inputandoutputmust use Prompt Blueprint format.- Chat message
contentmust be an array of content blocks, not a plain string. - Provider-specific settings such as structured outputs, tools, tool choice, thinking, and reasoning should be recorded in the prompt blueprint or
parameterspayload. - Use
status,error_type, anderror_messageto log failed or degraded requests.
Related
Body
application/json
Request body for custom logging. Chat message content must be an array of content blocks, not a plain string.
Categorized error type.
| Value | Description | Allowed Statuses |
|---|---|---|
PROVIDER_RATE_LIMIT | Rate limit hit on provider API | WARNING, ERROR |
PROVIDER_QUOTA_LIMIT | Account quota or spending limit exceeded | WARNING, ERROR |
PROVIDER_PARTIAL_RESPONSE | Provider returned a successful response, but the saved output may be incomplete, filtered, blocked, malformed, or otherwise partial | WARNING |
VARIABLE_MISSING_OR_EMPTY | Required template variable was missing or empty | WARNING |
PROVIDER_TIMEOUT | Request timed out | ERROR |
PROVIDER_AUTH_ERROR | Authentication failed with provider | ERROR |
PROVIDER_ERROR | General provider-side error | ERROR |
TEMPLATE_RENDER_ERROR | Failed to render prompt template | ERROR |
UNKNOWN_ERROR | Uncategorized error | WARNING, ERROR |
Available options:
PROVIDER_TIMEOUT, PROVIDER_QUOTA_LIMIT, PROVIDER_RATE_LIMIT, PROVIDER_PARTIAL_RESPONSE, PROVIDER_AUTH_ERROR, PROVIDER_ERROR, TEMPLATE_RENDER_ERROR, VARIABLE_MISSING_OR_EMPTY, UNKNOWN_ERROR Response
Successful Response
Was this page helpful?

