Skip to main content

Helicone Integration Guide

APIpieHelicone

This guide will walk you through integrating Helicone with APIpie, enabling comprehensive observability, monitoring, and analytics for your LLM applications with just a few lines of code.

What is Helicone?

Helicone is an all-in-one, open-source LLM developer platform that provides:

  • Observability: Track and monitor all your LLM requests with detailed logs and metrics
  • Analytics: Gain insights into usage patterns, costs, latency, and other key metrics
  • Tracing: Visualize the execution path of your LLM applications and agent systems
  • Prompt Management: Version and experiment with prompts using production data
  • Evaluations: Run automated evaluations on your LLM outputs
  • Security & Compliance: Enterprise-ready with SOC 2 and GDPR compliance

By connecting Helicone with APIpie, you can monitor all your LLM interactions across different models with minimal overhead, gaining valuable insights to optimize performance and costs.


Integration Steps

1. Create a Helicone Account

  • Register here: Helicone Registration
  • Helicone offers a generous free tier with 10,000 requests per month.

2. Create an APIpie Account

3. Add Credit to APIpie

4. Generate API Keys

  • APIpie API Key: APIpie API Keys
  • Helicone API Key: Navigate to your Helicone dashboard and generate an API key

5. Install Required Libraries

# For Python
pip install openai
# or
pip install together # If you're using the Together AI client

For JavaScript/TypeScript:

# For Node.js
npm install openai
# or
yarn add openai
# or
pnpm add openai

Key Features

  • One-line Integration: Add observability to your LLM applications with minimal code changes
  • Real-time Monitoring: Track request volume, costs, latency, and more in real-time
  • Session & Trace Analysis: Analyze complex agent systems and multi-step LLM workflows
  • Cost Management: Track spending across models and optimize for cost-efficiency
  • Prompt Management: Version control and optimize your prompts
  • Caching: Reduce costs and improve performance with built-in caching

Example Workflows

Application TypeWhat Helicone Helps You Monitor
Chatbot ApplicationsTrack conversation flows, user satisfaction, and costs
Agent SystemsVisualize complex agent interactions and tool usage
RAG ImplementationsMonitor retrieval quality and overall system performance
Production LLM ApplicationsEnsure reliability, manage costs, and track KPIs
Prompt EngineeringCompare different prompt versions and their effectiveness

Using Helicone with APIpie

Basic Python Integration (Base URL Method)

import os
import openai

# Configure the client with Helicone proxy and APIpie key
client = openai.OpenAI(
api_key=os.environ.get("APIPIE_API_KEY"), # Your APIpie API key
base_url=f"https://oai.hconeai.com/v1/{os.environ.get('HELICONE_API_KEY')}"
)

# Make requests as normal - Helicone will log them automatically
response = client.chat.completions.create(
model="gpt-4o-mini", # Use any model available on APIpie
messages=[
{"role": "user", "content": "What are some fun things to do in London?"}
]
)

print(response.choices[0].message.content)

Python Integration (Headers Method - More Secure)

import os
import openai

# Configure the client with Helicone headers
client = openai.OpenAI(
api_key=os.environ.get("APIPIE_API_KEY"), # Your APIpie API key
base_url="https://apipie.ai/v1", # APIpie endpoint
default_headers={
"Helicone-Auth": f"Bearer {os.environ.get('HELICONE_API_KEY')}"
}
)

# Make requests as normal - Helicone will log them automatically
response = client.chat.completions.create(
model="gpt-4o-mini", # Use any model available on APIpie
messages=[
{"role": "user", "content": "What are some fun things to do in London?"}
]
)

print(response.choices[0].message.content)

JavaScript/TypeScript Integration

import OpenAI from "openai";

// Configure the client with Helicone proxy
const openai = new OpenAI({
apiKey: process.env.APIPIE_API_KEY, // Your APIpie API key
baseURL: `https://oai.hconeai.com/v1/${process.env.HELICONE_API_KEY}`,
});

// Or use headers for more secure environments
const openaiWithHeaders = new OpenAI({
apiKey: process.env.APIPIE_API_KEY, // Your APIpie API key
baseURL: 'https://apipie.ai/v1', // APIpie endpoint
defaultHeaders: {
"Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`,
},
});

// Make requests as normal - Helicone will log them automatically
async function getCompletion() {
const response = await openai.chat.completions.create({
model: "gpt-4o-mini", // Use any model available on APIpie
messages: [
{ role: "user", content: "What are some fun things to do in London?" }
],
});

console.log(response.choices[0].message.content);
}

getCompletion();

Adding Custom Properties to Requests

Helicone allows you to add custom properties to your requests for better filtering and analysis:

import os
import openai

client = openai.OpenAI(
api_key=os.environ.get("APIPIE_API_KEY"), # Your APIpie API key
base_url="https://apipie.ai/v1", # APIpie endpoint
default_headers={
"Helicone-Auth": f"Bearer {os.environ.get('HELICONE_API_KEY')}",
"Helicone-Property-User-Id": "user_123", # Add custom user ID
"Helicone-Property-Session-Id": "session_abc", # Add session tracking
"Helicone-Property-App-Version": "1.2.3", # Track app version
}
)

response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "What are some fun things to do in London?"}
]
)

print(response.choices[0].message.content)

Caching Responses for Cost Optimization

Enable caching to avoid redundant API calls and reduce costs:

import os
import openai

client = openai.OpenAI(
api_key=os.environ.get("APIPIE_API_KEY"),
base_url="https://apipie.ai/v1",
default_headers={
"Helicone-Auth": f"Bearer {os.environ.get('HELICONE_API_KEY')}",
"Helicone-Cache-Enabled": "true" # Enable caching
}
)

# Make the same request multiple times - only the first will hit the API
for i in range(3):
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "What is the capital of France?"}
]
)
print(f"Request {i+1}: {response.choices[0].message.content}")

Tracking Feedback

Collect user feedback to evaluate model performance:

import os
import requests

def log_feedback(request_id, rating, comment=None):
"""Log user feedback for a specific request."""
url = "https://api.hconeai.com/v1/feedback"
headers = {
"Authorization": f"Bearer {os.environ.get('HELICONE_API_KEY')}",
"Content-Type": "application/json"
}
payload = {
"request_id": request_id,
"rating": rating, # 1 for bad 5 for good
"comment": comment
}
response = requests.post(url, headers=headers, json=payload)
return response.json()

# Use after getting a response
request_id = response.id # Get this from the Helicone response
log_feedback(request_id, 5, "Perfect answer!")

Viewing Your Data in Helicone

After integrating Helicone with APIpie, you can access your dashboards and analyze your data:

  1. Log in to your Helicone Dashboard
  2. View key metrics like request volume, costs, and latency
  3. Explore traces and sessions to understand user interactions
  4. Analyze prompt effectiveness and model performance
  5. Set up custom dashboards and alerts

Troubleshooting & FAQ

  • I'm not seeing any data in Helicone
    Ensure your API keys are correct and that you're making requests through the Helicone proxy or with the proper headers.

  • How does Helicone affect my API latency?
    Helicone adds minimal latency typically less than 10 to your requests when using their cloud version.

  • Is my data secure with Helicone?
    Yes, Helicone is SOC 2 and GDPR compliant. For maximum security, consider self-hosting Helicone using their Docker or Helm charts.

  • How can I filter requests in Helicone?
    Use custom properties in your headers to add metadata to requests, which can then be filtered in the dashboard.

  • Can I export my data from Helicone?
    Yes, Helicone provides APIs for data export, allowing you to integrate with your existing data pipelines or analytics tools.

  • Is there a self-hosted option?
    Yes, Helicone is open-source and can be self-hosted using Docker or Helm. See their documentation for details.

For more information, see the Helicone documentation or their GitHub repository.


Support

If you encounter any issues during the integration process, please reach out on APIpie Discord or Helicone Discord for assistance.