Request Structure

A typical request will have the following structure:

Endpoint

POST https://api.worker.helicone.ai/custom/v1/log

Note: The endpoint may vary depending on your Helicone setup. If the above endpoint doesn’t work, you can also try:

  • https://api.us.helicone.ai/custom/v1/log
  • https://api.helicone.ai/custom/v1/log

Headers

NameValue
AuthorizationBearer {API_KEY}

Replace {API_KEY} with your actual API Key.

Body

export type HeliconeAsyncLogRequest = {
  providerRequest: ProviderRequest;
  providerResponse: ProviderResponse;
  timing: Timing;
};

export type ProviderRequest = {
  url: "custom-model-nopath";
  json: {
    _type: "tool";
    toolName: string;
    input: any;
    [key: string]: any;
  };
  meta: Record<string, string>;
};

export type ProviderResponse = {
  json: {
    _type?: "tool";
    toolName: string;
    [key: string]: any;
  };
  status: number;
  headers: Record<string, string>;
};

export type Timing = {
  // From Unix epoch in Milliseconds
  startTime: {
    seconds: number;
    milliseconds: number;
  };
  endTime: {
    seconds: number;
    milliseconds: number;
  };
};

Example Usage

curl -X POST https://api.worker.helicone.ai/custom/v1/log \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
  "providerRequest": {
    "url": "custom-model-nopath",
    "json": {
      "_type": "tool",
      "toolName": "weather_api",
      "input": {
        "location": "San Francisco",
        "units": "celsius"
      }
    },
    "meta": {
      "user_id": "user_123",
      "session_id": "session_456",
      "environment": "production"
    }
  },
  "providerResponse": {
    "json": {
      "_type": "tool",
      "toolName": "weather_api",
      "temperature": 18.5,
      "conditions": "Partly Cloudy",
      "humidity": 72,
      "wind": {
        "speed": 12,
        "direction": "NW"
      }
    },
    "status": 200,
    "headers": {
      "content-type": "application/json",
      "cache-control": "max-age=300"
    }
  },
  "timing": {
    "startTime": {
      "seconds": 1625686222,
      "milliseconds": 500
    },
    "endTime": {
      "seconds": 1625686223,
      "milliseconds": 750
    }
  }
}'