Integrate any custom LLM with Helicone using the TypeScript Manual Logger. Step-by-step guide for NodeJS implementation to connect your proprietary or open-source models.
To get started, install the `@helicone/helpers` package
Set `HELICONE_API_KEY` as an environment variable
Create a new HeliconeManualLogger instance
Log your request
HeliconeLogBuilder
provides a simplified way to handle streaming LLM responses with better error handling and async support. It’s created using the logBuilder
method of HeliconeManualLogger
.
setError(error: any)
: Sets an error that occurred during the requesttoReadableStream<T>(stream: Stream<T>)
: Collects streaming responses and converts them to a readable stream while capturing the response for loggingsetResponse(body: string)
: Sets the response body for non-streaming responsessendLog()
: Sends the log to Heliconerequest
: HeliconeLogRequest
- The request object to logoperation
: (resultRecorder: HeliconeResultRecorder) => Promise<T>
- The operation to be executed and loggedadditionalHeaders
: Record<string, string>
HeliconeManualLogger
class provides several methods for logging different types of requests and responses. Here’s a comprehensive overview of each method:
request
: The request object to logoperation
: A function that performs the actual API call and records the resultsadditionalHeaders
: Optional additional headers to include with the log requestrequest
: The request object to logoperation
: A function that performs the streaming API call and attaches the stream to the recorderadditionalHeaders
: Optional additional headers to include with the log requestrequest
: The request object to logstream
: The ReadableStream to consume and logadditionalHeaders
: Optional additional headers to include with the log requestrequest
: The request object to logbody
: The response body as a stringadditionalHeaders
: Optional additional headers to include with the log requestrequest
: The request object to logadditionalHeaders
: Optional additional headers to include with the log requestafter
Function with Streamingafter
function to log streaming responses without blocking the client response: