diff --git a/package-lock.json b/package-lock.json index 151d345..3d29014 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "portkey-ai", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "portkey-ai", - "version": "1.3.0", + "version": "1.3.1", "license": "MIT", "dependencies": { "agentkeepalive": "^4.5.0", @@ -3295,12 +3295,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -4141,9 +4141,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" diff --git a/package.json b/package.json index f29ad02..4247d3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "portkey-ai", - "version": "1.3.0", + "version": "1.3.1", "description": "Node client library for the Portkey API", "types": "dist/src/index.d.ts", "main": "dist/src/index.js", diff --git a/src/_types/generalTypes.ts b/src/_types/generalTypes.ts index d1a785a..b2359bc 100644 --- a/src/_types/generalTypes.ts +++ b/src/_types/generalTypes.ts @@ -11,7 +11,22 @@ export interface ApiClientInterface { Authorization?: string | null | undefined; cacheForceRefresh?: boolean | null | undefined; debug?: boolean | null | undefined; - customHost?: string | null | undefined + customHost?: string | null | undefined; + openaiProject?: string | null | undefined; + openaiOrganization?: string | null | undefined; + awsSecretAccessKey?: string | null | undefined; + awsAccessKeyId?: string | null | undefined; + awsSessionToken?: string | null | undefined; + awsRegion?: string | null | undefined; + vertexProjectId?: string | null | undefined; + vertexRegion?: string | null | undefined; + workersAiAccountId?: string | null | undefined; + azureResourceName?: string | null | undefined; + azureDeploymentId?: string | null | undefined; + azureApiVersion?: string | null | undefined; + forwardHeaders?: Array | null | undefined; + cacheNamespace?: string | null | undefined; + requestTimeout?: number | null | undefined; } export interface APIResponseType { diff --git a/src/apis/chatCompletions.ts b/src/apis/chatCompletions.ts index a956fe0..3caba71 100644 --- a/src/apis/chatCompletions.ts +++ b/src/apis/chatCompletions.ts @@ -49,6 +49,7 @@ class ChatCompletions extends ApiResource { export interface ChatCompletionsBodyBase extends ModelParams { messages?: Array; + response_format?: object; } export interface ChatCompletionsBodyStreaming extends ChatCompletionsBodyBase { diff --git a/src/apis/createHeaders.ts b/src/apis/createHeaders.ts index b63e4fb..54b9bc2 100644 --- a/src/apis/createHeaders.ts +++ b/src/apis/createHeaders.ts @@ -18,6 +18,12 @@ export const createHeaders = (config: Record): Record `-${letter.toLowerCase()}`) if (!isEmpty(v) && typeof v == "object") { diff --git a/src/baseClient.ts b/src/baseClient.ts index dbf6937..bf1630d 100644 --- a/src/baseClient.ts +++ b/src/baseClient.ts @@ -120,10 +120,10 @@ export abstract class ApiClient { portkeyHeaders: Record private fetch: Fetch; - constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost }: ApiClientInterface) { + constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, forwardHeaders, cacheNamespace, requestTimeout }: ApiClientInterface) { this.apiKey = apiKey ?? ""; this.baseURL = baseURL ?? ""; - this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost }) + this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost, cacheNamespace, openaiProject, openaiOrganization, awsSecretAccessKey, awsAccessKeyId, awsSessionToken, awsRegion, vertexProjectId, vertexRegion, workersAiAccountId, azureResourceName, azureDeploymentId, azureApiVersion, forwardHeaders, requestTimeout }) this.portkeyHeaders = this.defaultHeaders() this.fetch = fetch; this.responseHeaders = {} diff --git a/src/client.ts b/src/client.ts index 23559d5..37bf3aa 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6,8 +6,8 @@ import { MISSING_API_KEY_ERROR_MESSAGE, PORTKEY_BASE_URL } from "./constants"; import { castToError, readEnv } from "./utils"; export class Portkey extends ApiClient { - override apiKey: string | null; - override baseURL: string; + declare apiKey: string | null; + declare baseURL: string; virtualKey: string | null; config: Record | string | null | undefined; provider: string | null | undefined; @@ -17,6 +17,21 @@ export class Portkey extends ApiClient { cacheForceRefresh?: boolean | null | undefined; debug?: boolean | null | undefined; customHost?: string | null | undefined; + openaiProject?: string | null | undefined; + openaiOrganization?: string | null | undefined; + awsSecretAccessKey?: string | null | undefined; + awsAccessKeyId?: string | null | undefined; + awsSessionToken?: string | null | undefined; + awsRegion?: string | null | undefined; + vertexProjectId?: string | null | undefined; + vertexRegion?: string | null | undefined; + workersAiAccountId?: string | null | undefined; + azureResourceName?: string | null | undefined; + azureDeploymentId?: string | null | undefined; + azureApiVersion?: string | null | undefined; + forwardHeaders?: Array | null | undefined; + requestTimeout?: number | null | undefined; + cacheNamespace?: string | null | undefined; constructor({ apiKey = readEnv("PORTKEY_API_KEY") ?? null, baseURL = readEnv("PORTKEY_BASE_URL") ?? null, @@ -29,6 +44,21 @@ export class Portkey extends ApiClient { cacheForceRefresh, debug, customHost, + openaiProject, + openaiOrganization, + awsSecretAccessKey, + awsAccessKeyId, + awsSessionToken, + awsRegion, + vertexProjectId, + vertexRegion, + workersAiAccountId, + azureResourceName, + azureDeploymentId, + azureApiVersion, + forwardHeaders, + cacheNamespace, + requestTimeout, }: ApiClientInterface) { super({ @@ -42,7 +72,22 @@ export class Portkey extends ApiClient { Authorization, cacheForceRefresh, debug, - customHost + customHost, + cacheNamespace, + openaiProject, + openaiOrganization, + awsSecretAccessKey, + awsAccessKeyId, + awsSessionToken, + awsRegion, + vertexProjectId, + vertexRegion, + workersAiAccountId, + azureResourceName, + azureDeploymentId, + azureApiVersion, + forwardHeaders, + requestTimeout, }); this.apiKey = apiKey; @@ -57,7 +102,22 @@ export class Portkey extends ApiClient { this.metadata = metadata this.cacheForceRefresh = cacheForceRefresh; this.debug = debug; - this.customHost = customHost + this.customHost = customHost; + this.cacheNamespace = cacheNamespace;; + this.openaiProject = openaiProject; + this.openaiOrganization = openaiOrganization; + this.awsSecretAccessKey = awsSecretAccessKey; + this.awsAccessKeyId = awsAccessKeyId; + this.awsSessionToken = awsSessionToken; + this.awsRegion = awsRegion; + this.vertexProjectId = vertexProjectId; + this.vertexRegion = vertexRegion; + this.workersAiAccountId = workersAiAccountId; + this.azureResourceName = azureResourceName; + this.azureDeploymentId = azureDeploymentId; + this.azureApiVersion = azureApiVersion; + this.forwardHeaders = forwardHeaders; + this.requestTimeout = requestTimeout; } completions: API.Completions = new API.Completions(this);