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.
Helicone is an all-in-one, open-source LLM developer platform that provides:
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.
# 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
| Application Type | What Helicone Helps You Monitor |
|---|---|
| Chatbot Applications | Track conversation flows, user satisfaction, and costs |
| Agent Systems | Visualize complex agent interactions and tool usage |
| RAG Implementations | Monitor retrieval quality and overall system performance |
| Production LLM Applications | Ensure reliability, manage costs, and track KPIs |
| Prompt Engineering | Compare different prompt versions and their effectiveness |
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)
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)
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();
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)
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}")
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!")
After integrating Helicone with APIpie, you can access your dashboards and analyze your data:
For more information, see the Helicone documentation or their GitHub repository.
If you encounter any issues during the integration process, please reach out on APIpie Discord or Helicone Discord for assistance.
LiteLLM Integration Guide
Learn how to integrate LiteLLM with APIpie for unified access to multiple LLM providers through a consistent API.
AG2 (AutoGen) Integration Guide
Learn how to integrate AG2 (formerly AutoGen) with APIpie for building powerful multi-agent AI applications with minimal configuration.