LiteLLM
Connect Akto with LiteLLM
Overview
Prerequisites
Steps to Connect
1
2
3
4
Ensure Hook File is Accessible
# Set environment variables
export LITELLM_URL=http://your-litellm-instance-url
export DATA_INGESTION_SERVICE_URL=http://data-ingestion-service-url
export SYNC_MODE=true
# Start LiteLLM
litellm --config config.yamlservices:
litellm:
image: docker.litellm.ai/berriai/litellm:main-stable
volumes:
- ./config.yaml:/app/config.yaml
- ./custom_hooks.py:/app/custom_hooks.py
environment:
- LITELLM_URL=${LITELLM_URL}
- DATA_INGESTION_SERVICE_URL=${DATA_INGESTION_SERVICE_URL}
- SYNC_MODE=${SYNC_MODE}
# ... rest of config ...5
6
Verify Integration
# Check logs for hook initialization
docker-compose logs litellm | grep GuardrailsHandler
# Expected output:
# GuardrailsHandler initialized | sync_mode=True, timeout=5curl -X POST http://localhost:4000/chat/completions \
-H "Authorization: Bearer YOUR_LITELLM_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'How It Works
Request Flow (SYNC_MODE=true)
Request Flow (SYNC_MODE=false)
Get Support for your Akto setup
Last updated