Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/lib/fetchFromOpenAi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ export async function fetchFromOpenAi(
body: GPT4VCompletionRequest
): Promise<GPT4VCompletionResponse> {
const apiKey = providedApiKey ?? process.env.OPENAI_API_KEY

const apiUrl = process.env.OPENAI_API_URL || 'https://api.openai.com'
if (!apiKey) {
throw new Error(
'You need to provide an API key. Make sure OPENAI_API_KEY is set in your .env file.'
)
}

try {
const repsonse = await fetch('https://api.openai.com/v1/chat/completions', {
const repsonse = await fetch(`${apiUrl}/v1/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down