Skip to content

Commit 11012ed

Browse files
authored
Merge branch 'main' into chore/openai-compliance-improvements
2 parents c5e2e8e + 56fc835 commit 11012ed

File tree

27 files changed

+1334
-149
lines changed

27 files changed

+1334
-149
lines changed

cookbook/integrations/Sutra_with_Portkey.ipynb

Lines changed: 435 additions & 0 deletions
Large diffs are not rendered by default.

docs/installation-deployments.md

Lines changed: 137 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ Check out the [API docs](https://portkey.ai/docs/welcome/make-your-first-request
1414

1515
## Local Deployment
1616

17-
1. Run through [NPX](#node) or [BunX](#bun) Install
17+
1. Do [NPM](#node) or [Bun](#bun) Install
1818
2. Run a [Node.js Server](#nodejs-server)
19-
3. Deploy using [Docker](#docker)
20-
4. Deploy using [Docker Compose](#docker-compose)
21-
5. Deploy on [Cloudflare Workers](#cloudflare-workers)
22-
6. Deploy on [App Stack](#deploy-to-app-stack)
19+
3. Deploy on [App Stack](#deploy-to-app-stack)
20+
4. Deploy on [Cloudflare Workers](#cloudflare-workers)
21+
5. Deploy using [Docker](#docker)
22+
6. Deploy using [Docker Compose](#docker-compose)
2323
7. Deploy on [Replit](#replit)
2424
8. Deploy on [Zeabur](#zeabur)
25+
9. Deploy with [Supabase Functions](#supabase-functions)
26+
10. Deploy using [Fastly](#fastly)
27+
28+
---
2529

2630
### Node
2731

@@ -39,7 +43,37 @@ $ bunx @portkey-ai/gateway
3943

4044
<br>
4145

42-
### Deploy to App Stack
46+
47+
---
48+
49+
### NodeJS Server
50+
51+
1. Clone the Repository
52+
53+
```sh
54+
git clone https://github.com/portkey-ai/gateway
55+
```
56+
57+
2. Install the NPM Dependencies
58+
59+
```sh
60+
cd gateway
61+
npm i
62+
npm run build
63+
```
64+
65+
3. Run the Server
66+
67+
```sh
68+
node build/start-server.js
69+
```
70+
71+
<br>
72+
73+
---
74+
75+
### Deploy to App Stack
76+
4377
F5 Distributed Cloud
4478
1. [Create an App Stack Site](https://docs.cloud.f5.com/docs/how-to/site-management/create-voltstack-site)
4579

@@ -94,7 +128,8 @@ curl --request POST \
94128
--data '{"metadata": {"name": "$DISTRIBUTED_CLOUD_SERVICE_NAME","namespace": "$DISTRIBUTED_CLOUD_NAMESPACE","labels": {},"annotations": {},"description": "","disable": false},"spec": {"origin_servers": [{"k8s_service": {"service_name": "$DISTRIBUTED_CLOUD_SERVICE_NAME.$DISTRIBUTED_CLOUD_APP_STACK_NAMESPACE","site_locator": {"site": {"tenant": "$DISTRIBUTED_CLOUD_TENANT_ID","namespace": "system","name": "$DISTRIBUTED_CLOUD_APP_STACK_SITE"}},"inside_network": {}},"labels": {}}],"no_tls": {},"port": 8787,"same_as_endpoint_port": {},"healthcheck": [],"loadbalancer_algorithm": "LB_OVERRIDE","endpoint_selection": "LOCAL_PREFERRED","advanced_options": null}}'
95129
```
96130
or [use the UI](https://docs.cloud.f5.com/docs/how-to/app-networking/origin-pools)
97-
5. Create an HTTP Load Balancer, including header injection of Portkey provider and credentials
131+
132+
6. Create an HTTP Load Balancer, including header injection of Portkey provider and credentials
98133
```shell
99134
curl --request POST \
100135
--url https://$DISTRIBUTED_CLOUD_TENANT.console.ves.volterra.io/api/config/namespaces/$DISTRIBUTED_CLOUD_NAMESPACE/http_loadbalancers \
@@ -103,7 +138,8 @@ curl --request POST \
103138
--data '{"metadata": {"name": "$DISTRIBUTED_CLOUD_SERVICE_NAME","namespace": "$DISTRIBUTED_CLOUD_NAMESPACE","labels": {},"annotations": {},"description": "","disable": false},"spec": {"domains": ["$PORTKEY_GATEWAY_FQDN"],"https_auto_cert": {"http_redirect": true,"add_hsts": false,"tls_config": {"default_security": {}},"no_mtls": {},"default_header": {},"enable_path_normalize": {},"port": 443,"non_default_loadbalancer": {},"header_transformation_type": {"default_header_transformation": {}},"connection_idle_timeout": 120000,"http_protocol_options": {"http_protocol_enable_v1_v2": {}}},"advertise_on_public_default_vip": {},"default_route_pools": [{"pool": {"tenant": "$DISTRIBUTED_CLOUD_TENANT_ID","namespace": "$DISTRIBUTED_CLOUD_NAMESPACE","name": "$DISTRIBUTED_CLOUD_SERVICE_NAME"},"weight": 1,"priority": 1,"endpoint_subsets": {}}],"origin_server_subset_rule_list": null,"routes": [],"cors_policy": null,"disable_waf": {},"add_location": true,"no_challenge": {},"more_option": {"request_headers_to_add": [{"name": "x-portkey-provider","value": "$PORTKEY_PROVIDER","append": false},{"name": "Authorization","value": "Bearer $PORTKEY_PROVIDER_AUTH_TOKEN","append": false}],"request_headers_to_remove": [],"response_headers_to_add": [],"response_headers_to_remove": [],"max_request_header_size": 60,"buffer_policy": null,"compression_params": null,"custom_errors": {},"javascript_info": null,"jwt": [],"idle_timeout": 30000,"disable_default_error_pages": false,"cookies_to_modify": []},"user_id_client_ip": {},"disable_rate_limit": {},"malicious_user_mitigation": null,"waf_exclusion_rules": [],"data_guard_rules": [],"blocked_clients": [],"trusted_clients": [],"api_protection_rules": null,"ddos_mitigation_rules": [],"service_policies_from_namespace": {},"round_robin": {},"disable_trust_client_ip_headers": {},"disable_ddos_detection": {},"disable_malicious_user_detection": {},"disable_api_discovery": {},"disable_bot_defense": {},"disable_api_definition": {},"disable_ip_reputation": {},"disable_client_side_defense": {},"csrf_policy": null,"graphql_rules": [],"protected_cookies": [],"host_name": "","dns_info": [],"internet_vip_info": [],"system_default_timeouts": {},"jwt_validation": null,"disable_threat_intelligence": {},"l7_ddos_action_default": {},}}'
104139
```
105140
or [use the UI](https://docs.cloud.f5.com/docs/how-to/app-networking/http-load-balancer)
106-
6. Test the service
141+
142+
7. Test the service
107143
```shell
108144
curl --request POST \
109145
--url https://$PORTKEY_GATEWAY_FQDN/v1/chat/completions \
@@ -137,6 +173,7 @@ in addition to the response headers, you should get a response body like
137173
}
138174
```
139175

176+
---
140177

141178
### Cloudflare Workers
142179

@@ -159,33 +196,10 @@ npm install
159196
npm run deploy
160197
```
161198

199+
For more details, refer to [Cloudflare Workers official](https://developers.cloudflare.com/workers/).
162200
<br>
163201

164-
### NodeJS Server
165-
166-
1. Clone the Repository
167-
168-
```sh
169-
git clone https://github.com/portkey-ai/gateway
170-
```
171-
172-
2. Install the NPM Dependencies
173-
174-
```sh
175-
cd gateway
176-
npm i
177-
npm run build
178-
```
179-
180-
<br>
181-
182-
3. Run the Server
183-
184-
```sh
185-
node build/start-server.js
186-
```
187-
188-
<br>
202+
---
189203

190204
### Docker
191205

@@ -199,6 +213,8 @@ For more information on the Docker image, check [here](https://hub.docker.com/r/
199213

200214
<br>
201215

216+
---
217+
202218
### Docker Compose
203219

204220
1. Download Compose File from the Repository:
@@ -214,8 +230,10 @@ docker compose up -d
214230
```
215231
> The service is now running and listening on port 8787
216232
233+
For more details, refer to [Docker Compose official](https://docs.docker.com/compose/).
217234
<br>
218235

236+
219237
### AWS EC2
220238
1. Copy the AWS CloudFormation template from below:
221239
```yaml
@@ -336,48 +354,123 @@ Outputs:
336354
337355
5. Once the stack is created, you can access the Portkey Gateway URL from the Outputs section.
338356
357+
---
358+
359+
339360
### Replit
340361
341362
[![Deploy on Replit](https://replit.com/badge?caption=Deploy%20on%20Replit)](https://replit.com/@portkey/AI-Gateway?v=1)
342363
343-
<br>
364+
---
344365
345366
### Zeabur
346367
347368
[![Deploy on Zeabur](https://zeabur.com/button.svg)](https://zeabur.com/templates/RU38E3)
348369
349-
<br>
370+
---
350371
351-
### Vercel
372+
### Supabase Functions
373+
374+
1. Clone the Repository:
375+
376+
```sh
377+
git clone https://github.com/portkey-ai/gateway
378+
```
352379

353-
Docs to be written, please help!
380+
2. Set up a Supabase Account and create a new project (in browser).
381+
3. Install the Supabase CLI, login using `supabase login
382+
` and Initialize, follow [guides](https://supabase.com/docs/guides/local-development)
383+
4. Write Your Supabase Function in:
384+
```sh
385+
supabase/functions/your-function-file/index.ts
386+
```
387+
5. Deploy the Function (for windows add `npx` in start):
388+
```sh
389+
supabase functions deploy your-function-file
390+
```
391+
6. Now, its ready to Test, Monitor and Manage Functions (Using url from supabase dashboard):
392+
- Similar to `https://your-project-id.supabase.co/functions/v1/your-function-file`
393+
394+
Refer to [Supabase's official documentation](https://supabase.com/docs) for more details.
354395

355396
<br>
356397

398+
---
399+
357400
### Fastly
358401

359-
Docs to be written, please help!
402+
1. Create / login to your fastly account (in browser).
403+
404+
2. Clone the Gateway Repository:
405+
406+
```sh
407+
git clone https://github.com/portkey-ai/gateway
408+
```
409+
410+
3. Install Fastly’s CLI:
411+
412+
```sh
413+
npm install fastly-cli
414+
```
415+
416+
4. Log in to Fastly:
417+
```sh
418+
fastly login
419+
```
420+
421+
5. Create a New Fastly Service:
422+
```sh
423+
fastly compute init
424+
```
425+
426+
6. Write Your Edge Function Code in `src/main.rs` or `src/index.js`
427+
428+
7. Set up the token locally (token is located on `Account > User(left bottom most) > API Token`)
429+
```sh
430+
fastly profile create
431+
```
432+
Then follow the steps there to add token.
433+
434+
8. Deploy to Fastly
435+
```sh
436+
fastly compute publish
437+
```
438+
9. Now, its ready to Test, Monitor and Manage Functions (Using url from fastly dashboard):
439+
- Similar to `your-new-project.edgecompute.app`
440+
441+
For more details, refer to [Fastly’s official](https://www.fastly.com/products/edge-compute).
360442

361443
<br>
362444

363-
### AWS Lambda
445+
---
364446

365-
Docs to be written, please help!
447+
### Vercel
448+
449+
- Docs to be written, please help!
450+
- Make sure you've deployed and tested the same.
366451

367452
<br>
368453

369-
### Lambda@edge
454+
---
455+
456+
### AWS Lambda
370457

371-
Docs to be written, please help!
458+
- Docs to be written, please help!
459+
- Make sure you've deployed and tested the same.
372460

373461
<br>
374462

375-
### Supabase Functions
463+
---
464+
465+
### Lambda edge
376466

377-
Docs to be written, please help!
467+
- Docs to be written, please help!
468+
- Make sure you've deployed and tested the same.
378469

379470
<br>
380471

472+
---
473+
381474
## Enterprise Deployment
382475
Make your AI app more <ins>reliable</ins> and <ins>forward compatible</ins>, while ensuring complete <ins>data security</ins> and <ins>privacy</ins>.
383476

plugins/default/manifest.json

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,14 +595,14 @@
595595
}
596596
},
597597
{
598-
"name": "Model whitelisting",
598+
"name": "Allowed Models",
599599
"id": "modelwhitelist",
600600
"type": "guardrail",
601601
"supportedHooks": ["beforeRequestHook"],
602602
"description": [
603603
{
604604
"type": "subHeading",
605-
"text": "Check if the model in the request is part of the allowed model list."
605+
"text": "Blocks any request whose model isn’t on this list."
606606
}
607607
],
608608
"parameters": {
@@ -614,7 +614,7 @@
614614
"description": [
615615
{
616616
"type": "subHeading",
617-
"text": "Enter the allowed models."
617+
"text": "Enter the allowed models. e.g. gpt-4o, llama-3-70b, mixtral-8x7b"
618618
}
619619
],
620620
"items": {
@@ -627,7 +627,7 @@
627627
"description": [
628628
{
629629
"type": "subHeading",
630-
"text": "If true, the verdict will be true when model is not in the list"
630+
"text": "When on, any model in the list is blocked instead of allowed."
631631
}
632632
],
633633
"default": false
@@ -706,6 +706,49 @@
706706
},
707707
"required": ["jwksUri", "headerKey"]
708708
}
709+
},
710+
{
711+
"name": "Required Metadata Keys",
712+
"id": "requiredMetadataKeys",
713+
"type": "guardrail",
714+
"supportedHooks": ["beforeRequestHook"],
715+
"description": [
716+
{
717+
"type": "subHeading",
718+
"text": "Checks if the metadata contains all the required keys"
719+
}
720+
],
721+
"parameters": {
722+
"type": "object",
723+
"properties": {
724+
"metadataKeys": {
725+
"type": "array",
726+
"label": "Metadata Keys",
727+
"description": [
728+
{
729+
"type": "subHeading",
730+
"text": "Enter the metadata keys to check for."
731+
}
732+
],
733+
"items": {
734+
"type": "string"
735+
}
736+
},
737+
"operator": {
738+
"type": "string",
739+
"label": "Operator",
740+
"description": [
741+
{
742+
"type": "subHeading",
743+
"text": "Select the operator to use."
744+
}
745+
],
746+
"enum": ["all", "any", "none"],
747+
"default": "all"
748+
}
749+
},
750+
"required": ["metadataKeys", "operator"]
751+
}
709752
}
710753
]
711754
}

0 commit comments

Comments
 (0)