403 error while using gemini with open ai node library

    try {
      console.log("settings", settings);
      const openai = new OpenAI({
        apiKey: settings.openaiApiKey,
        baseURL: settings.aiUrl,
        dangerouslyAllowBrowser: true,
      });

      const model = settings.aiModel;
      const customPrompt = settings.customPrompt || "";

      const messages = [
        {
          role: "user" as const, // claude does not support system messages?
          content: `You are a helpful assistant specialized as a "${
            selectedAgent.name
          }". ${selectedAgent.systemPrompt}
            Rules:
            - Current time (JavaScript Date.prototype.toString): ${new Date().toString()}
            - User timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone}
            - User timezone offset: ${new Date().getTimezoneOffset()}
            - ${customPrompt ? `Custom prompt: ${customPrompt}` : ""}
            `,
        },
        ...chatMessages.map((msg) => ({
          role: msg.role as "user" | "assistant" | "system",
          content: msg.content,
        })),
        {
          role: "user" as const,
          content: `Context data: ${JSON.stringify(
            selectedAgent.dataSelector(
              results.filter((_, index) => selectedResults.has(index))
            )
          )}

          User query: ${floatingInput}`,
        },
      ];

      console.log("messages", messages);

      abortControllerRef.current = new AbortController();
      setIsStreaming(true);

      const stream = await openai.chat.completions.create(
        {
          model: model,
          messages: messages,
          stream: true,
        },
        {
          signal: abortControllerRef.current.signal,
        }
      );

i’m trying to use gemini with openai node library but i’m getting this error. i tried to search across the web but got no solution. how can fix this? please help!

Preflight response is not successful. Status code: 403
Fetch API cannot load https://generativelanguage.googleapis.com/v1beta/openal/chat/completions due to access control checks.
Failed to load resource: Preflight response is not successful. Status code: 403
https://generativelanguage.googleapis.com/v1beta/openai/chat/completions
Preflight response is not successful. Status code: 403
Fetch API cannot load https://generativelanguage.googleapis.com/v1beta/openal/chat/completions due to access control checks.
Failed to load resource: Preflight response is not successful. Status code: 403
https://generativelanguage.googleapis.com/v1beta/openai/chat/completions
Preflight response is not successful. Status code: 403
Fetch API cannot load https://generativelanguage.googleapis.com/v1beta/openai/chat/completions due to access control checks.
Failed to load resource: Preflight response is not successful. Status code: 403
https://generative language.googleapis.com/v1beta/openai/chat/completions
Error generating Al response: Error: Connection error