1

To get started, install the @helicone/helpers package

npm install @helicone/helpers
2

Set up your Helicone API key in your .env file

Log into Helicone or create an account. Once you have an account, you can generate an API key here.
export HELICONE_API_KEY=<your-helicone-api-key>
3

Create a new HeliconeManualLogger instance

import { HeliconeManualLogger } from "@helicone/helpers";

const heliconeLogger = new HeliconeManualLogger({
  apiKey: process.env.HELICONE_API_KEY,
  headers: {} // Additional headers sent with the request (optional)
});
4

Log your request

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-3.5-turbo",
        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

Verify your requests in Helicone

With the above setup, any calls to any tool will automatically be logged and monitored by Helicone. Review them in your Helicone dashboard.

For more complex examples including APIs, database queries, and document search, check out our full examples on GitHub.

To learn more about the HeliconeManualLogger API, see the API Reference here.