Skip to main content
1
npm install @helicone/helpers
2
export HELICONE_API_KEY=<your-helicone-api-key>
3
import { HeliconeManualLogger } from "@helicone/helpers";

const heliconeLogger = new HeliconeManualLogger({
  apiKey: process.env.HELICONE_API_KEY,
  headers: {} // Additional headers sent with the request (optional)
});
4
const tools = [{
  "type": "function",
  "function": {
    "name": "getWeather",
    "description": "Get current temperature for a given location.",
    "parameters": {
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": "City and country e.g. Bogotá, Colombia"
            }
        },
        "required": [
            "location"
        ],
        "additionalProperties": false
    },
    "strict": true
  }
}];

const request = await heliconeLogger.logRequest(
  tools,
  async (resultRecorder) => {
    // The actual tool call
    const response = await fetch("https://api.openai.com/v1/chat/completions", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${process.env.OPENAI_API_KEY}`
      },
      body: JSON.stringify({
        model: "gpt-4o-mini",
        messages: [
          {
            role: "user",
            content: "What's the weather like in Bogotá, Colombia?"
          }
        ],
        tools
      })
    });

    const results = await response.json();

    // Log the results to Helicone
    resultRecorder.appendResults({
      response: results,
      usage: results.usage,
      model: results.model
    });

    return results;
  },
  {
    "Helicone-Property-Session": "user-123" // Optional: Add session tracking or any custom properties
  }
);
5
For more complex examples including APIs, database queries, and document search, check out our full examples on GitHub.