Skip to content

Commit

Permalink
feat: openai-project openai-organization headers added
Browse files Browse the repository at this point in the history
  • Loading branch information
csgulati09 committed May 21, 2024
1 parent 2ad6b09 commit 6524a16
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/_types/generalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ 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;
}

export interface APIResponseType {
Expand Down
4 changes: 2 additions & 2 deletions src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export abstract class ApiClient {
portkeyHeaders: Record<string, string>

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 }: 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, openaiProject, openaiOrganization })
this.portkeyHeaders = this.defaultHeaders()
this.fetch = fetch;
this.responseHeaders = {}
Expand Down
12 changes: 10 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ 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;
constructor({
apiKey = readEnv("PORTKEY_API_KEY") ?? null,
baseURL = readEnv("PORTKEY_BASE_URL") ?? null,
Expand All @@ -29,6 +31,8 @@ export class Portkey extends ApiClient {
cacheForceRefresh,
debug,
customHost,
openaiProject,
openaiOrganization
}: ApiClientInterface) {

super({
Expand All @@ -42,7 +46,9 @@ export class Portkey extends ApiClient {
Authorization,
cacheForceRefresh,
debug,
customHost
customHost,
openaiProject,
openaiOrganization
});

this.apiKey = apiKey;
Expand All @@ -57,7 +63,9 @@ export class Portkey extends ApiClient {
this.metadata = metadata
this.cacheForceRefresh = cacheForceRefresh;
this.debug = debug;
this.customHost = customHost
this.customHost = customHost;
this.openaiProject = openaiProject;
this.openaiOrganization = openaiOrganization;
}

completions: API.Completions = new API.Completions(this);
Expand Down

0 comments on commit 6524a16

Please sign in to comment.