Skip to main content

Akto

Overview​

Akto provides monitoring and guardrails for AI/ML workloads.

The Akto guardrail supports two modes:

  • pre_call — validates requests and blocks if flagged (sync)
  • logging_only — non-blocking ingestion of request+response for monitoring (async)

Use them together for full protection, or logging_only alone for monitor-only mode.

1. Get Your Akto Credentials​

Set up the Akto Guardrail API Service and grab:

  • AKTO_GUARDRAIL_API_BASE — your Guardrail API Base URL
  • AKTO_API_KEY — your API key

2. Configure in config.yaml​

A single guardrail entry with both modes. Requests are validated before the LLM call, and allowed traffic is ingested after the response.

guardrails:
- guardrail_name: "akto-guardrail"
litellm_params:
guardrail: akto
mode: [pre_call, logging_only]
akto_base_url: os.environ/AKTO_GUARDRAIL_API_BASE
akto_api_key: os.environ/AKTO_API_KEY
default_on: true
unreachable_fallback: fail_closed # optional: fail_open | fail_closed (default: fail_closed)
guardrail_timeout: 5 # optional, default: 5
akto_account_id: "1000000" # optional, env fallback: AKTO_ACCOUNT_ID
akto_vxlan_id: "0" # optional, env fallback: AKTO_VXLAN_ID

Monitor-only mode​

No blocking — just ingest all traffic for monitoring.

guardrails:
- guardrail_name: "akto-monitor"
litellm_params:
guardrail: akto
mode: logging_only
akto_base_url: os.environ/AKTO_GUARDRAIL_API_BASE
akto_api_key: os.environ/AKTO_API_KEY
default_on: true

3. Test It​

curl -i http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your litellm key>" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}'

If a request gets blocked:

{
"error": {
"message": "Blocked by Akto Guardrails",
"type": "None",
"param": "None",
"code": "403"
}
}

4. How It Works​

Block + Ingest mode (pre_call + logging_only):

Request → LiteLLM → Akto guardrail check (pre_call, awaited)
→ Allowed → LLM call → response → Akto ingest (logging_only, fire-and-forget)
→ Blocked → Akto ingest blocked marker (fire-and-forget) → 403 error

Monitor-only mode (logging_only):

Request → LiteLLM → LLM call → response → Akto ingest (fire-and-forget)

5. Event behavior​

ModeLiteLLM hookAkto callBlocking
pre_callapply_guardrailAwaited: guardrails=true, ingest_data=falseYes
logging_onlyasync_log_success_eventFire-and-forget: guardrails=false, ingest_data=trueNo
  • Blocked requests produce one fire-and-forget ingest with statusCode: 403.
  • Allowed requests produce one fire-and-forget ingest with request + response.
  • No duplicate messages — each request produces exactly one ingestion call.

6. Parameters​

ParameterEnv VariableDefaultDescription
akto_base_urlAKTO_GUARDRAIL_API_BASErequiredAkto Guardrail API Base URL
akto_api_keyAKTO_API_KEYrequiredAPI key (sent as Authorization header)
akto_account_idAKTO_ACCOUNT_ID1000000Akto account id included in payload
akto_vxlan_idAKTO_VXLAN_ID0Akto vxlan id included in payload
unreachable_fallback—fail_closedfail_open or fail_closed
guardrail_timeout—5Timeout in seconds for pre_call validation
default_on—true (recommended)Enables the guardrail by default

7. Error Handling​

Scenariofail_closed (default)fail_open
Akto unreachableBlocked (503)Passes through
Akto returns errorBlocked (503)Passes through
Guardrail says blockedBlocked (403)Blocked (403)
🚅
LiteLLM Enterprise
SSO/SAML, audit logs, spend tracking, multi-team management, and guardrails — built for production.
Learn more →