Helicone Community Page

Updated 2 months ago

Gemini

i'm also getting this error

Plain Text
HTTPSConnectionPool(host='gateway.helicone.ai', port=443): Max retries exceeded with url: /v1beta/models/gemini-1.5-flash-002:generateContent?%24alt=json%3Benum-encoding%3Dint (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2417)')))
J
F
3 comments
Hi! Can you share a bit more about your set up? What language? What environment
yeah sure! doing python and here's my code

Plain Text
genai_client = genai.configure(
    api_key=GEMINI_API_KEY,
    client_options={"api_endpoint": "gateway.helicone.ai"},
    default_metadata=[
        ('helicone-auth', f'Bearer {HELICONE_API_KEY}'),
        ('helicone-target-url', 'https://generativelanguage.googleapis.com'),
        ('Helicone-Posthog-Key', 'phc_Po7EZD7NU00cQbjso4HRPeHHAfzw2zfsONUJl0ZVQux'),
        ('Helicone-Posthog-Host', 'https://us.i.posthog.com'),
    ],
    transport="rest"
)

model = genai.GenerativeModel("gemini-1.5-flash-002")

def call_gemini_flash(prompt: str):
    response = model.generate_content(
        prompt, generation_config=GenerationConfig(
            max_output_tokens=8192,
            temperature=0,
        ))

    try:
        return response.text.strip().__str__()
    except Exception as e:
        log_info(response)
        return ""
also, one more thing, the prices aren't accurate when using Gemini, is there a way to fix that? I spent $0.6 playing around with it, Helicone is showing me $2.6
Add a reply
Sign up and join the conversation on Discord