Helicone Community Page

Updated 4 months ago

Integration with VertexAI does not work

I made the correct settings using VertexAI (enterprise), but the requests do not appear in helicone.
1
D
C
f
26 comments
To resolve the issue of VertexAI requests not appearing in Helicone, follow these steps to ensure your setup is correctly configured:

  1. Create an Account and Generate API Keys:
  1. Set API Keys as Environment Variables:
    • Ensure your API keys are set as environment variables:
      Plain Text
      export HELICONE_API_KEY=<your API key>
      export GCLOUD_API_KEY=<your Google Cloud API key>
  1. Install Necessary Packages:
    • Make sure you have the required packages installed in your JavaScript project:
      Plain Text
      npm install @google-cloud/vertexai
  1. Import VertexAI and Configure the Client:
    • Import the VertexAI module and configure the client with your project details:
      ```javascript
      import { VertexAI } from "@google-cloud/vertexai";
const vertex_ai = new VertexAI({
project: "your-project-id",
location: "your-location",
apiEndpoint: "gateway.helicone.ai",
});
Plain Text
5. **Set Up Custom Headers**:
   - Define custom headers to include the Helicone authentication and target URL:
     
javascript
const customHeaders = new Headers({
"Helicone-Auth": Bearer ${process.env.HELICONE_API_KEY},
"Helicone-Target-URL": https://${LOCATION}-aiplatform.googleapis.com,
});
Plain Text
6. **Define Request Options**:
   - Set up the request options to include the custom headers:
     
javascript
const requestOptions = {
customHeaders: customHeaders,
} as RequestOptions;
Plain Text
7. **Get the Generative Model**:
   - Retrieve the generative model using the VertexAI client:
     
javascript
const generativeModel = vertex_ai.preview.getGenerativeModel(
{
model: "model-name"
},
requestOptions // Pass request options
);
```
  1. Generate Content:
    • Make a request to generate content and log the result:
      Plain Text
      const result = await generativeModel.generateContent({
        contents: [{ role: "user", parts: [{ text: "How are you doing today?" }] }],
      });
      console.log(result);
By following these steps, you should be able to correctly configure your VertexAI requests to appear in Helicone. Ensure that all environment variables and headers are correctly set to avoid any misconfigurations. source
hi , could you share more about your integration?
Apologies about the late response! I would love to hop on this and fix it for you.
Hi, , sorry for the delay, I only saw the reply now because we tried again yesterday and it didn't work.
here is the implementation
Attachments
image.png
image.png
Hi , any feedback?
Hi, will take a look in just a minute
Hi , could you try a few things:

  1. Mint a new Helicone API key and use that one
  2. Make sure you explicitly cast:
Plain Text
const requestOptions = {
  customHeaders: customHeaders,
} as RequestOptions;


Please let me know if that helps.
now it worked, thanks!
No problem! If you're interested, I'd love to have a quick 15 minute chat: https://cal.com/cole-gottdank/15min
another question, I'm using Azure OpenAI with stream and the tokens don't appear...
Attachment
image.png
Will share that with the team
ok, thanks! can i wait in this ticket right here or open another one for that?
Could you open a new one?
Now another problem has arisen. When I send a request with a document, it gives an error
Attachment
image.png
Hi, are you able to schedule a call with me?
ah, i managed to solve it! it was my mistake, thanks!
Hi @fsdiasv what was the issue? Is there something we can add to our docs to help with this?
it was our mistake here. the region was different in the helicone header compared to the class region
Add a reply
Sign up and join the conversation on Discord