Skip to main content
Documentation
API Reference

Error Codes

All Laghav API errors return a consistent JSON body with a machine-readable code, human message, request ID, and docs URL.

Error response shape

error.json
{
error: "Human-readable message explaining what went wrong",
code: "MACHINE_READABLE_CODE",
request_id: "lgh_req_abc123",
docs_url: "https://docs.laghav.ai/errors/MACHINE_READABLE_CODE"
}

Complete error code reference

HTTPCodeDescriptionResolution
400INVALID_MESSAGESmessages array malformed or emptyCheck that messages is a non-empty array of {role, content} objects
400MESSAGES_TOO_LARGECombined input > 100K tokensChunk your input or reduce context window
400INVALID_MODELUnknown model nameSee the Supported Models list
400INPUT_TOO_LARGEPlayground input > 5000 charsTrim input for playground; use /v1/complete for large inputs
401UNAUTHORIZEDMissing Authorization headerAdd Authorization: Bearer lgh_live_xxx header
401INVALID_KEYAPI key not foundVerify key in dashboard → Settings → API Keys
401KEY_REVOKEDAPI key was revokedCreate a new key in the dashboard
403PLAN_FEATURE_LOCKEDFeature not on current planUpgrade plan; see /pricing
403PROTOCOL_BLOCKEDRequest blocked by company protocolReview your governance protocol rules
403BUDGET_EXCEEDEDTeam monthly budget cap reachedIncrease budget or wait for monthly reset
429RATE_LIMIT_EXCEEDEDToo many requests per minuteRetry after X-RateLimit-Reset timestamp
429MONTHLY_LIMIT_REACHEDMonthly call quota exhaustedUpgrade plan to restore access
429PLAYGROUND_LIMIT_EXCEEDEDDaily playground limit reachedSign up for free account (50/day)
502PROVIDER_ERRORLLM provider returned an errorCheck provider status; retry
503COMPRESSOR_UNAVAILABLECompression service is downSet compress: false as fallback; check status.laghav.ai
504PROVIDER_TIMEOUTLLM provider took > 30sRetry; may indicate provider outage

Handling errors in Python

errors.py
from laghav import LaghavClient
from laghav.errors import (
RateLimitError,
BudgetExceededError,
PlanFeatureLockedError,
ProviderError,
LaghavError,
)
client = LaghavClient()
try:
response = client.complete(messages=[...], model="auto")
except RateLimitError as e:
print(f"Rate limited. Retry after: {e.retry_after}s")
except BudgetExceededError as e:
print(f"Team budget exceeded: {e.budget_id}")
# Notify team admin
except PlanFeatureLockedError as e:
print(f"Feature not on current plan: {e.feature}")
print(f"Upgrade at: {e.upgrade_url}")
except ProviderError as e:
print(f"LLM provider error: {e.provider} — {e.message}")
# Retry with exponential backoff
except LaghavError as e:
# All other Laghav errors
print(f"Code: {e.code}")
print(f"Message: {e.message}")
print(f"Request ID: {e.request_id}")
print(f"Docs: {e.docs_url}")