1{
2 lib,
3 aiohttp,
4 apscheduler,
5 azure-identity,
6 azure-keyvault-secrets,
7 backoff,
8 boto3,
9 buildPythonPackage,
10 click,
11 cryptography,
12 email-validator,
13 fastapi,
14 fastapi-sso,
15 fetchFromGitHub,
16 google-cloud-kms,
17 gunicorn,
18 importlib-metadata,
19 jinja2,
20 jsonschema,
21 mcp,
22 openai,
23 orjson,
24 poetry-core,
25 prisma,
26 pydantic,
27 pyjwt,
28 pynacl,
29 python,
30 python-dotenv,
31 python-multipart,
32 pythonOlder,
33 pyyaml,
34 requests,
35 resend,
36 rich,
37 rq,
38 tiktoken,
39 tokenizers,
40 uvloop,
41 uvicorn,
42 websockets,
43 nixosTests,
44 nix-update-script,
45}:
46
47buildPythonPackage rec {
48 pname = "litellm";
49 version = "1.75.5";
50 pyproject = true;
51
52 disabled = pythonOlder "3.8";
53
54 src = fetchFromGitHub {
55 owner = "BerriAI";
56 repo = "litellm";
57 tag = "v${version}-stable";
58 hash = "sha256-VedQ0cNOf9vUFF7wjT7WOsCfTesIvzhudDfGnBTXO3E=";
59 };
60
61 build-system = [ poetry-core ];
62
63 dependencies = [
64 aiohttp
65 click
66 email-validator
67 importlib-metadata
68 jinja2
69 jsonschema
70 openai
71 pydantic
72 python-dotenv
73 requests
74 tiktoken
75 tokenizers
76 ];
77
78 optional-dependencies = {
79 proxy = [
80 apscheduler
81 backoff
82 boto3
83 cryptography
84 fastapi
85 fastapi-sso
86 gunicorn
87 mcp
88 orjson
89 pyjwt
90 pynacl
91 python-multipart
92 pyyaml
93 rich
94 rq
95 uvloop
96 uvicorn
97 websockets
98 ];
99
100 extra_proxy = [
101 azure-identity
102 azure-keyvault-secrets
103 google-cloud-kms
104 prisma
105 resend
106 ];
107 };
108
109 pythonImportsCheck = [
110 "litellm"
111 "litellm_enterprise"
112 ];
113
114 # Relax dependency check on openai, may not be needed in the future
115 pythonRelaxDeps = [ "openai" ];
116
117 # access network
118 doCheck = false;
119
120 postFixup = ''
121 # Symlink litellm_enterprise to make it discoverable
122 pushd $out/lib/python${python.pythonVersion}/site-packages
123 ln -s enterprise/litellm_enterprise litellm_enterprise
124 popd
125 '';
126
127 passthru = {
128 tests = { inherit (nixosTests) litellm; };
129 updateScript = nix-update-script {
130 extraArgs = [
131 "--version-regex"
132 "v([0-9]+\\.[0-9]+\\.[0-9]+)-stable"
133 ];
134 };
135 };
136
137 meta = {
138 description = "Use any LLM as a drop in replacement for gpt-3.5-turbo. Use Azure, OpenAI, Cohere, Anthropic, Ollama, VLLM, Sagemaker, HuggingFace, Replicate (100+ LLMs)";
139 mainProgram = "litellm";
140 homepage = "https://github.com/BerriAI/litellm";
141 changelog = "https://github.com/BerriAI/litellm/releases/tag/${src.tag}";
142 license = lib.licenses.mit;
143 maintainers = with lib.maintainers; [ happysalada ];
144 };
145}