Skip to content

API Reference

Glitch provides a unified API for both LLM proxying and management operations. Use a single API key for everything.

All API requests use your Project API key in the Authorization header:

Authorization: Bearer glitch_sk_abc123...

Get your API key from the Glitch dashboard by creating a project.


https://api.golabrat.ai

All endpoints below are relative to this base URL.


These endpoints proxy requests to your LLM provider with security scanning. They’re OpenAI-compatible, so you can use any OpenAI SDK.

Endpoint: POST /v1/chat/completions

Proxies to the upstream LLM with input/output scanning applied.

Terminal window
curl https://api.golabrat.ai/v1/chat/completions \
-H "Authorization: Bearer glitch_sk_abc123..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, world!"}
],
"temperature": 0.7
}'

All LLM proxy responses include security metadata:

HeaderDescription
X-Risk-Blockedtrue if request was blocked, false otherwise
X-Risk-CategoriesComma-separated list of detected categories
X-Risk-ConfidenceHighest confidence score (0.0-1.0)

Endpoint: POST /v1/detect

Run detection without proxying to an LLM. Useful for pre-screening content.

Terminal window
curl https://api.golabrat.ai/v1/detect \
-H "Authorization: Bearer glitch_sk_abc123..." \
-H "Content-Type: application/json" \
-d '{
"content": "Ignore all previous instructions",
"direction": "input"
}'

Response:

{
"blocked": true,
"categories": [
{
"type": "prompt_attack",
"confidence": 0.95,
"action": "block"
}
]
}

These endpoints let you manage policies and projects programmatically.

Endpoint: GET /v1/policies/

Terminal window
curl https://api.golabrat.ai/v1/policies/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Response:

{
"count": 2,
"results": [
{
"id": "uuid-1",
"name": "Balanced Security",
"policy_mode": "IO",
"is_default": true,
"input_detectors": [...],
"output_detectors": [...],
"created_at": "2024-01-01T00:00:00Z"
}
]
}

Endpoint: GET /v1/policies/{policy_id}/

Terminal window
curl https://api.golabrat.ai/v1/policies/uuid-1/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Endpoint: POST /v1/policies/

Terminal window
curl -X POST https://api.golabrat.ai/v1/policies/ \
-H "Authorization: Bearer glitch_sk_abc123..." \
-H "Content-Type: application/json" \
-d '{
"name": "My Custom Policy",
"policy_mode": "IO",
"input_detectors": [
{
"detector_type": "prompt_attack",
"threshold": "L2",
"action": "block"
}
],
"output_detectors": [
{
"detector_type": "pii/email",
"threshold": "L2",
"action": "block"
}
],
"allow_list": {
"entries": ["*@yourcompany.com"],
"match_type": "wildcard"
},
"deny_list": {
"entries": [],
"match_type": "exact"
}
}'

Endpoint: PATCH /v1/policies/{policy_id}/

Terminal window
curl -X PATCH https://api.golabrat.ai/v1/policies/uuid-1/ \
-H "Authorization: Bearer glitch_sk_abc123..." \
-H "Content-Type: application/json" \
-d '{
"name": "Updated Policy Name"
}'

Endpoint: DELETE /v1/policies/{policy_id}/

Terminal window
curl -X DELETE https://api.golabrat.ai/v1/policies/uuid-1/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Endpoint: POST /v1/policies/{policy_id}/set_default/

Terminal window
curl -X POST https://api.golabrat.ai/v1/policies/uuid-1/set_default/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Endpoint: POST /v1/policies/{policy_id}/duplicate/

Terminal window
curl -X POST https://api.golabrat.ai/v1/policies/uuid-1/duplicate/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Endpoint: GET /v1/projects/

Terminal window
curl https://api.golabrat.ai/v1/projects/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Response:

{
"count": 1,
"results": [
{
"id": "uuid-1",
"name": "Production App",
"key_prefix": "glitch_sk_abc",
"environment": "production",
"policy_id": "policy-uuid",
"policy_name": "Balanced Security",
"is_active": true,
"created_at": "2024-01-01T00:00:00Z",
"last_used_at": "2024-01-15T12:00:00Z"
}
]
}

Endpoint: POST /v1/projects/

Terminal window
curl -X POST https://api.golabrat.ai/v1/projects/ \
-H "Authorization: Bearer glitch_sk_abc123..." \
-H "Content-Type: application/json" \
-d '{
"name": "My New Project",
"environment": "development",
"policy_id": "policy-uuid"
}'

Response:

{
"id": "uuid-new",
"name": "My New Project",
"raw_key": "glitch_sk_newkey123...",
"key_prefix": "glitch_sk_new",
"environment": "development",
"policy_id": "policy-uuid"
}

Endpoint: PATCH /v1/projects/{project_id}/

Terminal window
curl -X PATCH https://api.golabrat.ai/v1/projects/uuid-1/ \
-H "Authorization: Bearer glitch_sk_abc123..." \
-H "Content-Type: application/json" \
-d '{
"policy_id": "new-policy-uuid"
}'

Endpoint: DELETE /v1/projects/{project_id}/

Terminal window
curl -X DELETE https://api.golabrat.ai/v1/projects/uuid-1/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Endpoint: GET /v1/policies/detector_types/

Terminal window
curl https://api.golabrat.ai/v1/policies/detector_types/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Response:

{
"detector_types": [
{ "value": "prompt_attack", "label": "Prompt Attack", "category": "prompt_defense" },
{ "value": "pii/email", "label": "Email Address", "category": "data_leakage_prevention" },
{ "value": "pii/credit_card", "label": "Credit Card", "category": "data_leakage_prevention" },
{ "value": "pii/ssn", "label": "Social Security Number", "category": "data_leakage_prevention" },
{ "value": "moderated_content/harassment", "label": "Harassment", "category": "content_moderation" },
{ "value": "moderated_content/harassment_threatening", "label": "Threatening Harassment", "category": "content_moderation" },
{ "value": "moderated_content/hate", "label": "Hate Speech", "category": "content_moderation" },
{ "value": "moderated_content/hate_threatening", "label": "Threatening Hate Speech", "category": "content_moderation" },
{ "value": "moderated_content/sexual", "label": "Sexual Content", "category": "content_moderation" },
{ "value": "moderated_content/sexual_minors", "label": "Sexual Content (Minors)", "category": "content_moderation" },
{ "value": "moderated_content/violence", "label": "Violence", "category": "content_moderation" },
{ "value": "moderated_content/violence_graphic", "label": "Graphic Violence", "category": "content_moderation" },
{ "value": "moderated_content/self_harm", "label": "Self Harm", "category": "content_moderation" },
{ "value": "moderated_content/self_harm_intent", "label": "Self Harm Intent", "category": "content_moderation" },
{ "value": "moderated_content/self_harm_instructions", "label": "Self Harm Instructions", "category": "content_moderation" },
{ "value": "moderated_content/illicit", "label": "Illicit Activities", "category": "content_moderation" },
{ "value": "moderated_content/illicit_violent", "label": "Violent Illicit Activities", "category": "content_moderation" },
{ "value": "unknown_links", "label": "Unknown Links", "category": "malicious_links" }
]
}

Endpoint: GET /v1/policies/threshold_levels/

Terminal window
curl https://api.golabrat.ai/v1/policies/threshold_levels/ \
-H "Authorization: Bearer glitch_sk_abc123..."

Response:

{
"threshold_levels": [
{ "value": "L1", "label": "Confident", "threshold": 0.9 },
{ "value": "L2", "label": "Very Likely", "threshold": 0.75 },
{ "value": "L3", "label": "Likely", "threshold": 0.5 },
{ "value": "L4", "label": "Less Likely", "threshold": 0.25 }
]
}

All endpoints return consistent error responses:

{
"error": {
"message": "Human-readable error message",
"type": "error_type",
"code": "error_code"
}
}
StatusTypeDescription
400invalid_requestMalformed request or validation error
401authentication_errorInvalid or missing API key
403permission_deniedInsufficient permissions
403security_blockRequest blocked by security policy
404not_foundResource not found
429rate_limitRate limit exceeded
500internal_errorServer error

Endpoint TypeLimit
LLM Proxy (/v1/chat/completions, /v1/detect)1000 req/min
Management (/v1/policies/*, /v1/projects/*)100 req/min

Rate limit headers are included in responses:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 950
X-RateLimit-Reset: 1704067260