Manual Logger - cURL
Integrate any custom LLM with Helicone using cURL. Step-by-step guide for direct API integration to connect your proprietary or open-source models.
cURL Manual Logger
You can log custom model calls directly to Helicone using cURL or any HTTP client that can make POST requests.
Request Structure
A typical request will have the following structure:
Endpoint
Headers
Name | Value |
---|---|
Authorization | Bearer {API_KEY} |
Replace {API_KEY}
with your actual Helicone API Key.
Body
The request body follows this structure:
Example Usage
Here’s a complete example of logging a request to a custom model:
Note: The
timing
field is optional. If not provided, Helicone will automatically set the current time as both start and end time.
Token Tracking
Helicone supports token tracking for custom model integrations. To enable this, include a usage
object in your providerResponse.json
. Here are the supported formats:
OpenAI-style Format
Anthropic-style Format
Google-style Format
Alternative Format
If your model returns token counts in a different format, you can transform the response to match one of these formats before logging to Helicone. If no token information is provided, Helicone will still log the request but token metrics will not be available.
Advanced Usage
Adding Custom Properties
You can add custom properties to your requests by including them in the meta
field:
Session Tracking
To group requests into sessions, include a session ID in the meta
field:
User Tracking
To associate requests with specific users, include a user ID in the meta
field:
Calculating Timing Information
The timing information is optional but recommended for accurate latency metrics. It should be calculated as follows:
- Record the start time before making your request to the LLM provider
- Record the end time after receiving the response
- Convert these times to Unix epoch format (seconds and milliseconds)
Regional Support: Helicone supports both US and EU regions for caching. In development/preview environments, both regions use the same cache URL, while in production they use region-specific endpoints.
Example in JavaScript:
Complete Example with Python Requests
Here’s a complete example using Python’s requests
library:
For more examples and detailed usage, check out our Manual Logger with Streaming cookbook.
Examples
Basic Example
String Response Example
You can now log string responses directly using the textBody
field:
Time to First Token Example
For streaming responses, you can include the time to first token:
Note that timeToFirstToken
is measured in milliseconds.
Was this page helpful?