BerriAI/litellm · warning · Exception
Promptlayer did not successfully log the response!
Error message
Promptlayer did not successfully log the response!
What it means
After POSTing a track-request payload to api.promptlayer.com, PromptLayer raises a generic Exception whenever the response JSON lacks success: true. This means the request reached PromptLayer but was rejected (auth, malformed body, or server-side failure) — it is not a network error, the HTTP layer succeeded.
Source
Thrown at litellm/integrations/prompt_layer.py:66
"https://api.promptlayer.com/rest/track-request",
json={
"function_name": "openai.ChatCompletion.create",
"kwargs": new_kwargs,
"tags": tags,
"request_response": dict(response_obj),
"request_start_time": int(start_time.timestamp()),
"request_end_time": int(end_time.timestamp()),
"api_key": self.key,
# Optional params for PromptLayer
# "prompt_id": "<PROMPT ID>",
# "prompt_input_variables": "<Dictionary of variables for prompt>",
# "prompt_version":1,
},
)
response_json: Final = request_response.json()
if not request_response.json().get("success", False):
raise Exception("Promptlayer did not successfully log the response!")
print_verbose(f"Prompt Layer Logging: success - final response object: {request_response.text}")
if "request_id" in response_json:
if metadata:
response: Final = litellm.module_level_client.post(
"https://api.promptlayer.com/rest/track-metadata",
json={
"request_id": response_json["request_id"],
"api_key": self.key,
"metadata": metadata,
},
)
print_verbose(f"Prompt Layer Logging: success - metadata post response object: {response.text}")
except Exception:
print_verbose(f"error: Prompt Layer Error - {traceback.format_exc()}")
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Verify PROMPTLAYER_API_KEY is the correct active key for the same workspace as any prompt ids used
- Log request_response.text just before the raise (or reproduce the POST in curl) to see PromptLayer's actual error message
- Remove unsupported optional fields (prompt_id / prompt_input_variables) from the payload and retry
- If the failure is transient, wrap the call and retry once with backoff
Example fix
# before
response_json = request_response.json()
if not request_response.json().get("success", False):
raise Exception("Promptlayer did not successfully log the response!")
# after — surface the upstream reason
if not response_json.get("success", False):
raise Exception(
f"PromptLayer logging failed (status={request_response.status_code}): "
f"{response_json.get('message', request_response.text)}"
) Defensive patterns
Strategy: retry
Validate before calling
import litellm
import os
assert os.getenv("PROMPTLAYER_API_KEY"), "PROMPTLAYER_API_KEY missing — PromptLayer logging will fail" Try / catch
for attempt in range(2):
try:
resp = litellm.completion(model="gpt-4o", messages=msgs)
break
except Exception as e:
if "Promptlayer did not successfully log" in str(e) and attempt == 0:
continue # transient PromptLayer rejection — retry once
raise Prevention
- Treat PromptLayer callback failures as non-fatal: wrap completion calls or run the callback in fire-and-forget mode so logging outages don't break inference
- Rotate the PromptLayer API key with the same discipline as provider keys and monitor its expiry
- Log the full upstream response body when debugging — PromptLayer puts the real reason in JSON other than success=false
When it happens
Trigger: Calling litellm with the prompt_layer callback while PROMPTLAYER_API_KEY is wrong/expired (key sent in the JSON body); prompt template references (prompt_id, prompt_input_variables) that do not match the account; PromptLayer API returning success: false for schema violations.
Common situations: Rotated or typo'd PromptLayer API keys; using a prompt id from a different workspace; PromptLayer API changes or transient 4xx/5xx that still return JSON with success false.
Related errors
- start_time is required, got={start_time} of type {type(start
- end_time is required, got={end_time} of type {type(end_time)
- usage is required, got={usage} of type {type(usage)}
- logging_obj is required
- logging_obj is required
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/24b2787f21deff78.
Report an issue: GitHub.