Skip to content

Commit 26e1d77

Browse files
committed
Merge branch 'main' of github.com:Portkey-AI/gateway into feat/ft-batch-improvements
2 parents c67d71d + a6fe2d9 commit 26e1d77

33 files changed

+560
-92
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
[![npm version](https://badge.fury.io/js/%40portkey-ai%2Fgateway.svg)](https://portkey.wiki/gh-8)
2323
[![Better Stack Badge](https://uptime.betterstack.com/status-badges/v1/monitor/q94g.svg)](https://portkey.wiki/gh-9)
2424

25-
<a href="https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?stackName=portkey-gateway&templateURL=https://portkey-gateway-ec2-quicklaunch.s3.us-east-1.amazonaws.com/portkey-gateway-ec2-quicklaunch.template.yaml"><img src="https://img.shields.io/badge/Deploy_to_EC2-232F3E?style=for-the-badge&logo=amazonwebservices&logoColor=white" alt="Deploy to AWS EC2" /></a>
25+
<a href="https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?stackName=portkey-gateway&templateURL=https://portkey-gateway-ec2-quicklaunch.s3.us-east-1.amazonaws.com/portkey-gateway-ec2-quicklaunch.template.yaml"><img src="https://img.shields.io/badge/Deploy_to_EC2-232F3E?style=for-the-badge&logo=amazonwebservices&logoColor=white" alt="Deploy to AWS EC2" width="105"/></a> [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/Portkey-AI/gateway)
2626
</div>
2727

2828
<br/>

package-lock.json

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/azure/contentSafety.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Agent } from 'https';
12
import {
23
HookEventType,
34
PluginContext,
@@ -63,7 +64,7 @@ export const handler: PluginHandler<{
6364

6465
const apiVersion = parameters.apiVersion || '2024-11-01';
6566

66-
const url = `https://${credentials.resourceName}.cognitiveservices.azure.com/contentsafety/text:analyze?api-version=${apiVersion}`;
67+
const url = `${credentials.customHost || `https://${credentials.resourceName}.cognitiveservices.azure.com`}/contentsafety/text:analyze?api-version=${apiVersion}`;
6768

6869
const { token, error: tokenError } = await getAccessToken(
6970
credentials as any,
@@ -80,6 +81,17 @@ export const handler: PluginHandler<{
8081
};
8182
}
8283

84+
let agent: Agent | null = null;
85+
// privatelink doesn't contain a valid certificate, skipping verification if it's customHost.
86+
// SECURITY NOTE: The following disables SSL certificate validation for custom hosts.
87+
// This is necessary for Azure Private Link endpoints that may use self-signed certificates,
88+
// but should only be used with trusted private endpoints.
89+
if (credentials.customHost) {
90+
agent = new Agent({
91+
rejectUnauthorized: false,
92+
});
93+
}
94+
8395
const headers: Record<string, string> = {
8496
'Content-Type': 'application/json',
8597
'User-Agent': 'portkey-ai-plugin/',
@@ -100,7 +112,12 @@ export const handler: PluginHandler<{
100112
const timeout = parameters.timeout || 5000;
101113
let response;
102114
try {
103-
response = await post(url, request, { headers }, timeout);
115+
response = await post(
116+
url,
117+
request,
118+
{ headers, dispatcher: agent },
119+
timeout
120+
);
104121
} catch (e) {
105122
return { error: e, verdict: true, data };
106123
}

plugins/azure/manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@
123123
"tenantId": {
124124
"type": "string",
125125
"description": "Tenant ID for Azure Entra ID authentication"
126+
},
127+
"customHost": {
128+
"type": "string",
129+
"description": "Custom host for Azure AI services (Private Link etc.)"
126130
}
127131
},
128132
"anyOf": [

plugins/azure/pii.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Agent } from 'https';
12
import {
23
HookEventType,
34
PluginContext,
@@ -29,7 +30,7 @@ const redact = async (
2930

3031
const apiVersion = parameters.apiVersion || '2024-11-01';
3132

32-
const url = `https://${credentials?.resourceName}.cognitiveservices.azure.com/language/:analyze-text?api-version=${apiVersion}`;
33+
const url = `${credentials?.customHost || `https://${credentials?.resourceName}.cognitiveservices.azure.com`}/language/:analyze-text?api-version=${apiVersion}`;
3334

3435
const { token, error: tokenError } = await getAccessToken(
3536
credentials as any,
@@ -53,8 +54,24 @@ const redact = async (
5354
throw new Error('Unable to get access token');
5455
}
5556

57+
let agent: Agent | null = null;
58+
// privatelink doesn't contain a valid certificate, skipping verification if it's customHost.
59+
// SECURITY NOTE: The following disables SSL certificate validation for custom hosts.
60+
// This is necessary for Azure Private Link endpoints that may use self-signed certificates,
61+
// but should only be used with trusted private endpoints.
62+
if (credentials?.customHost) {
63+
agent = new Agent({
64+
rejectUnauthorized: false,
65+
});
66+
}
67+
5668
const timeout = parameters.timeout || 5000;
57-
const response = await post(url, body, { headers }, timeout);
69+
const response = await post(
70+
url,
71+
body,
72+
{ headers, dispatcher: agent },
73+
timeout
74+
);
5875
return response;
5976
};
6077

plugins/azure/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export interface AzureCredentials {
55
clientId?: string;
66
clientSecret?: string;
77
tenantId?: string;
8+
customHost?: string;
89
}

plugins/panw-prisma-airs/manifest.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"id": "panwPrismaAirs",
33
"name": "PANW Prisma AIRS Guardrail",
44
"description": "Blocks prompt/response when Palo Alto Networks Prisma AI Runtime Security returns action=block.",
5-
"credentials": [
6-
{
7-
"id": "AIRS_API_KEY",
8-
"name": "AIRS API Key",
9-
"type": "string",
10-
"required": true
11-
}
12-
],
5+
"credentials": {
6+
"type": "object",
7+
"properties": {
8+
"AIRS_API_KEY": {
9+
"type": "string",
10+
"label": "AIRS API Key",
11+
"description": "The API key for Palo Alto Networks Prisma AI Runtime Security",
12+
"encrypted": true
13+
}
14+
},
15+
"required": ["AIRS_API_KEY"]
16+
},
1317
"functions": [
1418
{
1519
"id": "intercept",

plugins/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HookEventType, PluginContext } from './types';
22

33
interface PostOptions extends RequestInit {
44
headers?: Record<string, string>;
5+
[key: string]: any;
56
}
67

78
export interface ErrorResponse {

src/globals.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ export const RECRAFTAI: string = 'recraft-ai';
9292
export const MILVUS: string = 'milvus';
9393
export const REPLICATE: string = 'replicate';
9494
export const LEPTON: string = 'lepton';
95+
export const KLUSTER_AI: string = 'kluster-ai';
9596
export const NSCALE: string = 'nscale';
97+
export const HYPERBOLIC: string = 'hyperbolic';
9698

9799
export const VALID_PROVIDERS = [
98100
ANTHROPIC,
@@ -150,7 +152,9 @@ export const VALID_PROVIDERS = [
150152
REPLICATE,
151153
POWERED_BY,
152154
LEPTON,
155+
KLUSTER_AI,
153156
NSCALE,
157+
HYPERBOLIC,
154158
];
155159

156160
export const CONTENT_TYPES = {

src/handlers/handlerUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ export async function tryPost(
324324
fn,
325325
c,
326326
gatewayRequestURL: c.req.url,
327+
params: params,
327328
}));
328329
const endpoint =
329330
fn === 'proxy'

0 commit comments

Comments
 (0)