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
chore(tests): remove fully commented-out proxy test files and their CI entries
mateo13d20036cf3a
diff --git a/.github/workflows/test-unit-proxy-db.yml b/.github/workflows/test-unit-proxy-db.ymlindex 3725e0f5805..32080dfec7f 100644--- a/.github/workflows/test-unit-proxy-db.yml+++ b/.github/workflows/test-unit-proxy-db.yml@@ -110,8 +110,6 @@ jobs:- test-group: proxy-server-coretest-path: >-tests/proxy_unit_tests/test_proxy_server.py- tests/proxy_unit_tests/test_proxy_server_keys.py- tests/proxy_unit_tests/test_proxy_server_spend.pytests/proxy_unit_tests/test_aproxy_startup.pyworkers: 4dist: loadscope@@ -120,7 +118,6 @@ jobs:test-path: >-tests/proxy_unit_tests/test_proxy_config_unit_test.pytests/proxy_unit_tests/test_proxy_routes.py- tests/proxy_unit_tests/test_proxy_gunicorn.pytests/proxy_unit_tests/test_server_root_path.pytests/proxy_unit_tests/test_proxy_pass_user_config.pytests/proxy_unit_tests/test_proxy_token_counter.py@@ -198,7 +195,6 @@ jobs:tests/proxy_unit_tests/test_realtime_cache.pytests/proxy_unit_tests/test_proxy_exception_mapping.pytests/proxy_unit_tests/test_custom_tokenizer_bug.py- tests/proxy_unit_tests/test_model_response_typingworkers: 4dist: loadscopetimeout: 15diff --git a/tests/local_testing/test_model_response_typing/server.py b/tests/local_testing/test_model_response_typing/server.pydeleted file mode 100644index 80dbc33affd..00000000000--- a/tests/local_testing/test_model_response_typing/server.py+++ /dev/null@@ -1,23 +0,0 @@-# #### What this tests ####-# # This tests if the litellm model response type is returnable in a flask app--# import sys, os-# import traceback-# from flask import Flask, request, jsonify, abort, Response-# sys.path.insert(0, os.path.abspath('../../..')) # Adds the parent directory to the system path--# import litellm-# from litellm import completion--# litellm.set_verbose = False--# app = Flask(__name__)--# @app.route('/')-# def hello():-# data = request.json-# return completion(**data)--# if __name__ == '__main__':-# from waitress import serve-# serve(app, host='localhost', port=8080, threads=10)diff --git a/tests/local_testing/test_model_response_typing/test.py b/tests/local_testing/test_model_response_typing/test.pydeleted file mode 100644index 46bf5fbb44b..00000000000--- a/tests/local_testing/test_model_response_typing/test.py+++ /dev/null@@ -1,14 +0,0 @@-# import requests, json--# BASE_URL = 'http://localhost:8080'--# def test_hello_route():-# data = {"model": "claude-3-5-haiku-20241022", "messages": [{"role": "user", "content": "hey, how's it going?"}]}-# headers = {'Content-Type': 'application/json'}-# response = requests.get(BASE_URL, headers=headers, data=json.dumps(data))-# print(response.text)-# assert response.status_code == 200-# print("Hello route test passed!")--# if __name__ == '__main__':-# test_hello_route()diff --git a/tests/proxy_unit_tests/test_model_response_typing/server.py b/tests/proxy_unit_tests/test_model_response_typing/server.pydeleted file mode 100644index 80dbc33affd..00000000000--- a/tests/proxy_unit_tests/test_model_response_typing/server.py+++ /dev/null@@ -1,23 +0,0 @@-# #### What this tests ####-# # This tests if the litellm model response type is returnable in a flask app--# import sys, os-# import traceback-# from flask import Flask, request, jsonify, abort, Response-# sys.path.insert(0, os.path.abspath('../../..')) # Adds the parent directory to the system path--# import litellm-# from litellm import completion--# litellm.set_verbose = False--# app = Flask(__name__)--# @app.route('/')-# def hello():-# data = request.json-# return completion(**data)--# if __name__ == '__main__':-# from waitress import serve-# serve(app, host='localhost', port=8080, threads=10)diff --git a/tests/proxy_unit_tests/test_model_response_typing/test.py b/tests/proxy_unit_tests/test_model_response_typing/test.pydeleted file mode 100644index 46bf5fbb44b..00000000000--- a/tests/proxy_unit_tests/test_model_response_typing/test.py+++ /dev/null@@ -1,14 +0,0 @@-# import requests, json--# BASE_URL = 'http://localhost:8080'--# def test_hello_route():-# data = {"model": "claude-3-5-haiku-20241022", "messages": [{"role": "user", "content": "hey, how's it going?"}]}-# headers = {'Content-Type': 'application/json'}-# response = requests.get(BASE_URL, headers=headers, data=json.dumps(data))-# print(response.text)-# assert response.status_code == 200-# print("Hello route test passed!")--# if __name__ == '__main__':-# test_hello_route()diff --git a/tests/proxy_unit_tests/test_proxy_gunicorn.py b/tests/proxy_unit_tests/test_proxy_gunicorn.pydeleted file mode 100644index 73e368d35a5..00000000000--- a/tests/proxy_unit_tests/test_proxy_gunicorn.py+++ /dev/null@@ -1,61 +0,0 @@-# #### What this tests ####-# # Allow the user to easily run the local proxy server with Gunicorn-# # LOCAL TESTING ONLY-# import sys, os, subprocess-# import traceback-# from dotenv import load_dotenv--# load_dotenv()-# import os, io--# # this file is to test litellm/proxy--# sys.path.insert(-# 0, os.path.abspath("../..")-# ) # Adds the parent directory to the system path-# import pytest-# import litellm--# ### LOCAL Proxy Server INIT ###-# from litellm.proxy.proxy_server import save_worker_config # Replace with the actual module where your FastAPI router is defined-# filepath = os.path.dirname(os.path.abspath(__file__))-# config_fp = f"{filepath}/test_configs/test_config_custom_auth.yaml"-# def get_openai_info():-# return {-# "api_key": os.getenv("AZURE_API_KEY"),-# "api_base": os.getenv("AZURE_API_BASE"),-# }--# def run_server(host="0.0.0.0",port=8008,num_workers=None):-# if num_workers is None:-# # Set it to min(8,cpu_count())-# import multiprocessing-# num_workers = min(4,multiprocessing.cpu_count())--# ### LOAD KEYS ###--# # Load the Azure keys. For now get them from openai-usage-# azure_info = get_openai_info()-# print(f"Azure info:{azure_info}")-# os.environ["AZURE_API_KEY"] = azure_info['api_key']-# os.environ["AZURE_API_BASE"] = azure_info['api_base']-# os.environ["AZURE_API_VERSION"] = "2023-09-01-preview"--# ### SAVE CONFIG ###--# os.environ["WORKER_CONFIG"] = config_fp--# # In order for the app to behave well with signals, run it with gunicorn-# # The first argument must be the "name of the command run"-# cmd = f"gunicorn litellm.proxy.proxy_server:app --workers {num_workers} --worker-class uvicorn.workers.UvicornWorker --bind {host}:{port}"-# cmd = cmd.split()-# print(f"Running command: {cmd}")-# import sys-# sys.stdout.flush()-# sys.stderr.flush()--# # Make sure to propage env variables-# subprocess.run(cmd) # This line actually starts Gunicorn--# if __name__ == "__main__":-# run_server()diff --git a/tests/proxy_unit_tests/test_proxy_server_keys.py b/tests/proxy_unit_tests/test_proxy_server_keys.pydeleted file mode 100644index 717eec921b7..00000000000--- a/tests/proxy_unit_tests/test_proxy_server_keys.py+++ /dev/null@@ -1,269 +0,0 @@-# import sys, os, time-# import traceback-# from dotenv import load_dotenv--# load_dotenv()-# import os, io--# # this file is to test litellm/proxy--# sys.path.insert(-# 0, os.path.abspath("../..")-# ) # Adds the parent directory to the system path-# import pytest, logging-# import litellm-# from litellm import embedding, completion, completion_cost, Timeout-# from litellm import RateLimitError---# import sys, os, time-# import traceback-# from dotenv import load_dotenv--# load_dotenv()-# import os, io--# # this file is to test litellm/proxy-# from concurrent.futures import ThreadPoolExecutor--# sys.path.insert(-# 0, os.path.abspath("../..")-# ) # Adds the parent directory to the system path--# import pytest, logging, requests-# import litellm-# from litellm import embedding, completion, completion_cost, Timeout-# from litellm import RateLimitError-# from github import Github-# import subprocess---# # Function to execute a command and return the output-# def run_command(command):-# process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)-# output, _ = process.communicate()-# return output.decode().strip()---# # Retrieve the current branch name-# branch_name = run_command("git rev-parse --abbrev-ref HEAD")--# # GitHub personal access token (with repo scope) or use username and password-# access_token = os.getenv("GITHUB_ACCESS_TOKEN")-# # Instantiate the PyGithub library's Github object-# g = Github(access_token)--# # Provide the owner and name of the repository where the pull request is located-# repository_owner = "BerriAI"-# repository_name = "litellm"--# # Get the repository object-# repo = g.get_repo(f"{repository_owner}/{repository_name}")--# # Iterate through the pull requests to find the one related to your branch-# for pr in repo.get_pulls():-# print(f"in here! {pr.head.ref}")-# if pr.head.ref == branch_name:-# pr_number = pr.number-# break--# print(f"The pull request number for branch {branch_name} is: {pr_number}")---# def test_add_new_key():-# max_retries = 3-# retry_delay = 10 # seconds--# for retry in range(max_retries + 1):-# try:-# # Your test data-# test_data = {-# "models": ["gpt-3.5-turbo", "gpt-4", "claude-2", "azure-model"],-# "aliases": {"mistral-7b": "gpt-3.5-turbo"},-# "duration": "20m",-# }-# print("testing proxy server")--# # Your bearer token-# token = os.getenv("PROXY_MASTER_KEY")-# headers = {"Authorization": f"Bearer {token}"}--# endpoint = f"https://litellm-litellm-pr-{pr_number}.up.railway.app"--# # Make a request to the staging endpoint-# response = requests.post(-# endpoint + "/key/generate", json=test_data, headers=headers-# )--# print(f"response: {response.text}")--# if response.status_code == 200:-# result = response.json()-# break # Successful response, exit the loop-# elif response.status_code == 503 and retry < max_retries:-# print(-# f"Retrying in {retry_delay} seconds... (Retry {retry + 1}/{max_retries})"-# )-# time.sleep(retry_delay)-# else:-# assert False, f"Unexpected response status code: {response.status_code}"--# except Exception as e:-# print(traceback.format_exc())-# pytest.fail(f"An error occurred {e}")---# def test_update_new_key():-# try:-# # Your test data-# test_data = {-# "models": ["gpt-3.5-turbo", "gpt-4", "claude-2", "azure-model"],-# "aliases": {"mistral-7b": "gpt-3.5-turbo"},-# "duration": "20m",-# }-# print("testing proxy server")-# # Your bearer token-# token = os.getenv("PROXY_MASTER_KEY")-# headers = {"Authorization": f"Bearer {token}"}--# endpoint = f"https://litellm-litellm-pr-{pr_number}.up.railway.app"--# # Make a request to the staging endpoint-# response = requests.post(-# endpoint + "/key/generate", json=test_data, headers=headers-# )-# assert response.status_code == 200-# result = response.json()-# assert result["key"].startswith("sk-")--# def _post_data():-# json_data = {"models": ["bedrock-models"], "key": result["key"]}-# response = requests.post(-# endpoint + "/key/generate", json=json_data, headers=headers-# )-# print(f"response text: {response.text}")-# assert response.status_code == 200-# return response--# _post_data()-# print(f"Received response: {result}")-# except Exception as e:-# pytest.fail(f"LiteLLM Proxy test failed. Exception: {str(e)}")--# def test_add_new_key_max_parallel_limit():-# try:-# # Your test data-# test_data = {"duration": "20m", "max_parallel_requests": 1}-# # Your bearer token-# token = os.getenv("PROXY_MASTER_KEY")-# headers = {"Authorization": f"Bearer {token}"}--# endpoint = f"https://litellm-litellm-pr-{pr_number}.up.railway.app"-# print(f"endpoint: {endpoint}")-# # Make a request to the staging endpoint-# response = requests.post(-# endpoint + "/key/generate", json=test_data, headers=headers-# )-# assert response.status_code == 200-# result = response.json()--# # load endpoint with model-# model_data = {-# "model_name": "azure-model",-# "litellm_params": {-# "model": "azure/gpt-4.1-mini",-# "api_key": os.getenv("AZURE_API_KEY"),-# "api_base": os.getenv("AZURE_API_BASE"),-# "api_version": os.getenv("AZURE_API_VERSION")-# }-# }-# response = requests.post(endpoint + "/model/new", json=model_data, headers=headers)-# assert response.status_code == 200-# print(f"response text: {response.text}")---# def _post_data():-# json_data = {-# "model": "azure-model",-# "messages": [-# {-# "role": "user",-# "content": f"this is a test request, write a short poem {time.time()}",-# }-# ],-# }-# # Your bearer token-# response = requests.post(-# endpoint + "/chat/completions", json=json_data, headers={"Authorization": f"Bearer {result['key']}"}-# )-# return response--# def _run_in_parallel():-# with ThreadPoolExecutor(max_workers=2) as executor:-# future1 = executor.submit(_post_data)-# future2 = executor.submit(_post_data)--# # Obtain the results from the futures-# response1 = future1.result()-# print(f"response1 text: {response1.text}")-# response2 = future2.result()-# print(f"response2 text: {response2.text}")-# if response1.status_code == 429 or response2.status_code == 429:-# pass-# else:-# raise Exception()--# _run_in_parallel()-# except Exception as e:-# pytest.fail(f"LiteLLM Proxy test failed. Exception: {str(e)}")--# def test_add_new_key_max_parallel_limit_streaming():-# try:-# # Your test data-# test_data = {"duration": "20m", "max_parallel_requests": 1}-# # Your bearer token-# token = os.getenv("PROXY_MASTER_KEY")-# headers = {"Authorization": f"Bearer {token}"}--# endpoint = f"https://litellm-litellm-pr-{pr_number}.up.railway.app"--# # Make a request to the staging endpoint-# response = requests.post(-# endpoint + "/key/generate", json=test_data, headers=headers-# )-# print(f"response: {response.text}")-# assert response.status_code == 200-# result = response.json()--# def _post_data():-# json_data = {-# "model": "azure-model",-# "messages": [-# {-# "role": "user",-# "content": f"this is a test request, write a short poem {time.time()}",-# }-# ],-# "stream": True,-# }-# response = requests.post(-# endpoint + "/chat/completions", json=json_data, headers={"Authorization": f"Bearer {result['key']}"}-# )-# return response--# def _run_in_parallel():-# with ThreadPoolExecutor(max_workers=2) as executor:-# future1 = executor.submit(_post_data)-# future2 = executor.submit(_post_data)--# # Obtain the results from the futures-# response1 = future1.result()-# response2 = future2.result()-# if response1.status_code == 429 or response2.status_code == 429:-# pass-# else:-# raise Exception()--# _run_in_parallel()-# except Exception as e:-# pytest.fail(f"LiteLLM Proxy test failed. Exception: {str(e)}")diff --git a/tests/proxy_unit_tests/test_proxy_server_spend.py b/tests/proxy_unit_tests/test_proxy_server_spend.pydeleted file mode 100644index 9fed60412ce..00000000000--- a/tests/proxy_unit_tests/test_proxy_server_spend.py+++ /dev/null@@ -1,82 +0,0 @@-# import openai, json, time, asyncio-# client = openai.AsyncOpenAI(-# api_key="sk-1234",-# base_url="http://0.0.0.0:8000"-# )--# super_fake_messages = [-# {-# "role": "user",-# "content": f"What's the weather like in San Francisco, Tokyo, and Paris? {time.time()}"-# },-# {-# "content": None,-# "role": "assistant",-# "tool_calls": [-# {-# "id": "1",-# "function": {-# "arguments": "{\"location\": \"San Francisco\", \"unit\": \"celsius\"}",-# "name": "get_current_weather"-# },-# "type": "function"-# },-# {-# "id": "2",-# "function": {-# "arguments": "{\"location\": \"Tokyo\", \"unit\": \"celsius\"}",-# "name": "get_current_weather"-# },-# "type": "function"-# },-# {-# "id": "3",-# "function": {-# "arguments": "{\"location\": \"Paris\", \"unit\": \"celsius\"}",-# "name": "get_current_weather"-# },-# "type": "function"-# }-# ]-# },-# {-# "tool_call_id": "1",-# "role": "tool",-# "name": "get_current_weather",-# "content": "{\"location\": \"San Francisco\", \"temperature\": \"90\", \"unit\": \"celsius\"}"-# },-# {-# "tool_call_id": "2",-# "role": "tool",-# "name": "get_current_weather",-# "content": "{\"location\": \"Tokyo\", \"temperature\": \"30\", \"unit\": \"celsius\"}"-# },-# {-# "tool_call_id": "3",-# "role": "tool",-# "name": "get_current_weather",-# "content": "{\"location\": \"Paris\", \"temperature\": \"50\", \"unit\": \"celsius\"}"-# }-# ]--# async def chat_completions():-# super_fake_response = await client.chat.completions.create(-# model="gpt-3.5-turbo",-# messages=super_fake_messages,-# seed=1337,-# stream=False-# ) # get a new response from the model where it can see the function response-# await asyncio.sleep(1)-# return super_fake_response--# async def loadtest_fn(n = 1):-# global num_task_cancelled_errors, exception_counts, chat_completions-# start = time.time()-# tasks = [chat_completions() for _ in range(n)]-# chat_completions = await asyncio.gather(*tasks)-# successful_completions = [c for c in chat_completions if c is not None]-# print(n, time.time() - start, len(successful_completions))--# # print(json.dumps(super_fake_response.model_dump(), indent=4))--# asyncio.run(loadtest_fn())