Helicone Community Page

Updated 6 months ago

TypeError: Cannot read properties of undefined (reading '0')

At a glance

The post contains code for setting up providers for OpenAI, Anthropic, and GROQ using the Helicone API. The community members are encountering an error with the OpenAI provider, specifically a TypeError related to undefined properties. They have provided some additional context, such as the versions of the @ai-sdk/anthropic and @ai-sdk/openai packages they are using, and have identified that the issue seems to be related to the Helicone-Moderations-Enabled header when using the GPT-4 model. The community members are seeking help to resolve this issue.

Useful resources
Plain Text
{"helicone-message":"Helicone ran into an error servicing your request: TypeError: Cannot read properties of undefined (reading '0')","support":"Please reach out on our discord or email us at [email protected], we'd love to help!","helicone-error":"{}"}


Plain Text
import { createAnthropic } from "@ai-sdk/anthropic";
import { createOpenAI } from "@ai-sdk/openai";

export const heliconeDefaultHeaders = {
  "Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`,
  "Helicone-Cache-Enabled": "true",
  "Helicone-Moderations-Enabled": "true",
  "Helicone-LLM-Security-Enabled": "true",
  "Helicone-Retry-Enabled": "true",
  "Helicone-Retry-Num": "7",
  "Helicone-Retry-Min-Timeout": "1000",
};

export const openaiprovider = createOpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: "https://oai.helicone.ai/v1",
  headers: heliconeDefaultHeaders,
});

export const anthropicprovider = createAnthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
  baseURL: "https://anthropic.helicone.ai/v1",
  headers: heliconeDefaultHeaders,
});

export const groqprovider = createOpenAI({
  apiKey: process.env.GROQ_API_KEY,
  baseUrl: "https://groq.helicone.ai/openai/v1",
  headers: heliconeDefaultHeaders,
});
e
C
5 comments
^ getting this on the openAI provider, used to work totally fine πŸ€”
Plain Text
    "@ai-sdk/anthropic": "^0.0.39",
    "@ai-sdk/openai": "^0.0.44",
Yo! Did a bunch of testing, this seems to happen for me with the header
Plain Text
"Helicone-Moderations-Enabled": "true",

on gpt-4o models (using the latest one, at least, gpt-4o-2024-08-06)
Oh thank you
Heyo! Lmk if this was fixed πŸ™ Want to put it back into my code, hahah!
Add a reply
Sign up and join the conversation on Discord