Helicone Community Page

Updated 4 months ago

Helicone Integration with OpenAI in NodeJS

I am integrating helicone with the openAI(with gpt-4 model) in nodejs, getting unauthorized error(401), even after providing the proper helicone api key and gpt api key , followed the documentation of the helicone but those functions of openAI are not working with nodejs
1
J
B
C
37 comments
Hi there! Are you using our package or are you using the OpenAI client? (Can you share a code snippet)
Using Helicone package
const { HeliconeProxyOpenAIApi : OpenAI} = require("helicone");

const openai = new OpenAI({
apiKey: process.env.GPT_API_KEY,
heliconeMeta : {
apiKey : process.env.HELICONE_API_KEY
}
});

const GPT = async (prompt) => {
try{

let response = await openai.createChatCompletion({
model: "gpt-4",
messages: [{ role: "user", content: prompt }],
});
console.log('RESPONSE ::: ', response);
return response;
}catch(err){
console.log('ERR', err);
return err;
}
}
getting unauthorized access, even after providing proper GPT as well as Helovine Key
Hitting a 401 makes me suspect that it is OpenAI declining the apiKey. If you fail to authenticate with Helicone, we will not return a 401, we will continue to process your request as normal as we don't want to cause any errors in your critical path.

Would you be able to try a different ApiKey? Also, we have a new Helicone node package that supports OpenAI V4 (I recommend using this one):

https://www.npmjs.com/package/@helicone/helicone
Additionally, could you add me to your Helicone org? [email protected]

Thank you!
normally chatGPT is working, when I am integrating it with the Helicone (@helicone/helicone) package, I am getting this 401 status code error
so i thinks there is some issue with the Helicone API Key or package
there very well could be an issue with the package. I noticed you are using the proxy would you mind trying using OpenAI's native package with this integration method?

https://docs.helicone.ai/getting-started/integration-method/openai-proxy


Plain Text
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: request.env.OPENAI_API_KEY,
  baseURL: "https://oai.hconeai.com/v1",
  defaultHeaders: {
    "Helicone-Auth": `Bearer ${request.env.HELICONE_API_KEY}`,
  },
});
Attachment
Screenshot_2023-10-31_at_10.37.34_PM.png
openAI package or helicone package?
bcz the methods which u mentioned in the documentation, those methods are not present with the packages, methods are present with some different names
export * from "./async_logger/HeliconeAsyncLogger"; export * from "./async_logger/HeliconeAsyncOpenAI"; export * from "./async_logger/HeliconeLogger"; export * from "./async_logger/HeliconeMonkeyPatch"; export * from "./async_logger/HeliconeOpenAITypes"; export * from "./core/HeliconeClientOptions"; export * from "./core/HeliconeFeedback"; export * from "./core/HeliconeHeaderBuilder"; export * from "./core/HeliconeOpenAIApi"; export * from "./proxy_logger/HeliconeProxyOpenAI";
The OpenAI package
no helicone package
Just to make sure it works
const heliconeClient = new OpenAI({
apiKey : process.env.HELICONE_API_KEY,
baseURL: "https://oai.hconeai.com/v1",
defaultHeaders: {
"Helicone-Auth": Bearer ${process.env.HELICONE_API_KEY},
},
})
which functions to use after this
can you please provide it
Does this work? Have you tried that code block?
yaa this much part worked
need the furthur function name which will help me to send logs onto the helicone
Sorry I am a bit lost- what is the furthur?
like after this which function will help me of helicone to send the logs onto the helicone server
This should just work
Do you see the logs in Helicone?
What happens when you log in?
Are you free tomorrow to hop on a call?
Thanks for the help
No problem!
can i downgrade my paid version to free version of helicone
Just unsubscribe in the usage page
will i get the refund ?
You will have access to pro until the end of the pay period and then it will cancel!
Add a reply
Sign up and join the conversation on Discord