The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
passing in masster key for api calls
yuneng-jianga3ff9030edf9
diff --git a/.github/workflows/test_server_root_path.yml b/.github/workflows/test_server_root_path.ymlindex fa57491db39..9a13494b482 100644--- a/.github/workflows/test_server_root_path.yml+++ b/.github/workflows/test_server_root_path.yml@@ -13,8 +13,7 @@ jobs:strategy:matrix:- # Test multiple root paths to ensure flexibility- root_path: ["/api/v1", "/litellm", "/proxy"]+ root_path: ["/api/v1"]steps:- name: Checkout repository@@ -79,128 +78,147 @@ jobs:ROOT_PATH="${{ matrix.root_path }}"echo "Testing health endpoint at: http://localhost:4000${ROOT_PATH}/health"- response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000${ROOT_PATH}/health")-- if [ "$response" = "200" ]; then- echo "✅ Health endpoint returned 200"- else- echo "❌ Health endpoint returned $response (expected 200)"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/health")+ if [ "$response" = "200" ]; then+ echo "✅ Health endpoint returned 200"+ exit 0+ fi+ echo "Attempt $i/3 - got $response, retrying in 5s..."+ sleep 5+ done+ echo "❌ Health endpoint returned $response (expected 200)"+ docker logs litellm-test+ exit 1- name: Test health endpoint liveliness with root pathrun: |ROOT_PATH="${{ matrix.root_path }}"echo "Testing liveliness endpoint at: http://localhost:4000${ROOT_PATH}/health/liveliness"- response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000${ROOT_PATH}/health/liveliness")-- if [ "$response" = "200" ]; then- echo "✅ Liveliness endpoint returned 200"- else- echo "❌ Liveliness endpoint returned $response (expected 200)"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/health/liveliness")+ if [ "$response" = "200" ]; then+ echo "✅ Liveliness endpoint returned 200"+ exit 0+ fi+ echo "Attempt $i/3 - got $response, retrying in 5s..."+ sleep 5+ done+ echo "❌ Liveliness endpoint returned $response (expected 200)"+ docker logs litellm-test+ exit 1- name: Test health endpoint readiness with root pathrun: |ROOT_PATH="${{ matrix.root_path }}"echo "Testing readiness endpoint at: http://localhost:4000${ROOT_PATH}/health/readiness"- response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000${ROOT_PATH}/health/readiness")-- if [ "$response" = "200" ]; then- echo "✅ Readiness endpoint returned 200"- else- echo "❌ Readiness endpoint returned $response (expected 200)"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/health/readiness")+ if [ "$response" = "200" ]; then+ echo "✅ Readiness endpoint returned 200"+ exit 0+ fi+ echo "Attempt $i/3 - got $response, retrying in 5s..."+ sleep 5+ done+ echo "❌ Readiness endpoint returned $response (expected 200)"+ docker logs litellm-test+ exit 1- name: Test UI is accessible with root pathrun: |ROOT_PATH="${{ matrix.root_path }}"echo "Testing UI endpoint at: http://localhost:4000${ROOT_PATH}/ui"- # Test that UI returns 200 or 30x (redirect)- response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000${ROOT_PATH}/ui")-- if [[ "$response" =~ ^(200|30[0-9])$ ]]; then- echo "✅ UI endpoint returned $response"- else- echo "❌ UI endpoint returned $response (expected 200 or 30x)"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/ui")+ if [[ "$response" =~ ^(200|30[0-9])$ ]]; then+ echo "✅ UI endpoint returned $response"+ exit 0+ fi+ echo "Attempt $i/3 - got $response, retrying in 5s..."+ sleep 5+ done+ echo "❌ UI endpoint returned $response (expected 200 or 30x)"+ docker logs litellm-test+ exit 1- name: Test UI index page content with root pathrun: |ROOT_PATH="${{ matrix.root_path }}"echo "Testing UI content at: http://localhost:4000${ROOT_PATH}/ui/"- # Fetch UI page and check for expected content- content=$(curl -sL "http://localhost:4000${ROOT_PATH}/ui/")-- # Check if the response contains typical HTML/UI markers- if echo "$content" | grep -q -E "(html|<!DOCTYPE|<head|<body)"; then- echo "✅ UI page contains valid HTML content"- else- echo "❌ UI page does not contain expected HTML content"- echo "Response: $content"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ content=$(curl -sL --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/ui/")+ if echo "$content" | grep -q -E "(html|<!DOCTYPE|<head|<body)"; then+ echo "✅ UI page contains valid HTML content"+ exit 0+ fi+ echo "Attempt $i/3 - no valid HTML, retrying in 5s..."+ sleep 5+ done+ echo "❌ UI page does not contain expected HTML content"+ echo "Response: $content"+ docker logs litellm-test+ exit 1- name: Test API docs endpoint with root pathrun: |ROOT_PATH="${{ matrix.root_path }}"echo "Testing API docs at: http://localhost:4000${ROOT_PATH}/docs"- response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000${ROOT_PATH}/docs")-- if [ "$response" = "200" ]; then- echo "✅ API docs endpoint returned 200"- else- echo "❌ API docs endpoint returned $response (expected 200)"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/docs")+ if [ "$response" = "200" ]; then+ echo "✅ API docs endpoint returned 200"+ exit 0+ fi+ echo "Attempt $i/3 - got $response, retrying in 5s..."+ sleep 5+ done+ echo "❌ API docs endpoint returned $response (expected 200)"+ docker logs litellm-test+ exit 1- name: Test OpenAPI schema with root pathrun: |ROOT_PATH="${{ matrix.root_path }}"echo "Testing OpenAPI schema at: http://localhost:4000${ROOT_PATH}/openapi.json"- response=$(curl -s "http://localhost:4000${ROOT_PATH}/openapi.json")-- # Check if response contains valid OpenAPI schema markers- if echo "$response" | grep -q '"openapi"'; then- echo "✅ OpenAPI schema is valid"- else- echo "❌ OpenAPI schema is invalid or missing"- echo "Response: $response"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ response=$(curl -s --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/openapi.json")+ if echo "$response" | grep -q '"openapi"'; then+ echo "✅ OpenAPI schema is valid"+ exit 0+ fi+ echo "Attempt $i/3 - invalid schema, retrying in 5s..."+ sleep 5+ done+ echo "❌ OpenAPI schema is invalid or missing"+ echo "Response: $response"+ docker logs litellm-test+ exit 1- name: Test model list endpoint with root pathrun: |ROOT_PATH="${{ matrix.root_path }}"echo "Testing model list endpoint at: http://localhost:4000${ROOT_PATH}/v1/models"- response=$(curl -s -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/v1/models")-- # Check if response contains models data structure- if echo "$response" | grep -q '"data"'; then- echo "✅ Model list endpoint returned valid response"- else- echo "❌ Model list endpoint returned invalid response"- echo "Response: $response"- docker logs litellm-test- exit 1- fi+ for i in 1 2 3; do+ response=$(curl -s --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000${ROOT_PATH}/v1/models")+ if echo "$response" | grep -q '"data"'; then+ echo "✅ Model list endpoint returned valid response"+ exit 0+ fi+ echo "Attempt $i/3 - invalid response, retrying in 5s..."+ sleep 5+ done+ echo "❌ Model list endpoint returned invalid response"+ echo "Response: $response"+ docker logs litellm-test+ exit 1- name: Verify root path is NOT accessible without prefixrun: |@@ -208,7 +226,7 @@ jobs:echo "Verifying endpoints are NOT accessible without root path prefix"# These should fail (404) because we're accessing without the root path- response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000/health")+ response=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000/health")if [ "$response" = "404" ]; thenecho "✅ Correctly returns 404 when accessing without root path"@@ -285,17 +303,20 @@ jobs:run: |echo "Testing that default paths work when SERVER_ROOT_PATH is not set"- # These should work at root level- health=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000/health")- ui=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:4000/ui")+ for i in 1 2 3; do+ health=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000/health")+ ui=$(curl -s -o /dev/null -w "%{http_code}" --max-time 5 -H "Authorization: Bearer sk-1234" "http://localhost:4000/ui")- if [ "$health" = "200" ] && [[ "$ui" =~ ^(200|30[0-9])$ ]]; then- echo "✅ Default paths work correctly"- else- echo "❌ Default paths failed (health: $health, ui: $ui)"- docker logs litellm-test- exit 1- fi+ if [ "$health" = "200" ] && [[ "$ui" =~ ^(200|30[0-9])$ ]]; then+ echo "✅ Default paths work correctly"+ exit 0+ fi+ echo "Attempt $i/3 - health: $health, ui: $ui, retrying in 5s..."+ sleep 5+ done+ echo "❌ Default paths failed (health: $health, ui: $ui)"+ docker logs litellm-test+ exit 1- name: Cleanupif: always()