diff --git a/utils/const.ts b/utils/const.ts new file mode 100644 index 00000000..470f4b5c --- /dev/null +++ b/utils/const.ts @@ -0,0 +1,2 @@ +export const OPENAI_API_HOST = + process.env.OPENAI_API_HOST || 'https://api.openai.com'; \ No newline at end of file diff --git a/utils/index.ts b/utils/index.ts index da19d816..866d8ecd 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -4,6 +4,7 @@ import { ParsedEvent, ReconnectInterval, } from 'eventsource-parser'; +import { OPENAI_API_HOST } from './const'; const createPrompt = ( inputLanguage: string, @@ -82,7 +83,7 @@ export const OpenAIStream = async ( const system = { role: 'system', content: prompt }; - const res = await fetch(`https://api.openai.com/v1/chat/completions`, { + const res = await fetch(`${OPENAI_API_HOST}/v1/chat/completions`, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key || process.env.OPENAI_API_KEY}`,