Skip to content

Commit

Permalink
feat(proxy): enable pre configured openai base url
Browse files Browse the repository at this point in the history
  • Loading branch information
ranst91 committed Aug 16, 2024
1 parent 938bf61 commit 76b7b33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ NX_BASE_API_URL="http://localhost:3000"
NX_SUPERTOKENS_API_DOMAIN="http://localhost:3000"
NX_SUPERTOKENS_WEBSITE_DOMAIN="http://localhost:4200"
NX_DEBUG_MODE="true"

# Pezzo config
OPENAI_API_BASE_URL="https://api.openai.com/v1"
4 changes: 3 additions & 1 deletion apps/proxy/src/lib/OpenAIHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { RequestWithPezzoClient } from "../types/common.types";
import { Response } from "express";
import axios from "axios";

const baseUrl = process.env.OPENAI_API_BASE_URL ?? "https://api.openai.com/v1";

export class OpenAIV1Handler {
constructor(private req: RequestWithPezzoClient, private res: Response) {}

Expand All @@ -16,7 +18,7 @@ export class OpenAIV1Handler {
try {
const result = await axios({
method,
url: `https://api.openai.com/v1/${url}`,
url: `${baseUrl}/${url}`,
data: this.req.body,
headers: {
Authorization: headers.authorization,
Expand Down

0 comments on commit 76b7b33

Please sign in to comment.