@@ -2,7 +2,7 @@ import Image from '@theme/IdealImage';
2
2
import Tabs from '@theme/Tabs ';
3
3
import TabItem from '@theme/TabItem ';
4
4
5
- # ✨ Enterprise Features - Content Mod, SSO, Custom Swagger
5
+ # ✨ Enterprise Features - SSO, Audit Logs, Guardrails
6
6
7
7
Features here are behind a commercial license in our ` /enterprise ` folder. [ ** See Code** ] ( https://github.com/BerriAI/litellm/tree/main/enterprise )
8
8
@@ -14,18 +14,203 @@ Features here are behind a commercial license in our `/enterprise` folder. [**Se
14
14
15
15
Features:
16
16
- ✅ [ SSO for Admin UI] ( ./ui.md#✨-enterprise-features )
17
+ - ✅ [ Audit Logs] ( ./ui.md#✨-enterprise-features )
18
+ - ✅ [ Tracking Spend for Custom Tags] ( #tracking-spend-for-custom-tags )
17
19
- ✅ Content Moderation with LLM Guard, LlamaGuard, Google Text Moderations
18
20
- ✅ [ Prompt Injection Detection (with LakeraAI API)] ( #prompt-injection-detection-lakeraai )
19
21
- ✅ Reject calls from Blocked User list
20
22
- ✅ Reject calls (incoming / outgoing) with Banned Keywords (e.g. competitors)
21
- - ✅ Don't log/store specific requests to Langfuse, Sentry, etc. (eg confidential LLM requests)
22
- - ✅ Tracking Spend for Custom Tags
23
23
- ✅ Custom Branding + Routes on Swagger Docs
24
- - ✅ Audit Logs for ` Created At, Created By ` when Models Added
24
+
25
+ ## Audit Logs
26
+
27
+ Store Audit logs for ** Create, Update Delete Operations** done on ` Teams ` and ` Virtual Keys `
28
+
29
+ ** Step 1** Switch on audit Logs
30
+ ``` shell
31
+ litellm_settings:
32
+ store_audit_logs: true
33
+ ```
34
+
35
+ Start the litellm proxy with this config
36
+
37
+ ** Step 2** Test it - Create a Team
38
+
39
+ ``` shell
40
+ curl --location ' http://0.0.0.0:4000/team/new' \
41
+ --header ' Authorization: Bearer sk-1234' \
42
+ --header ' Content-Type: application/json' \
43
+ --data ' {
44
+ "max_budget": 2
45
+ }'
46
+ ```
47
+
48
+ ** Step 3** Expected Log
49
+
50
+ ``` json
51
+ {
52
+ "id" : " e1760e10-4264-4499-82cd-c08c86c8d05b" ,
53
+ "updated_at" : " 2024-06-06T02:10:40.836420+00:00" ,
54
+ "changed_by" : " 109010464461339474872" ,
55
+ "action" : " created" ,
56
+ "table_name" : " LiteLLM_TeamTable" ,
57
+ "object_id" : " 82e725b5-053f-459d-9a52-867191635446" ,
58
+ "before_value" : null ,
59
+ "updated_values" : {
60
+ "team_id" : " 82e725b5-053f-459d-9a52-867191635446" ,
61
+ "admins" : [],
62
+ "members" : [],
63
+ "members_with_roles" : [
64
+ {
65
+ "role" : " admin" ,
66
+ "user_id" : " 109010464461339474872"
67
+ }
68
+ ],
69
+ "max_budget" : 2.0 ,
70
+ "models" : [],
71
+ "blocked" : false
72
+ }
73
+ }
74
+ ```
75
+
76
+
77
+ ## Tracking Spend for Custom Tags
78
+
79
+ Requirements:
80
+
81
+ - Virtual Keys & a database should be set up, see [ virtual keys] ( https://docs.litellm.ai/docs/proxy/virtual_keys )
82
+
83
+ ### Usage - /chat/completions requests with request tags
84
+
85
+
86
+ <Tabs >
87
+
88
+
89
+ <TabItem value =" openai " label =" OpenAI Python v1.0.0+ " >
90
+
91
+ Set ` extra_body={"metadata": { }} ` to ` metadata ` you want to pass
92
+
93
+ ``` python
94
+ import openai
95
+ client = openai.OpenAI(
96
+ api_key = " anything" ,
97
+ base_url = " http://0.0.0.0:4000"
98
+ )
99
+
100
+ # request sent to model set on litellm proxy, `litellm --model`
101
+ response = client.chat.completions.create(
102
+ model = " gpt-3.5-turbo" ,
103
+ messages = [
104
+ {
105
+ " role" : " user" ,
106
+ " content" : " this is a test request, write a short poem"
107
+ }
108
+ ],
109
+ extra_body = {
110
+ " metadata" : {
111
+ " tags" : [" model-anthropic-claude-v2.1" , " app-ishaan-prod" ]
112
+ }
113
+ }
114
+ )
115
+
116
+ print (response)
117
+ ```
118
+ </TabItem >
119
+
120
+ <TabItem value =" Curl " label =" Curl Request " >
121
+
122
+ Pass ` metadata ` as part of the request body
123
+
124
+ ``` shell
125
+ curl --location ' http://0.0.0.0:4000/chat/completions' \
126
+ --header ' Content-Type: application/json' \
127
+ --data ' {
128
+ "model": "gpt-3.5-turbo",
129
+ "messages": [
130
+ {
131
+ "role": "user",
132
+ "content": "what llm are you"
133
+ }
134
+ ],
135
+ "metadata": {"tags": ["model-anthropic-claude-v2.1", "app-ishaan-prod"]}
136
+ }'
137
+ ```
138
+ </TabItem >
139
+ <TabItem value =" langchain " label =" Langchain " >
140
+
141
+ ``` python
142
+ from langchain.chat_models import ChatOpenAI
143
+ from langchain.prompts.chat import (
144
+ ChatPromptTemplate,
145
+ HumanMessagePromptTemplate,
146
+ SystemMessagePromptTemplate,
147
+ )
148
+ from langchain.schema import HumanMessage, SystemMessage
149
+
150
+ chat = ChatOpenAI(
151
+ openai_api_base = " http://0.0.0.0:4000" ,
152
+ model = " gpt-3.5-turbo" ,
153
+ temperature = 0.1 ,
154
+ extra_body = {
155
+ " metadata" : {
156
+ " tags" : [" model-anthropic-claude-v2.1" , " app-ishaan-prod" ]
157
+ }
158
+ }
159
+ )
160
+
161
+ messages = [
162
+ SystemMessage(
163
+ content = " You are a helpful assistant that im using to make a test request to."
164
+ ),
165
+ HumanMessage(
166
+ content = " test from litellm. tell me why it's amazing in 1 sentence"
167
+ ),
168
+ ]
169
+ response = chat(messages)
170
+
171
+ print (response)
172
+ ```
173
+
174
+ </TabItem >
175
+ </Tabs >
176
+
177
+
178
+ ### Viewing Spend per tag
179
+
180
+ #### ` /spend/tags ` Request Format
181
+ ``` shell
182
+ curl -X GET " http://0.0.0.0:4000/spend/tags" \
183
+ -H " Authorization: Bearer sk-1234"
184
+ ```
185
+
186
+ #### ` /spend/tags ` Response Format
187
+ ``` shell
188
+ [
189
+ {
190
+ " individual_request_tag" : " model-anthropic-claude-v2.1" ,
191
+ " log_count" : 6,
192
+ " total_spend" : 0.000672
193
+ },
194
+ {
195
+ " individual_request_tag" : " app-ishaan-local" ,
196
+ " log_count" : 4,
197
+ " total_spend" : 0.000448
198
+ },
199
+ {
200
+ " individual_request_tag" : " app-ishaan-prod" ,
201
+ " log_count" : 2,
202
+ " total_spend" : 0.000224
203
+ }
204
+ ]
205
+
206
+ ```
207
+
208
+
209
+ <!-- ## Tracking Spend per Key
25
210
26
211
27
212
## Content Moderation
28
- ### Content Moderation with LLM Guard
213
+ #### Content Moderation with LLM Guard
29
214
30
215
Set the LLM Guard API Base in your environment
31
216
@@ -160,7 +345,7 @@ curl --location 'http://0.0.0.0:4000/v1/chat/completions' \
160
345
</TabItem>
161
346
</Tabs>
162
347
163
- ### Content Moderation with LlamaGuard
348
+ #### Content Moderation with LlamaGuard
164
349
165
350
Currently works with Sagemaker's LlamaGuard endpoint.
166
351
@@ -194,7 +379,7 @@ callbacks: ["llamaguard_moderations"]
194
379
195
380
196
381
197
- ### Content Moderation with Google Text Moderation
382
+ #### Content Moderation with Google Text Moderation
198
383
199
384
Requires your GOOGLE_APPLICATION_CREDENTIALS to be set in your .env (same as VertexAI).
200
385
@@ -250,7 +435,7 @@ Here are the category specific values:
250
435
251
436
252
437
253
- ### Content Moderation with OpenAI Moderations
438
+ #### Content Moderation with OpenAI Moderations
254
439
255
440
Use this if you want to reject /chat, /completions, /embeddings calls that fail OpenAI Moderations checks
256
441
@@ -417,139 +602,6 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \
417
602
}
418
603
'
419
604
```
420
- ## Tracking Spend for Custom Tags
421
-
422
- Requirements:
423
-
424
- - Virtual Keys & a database should be set up, see [virtual keys](https://docs.litellm.ai/docs/proxy/virtual_keys)
425
-
426
- ### Usage - /chat/completions requests with request tags
427
-
428
-
429
- <Tabs>
430
-
431
-
432
- <TabItem value="openai" label="OpenAI Python v1.0.0+">
433
-
434
- Set `extra_body={"metadata": { }}` to `metadata` you want to pass
435
-
436
- ```python
437
- import openai
438
- client = openai.OpenAI(
439
- api_key="anything",
440
- base_url="http://0.0.0.0:4000"
441
- )
442
-
443
- # request sent to model set on litellm proxy, `litellm --model`
444
- response = client.chat.completions.create(
445
- model="gpt-3.5-turbo",
446
- messages = [
447
- {
448
- "role": "user",
449
- "content": "this is a test request, write a short poem"
450
- }
451
- ],
452
- extra_body={
453
- "metadata": {
454
- "tags": ["model-anthropic-claude-v2.1", "app-ishaan-prod"]
455
- }
456
- }
457
- )
458
-
459
- print(response)
460
- ```
461
- </TabItem>
462
-
463
- <TabItem value="Curl" label="Curl Request">
464
-
465
- Pass `metadata` as part of the request body
466
-
467
- ```shell
468
- curl --location ' http://0.0.0.0:4000/chat/completions' \
469
- --header 'Content-Type : application/json' \
470
- --data '{
471
- " model " : " gpt-3.5-turbo" ,
472
- " messages " : [
473
- {
474
- " role " : " user" ,
475
- " content " : " what llm are you"
476
- }
477
- ],
478
- " metadata " : {"tags": ["model-anthropic-claude-v2.1", "app-ishaan-prod"]}
479
- }'
480
- ```
481
- </TabItem >
482
- <TabItem value =" langchain " label =" Langchain " >
483
-
484
- ``` python
485
- from langchain.chat_models import ChatOpenAI
486
- from langchain.prompts.chat import (
487
- ChatPromptTemplate,
488
- HumanMessagePromptTemplate,
489
- SystemMessagePromptTemplate,
490
- )
491
- from langchain.schema import HumanMessage, SystemMessage
492
-
493
- chat = ChatOpenAI(
494
- openai_api_base = " http://0.0.0.0:4000" ,
495
- model = " gpt-3.5-turbo" ,
496
- temperature = 0.1 ,
497
- extra_body = {
498
- " metadata" : {
499
- " tags" : [" model-anthropic-claude-v2.1" , " app-ishaan-prod" ]
500
- }
501
- }
502
- )
503
-
504
- messages = [
505
- SystemMessage(
506
- content = " You are a helpful assistant that im using to make a test request to."
507
- ),
508
- HumanMessage(
509
- content = " test from litellm. tell me why it's amazing in 1 sentence"
510
- ),
511
- ]
512
- response = chat(messages)
513
-
514
- print (response)
515
- ```
516
-
517
- </TabItem >
518
- </Tabs >
519
-
520
-
521
- ### Viewing Spend per tag
522
-
523
- #### ` /spend/tags ` Request Format
524
- ``` shell
525
- curl -X GET " http://0.0.0.0:4000/spend/tags" \
526
- -H " Authorization: Bearer sk-1234"
527
- ```
528
-
529
- #### ` /spend/tags ` Response Format
530
- ``` shell
531
- [
532
- {
533
- " individual_request_tag" : " model-anthropic-claude-v2.1" ,
534
- " log_count" : 6,
535
- " total_spend" : 0.000672
536
- },
537
- {
538
- " individual_request_tag" : " app-ishaan-local" ,
539
- " log_count" : 4,
540
- " total_spend" : 0.000448
541
- },
542
- {
543
- " individual_request_tag" : " app-ishaan-prod" ,
544
- " log_count" : 2,
545
- " total_spend" : 0.000224
546
- }
547
- ]
548
-
549
- ```
550
-
551
-
552
- <!-- ## Tracking Spend per Key
553
605
554
606
## Tracking Spend per User -->
555
607
0 commit comments