Helicone Community Page

Updated 2 months ago

Hey I can do it for vercel ai sdk + groq with the

At a glance

The community member is trying to use the Vercel AI SDK with Gemini, similar to how they are using it with GROQ. They have provided the code for using GROQ, but are unsure about the baseURL for Gemini. The comments suggest trying the gateway URL and adding the "Helicone-Target-Url" header, but the community member reports that this approach did not work and resulted in a CORS error. The community members discuss the possibility of using a backend endpoint to route the traffic, but the original poster is building a web extension and wants to keep everything local. There is no explicitly marked answer in the comments.

Useful resources
Hey
I can do it for vercel ai sdk + groq with the following code:
Plain Text
createGroq({
    apiKey,
    baseURL: "https://groq.helicone.ai/openai/v1",
    headers: {
        "Helicone-Auth": `Bearer ${process.env.PLASMO_PUBLIC_HELICONE_API_KEY}`,
    },
});

so, my questions are:
  1. is it possible to do the similar thing for vercel ai sdk + gemini.
  2. if yes, then what's the baseURL for gemini?
thanks
H
J
6 comments
btw, I'm not using "Vertex AI", just gemini.
ie, the following:
Plain Text
createGoogleGenerativeAI({
    apiKey,
    baseURL: ???,
    headers: {
        "Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`,
    },
})
Hi! Not sure never tested this. Can you try gateway? And can you add the target url header like this?

https://docs.helicone.ai/integrations/gemini/api/python
yes, I did, no luck.
Plain Text
createGoogleGenerativeAI({
    apiKey,
    baseURL: `https://gateway.helicone.ai/v1beta/models/model-name:generateContent?key=${apiKey}`, <-- from the gemini js doc
    headers: {
        "Helicone-Auth": `Bearer ${process.env.PLASMO_PUBLIC_HELICONE_API_KEY}`,
        "Helicone-Target-Url":
        "https://generativelanguage.googleapis.com",
    },
})

it failed at the preflight phase, cors error. I'm working on a web extension, everything happens in the browser only. all api keys are saved in the browser local storage.
but, the interesting thing is that the code for groq works great in the same env, 🀣 .
Yeah, I would recommend adding a backend endpoint to route the traffic through.

for GROQ are you using the groq.helicone.ai or gateway.helicone.ai?
Yeah, I would recommend adding a backend endpoint to route the traffic through.
I'm building a web extension with everything locally, 🀣

for GROQ are you using the groq.helicone.ai or gateway.helicone.ai?
baseURL: "https://groq.helicone.ai/openai/v1",

since vercel ai sdk also supports gemini and "groq + vercel ai sdk" can work for this extension, it's really great to support "gemini + vercel ai sdk" too, then for the same tech stack, the same behaviour, πŸ™‚ , thanks.
Add a reply
Sign up and join the conversation on Discord