Install LiteLLM
-
Clone LiteLLM repo
-
Save LiteLLM directory in an environment variable
-
Create IRSA dependencies for LiteLLM
First, create IAM policy:
envsubst < $BEDROCK_LITELLM_DIR/iam/litellm-bedrock-policy.json > /tmp/litellm-bedrock-policy.json export LITELLM_BEDROCK_IAM_POLICY_ARN=$(aws iam create-policy \ --policy-name litellm-bedrock-policy \ --policy-document file:///tmp/litellm-bedrock-policy.json \ --output text \ --query "Policy.Arn") echo "export LITELLM_BEDROCK_IAM_POLICY_ARN=${LITELLM_BEDROCK_IAM_POLICY_ARN}" | tee -a ~/.bash_profile
Then, create IRSA setup:
-
Install LiteLLM
Note
LiteLLM helm chart is currently BETA, hence K8s manifests were used for installation. The snippet below will be changed once the helm chart is GAed.
Note
Make sure to change
LITELLM_MASTER_KEY
in$LITELLM_DIR/deploy/kubernetes/kub.yaml
to a random string rather than using the default API key, specially if you will expose LiteLLM endpoint externally.yq -i '.spec.template.spec.serviceAccount= "litellm-sa"' $LITELLM_DIR/deploy/kubernetes/kub.yaml yq -i 'del(.spec.template.spec.containers[0].env[] | select(.name == "DATABASE_URL") )' $LITELLM_DIR/deploy/kubernetes/kub.yaml yq -i '.spec.type= "ClusterIP"' $LITELLM_DIR/deploy/kubernetes/service.yaml kubectl create configmap litellm-config --from-file=$BEDROCK_LITELLM_DIR/litellm/config/proxy_config.yaml kubectl apply -f $LITELLM_DIR/deploy/kubernetes/kub.yaml kubectl apply -f $LITELLM_DIR/deploy/kubernetes/service.yaml
-
Allow acess to Bedrock models by following the steps in this doc page.
-
Ensure that LiteLLM pods are up and running
-
Verify LiteLLM
kubectl run curl --image=curlimages/curl --rm -it -- /bin/sh curl --location "http://litellm-service.default.svc.cluster.local:4000/chat/completions" \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer sk-1234' \ --data '{ "model": "bedrock-llama3-8b-instruct-v1", "messages": [ { "role": "user", "content": "what llm are you" } ] }'