Skip to main content
Helicone OSS LLM Observability

Manual Logger - Python

Integrate any custom LLM with Helicone using the Python Manual Logger. Step-by-step guide for Python implementation to connect your proprietary or open-source models.
2 min read

Python Manual Logger#

Logging calls to custom models is supported via the Helicone Python SDK.

Install the Helicone helpers package

Set `HELICONE_API_KEY` as an environment variable

Info
You can also set the Helicone API Key in your code (See below)

Create a new HeliconeManualLogger instance

Define your operation and make the request

API Reference#

HeliconeManualLogger#

LoggingOptions#

log_request#

Parameters#

  1. request: A dictionary containing the request parameters
  2. operation: A callable that takes a HeliconeResultRecorder and returns a result
  3. additional_headers: Optional dictionary of additional headers
  4. provider: Optional provider specification ("openai", "anthropic", or None for custom)

send_log#

Parameters#

  1. provider: Optional provider specification ("openai", "anthropic", or None for custom)
  2. request: A dictionary containing the request parameters
  3. response: Either a dictionary or string response to log
  4. options: A LoggingOptions dictionary with timing information

HeliconeResultRecorder#

Advanced Usage Examples#

Direct Logging with String Response#

For direct logging of string responses:

Streaming Responses#

For streaming responses with Python, you can use the log_request method with time to first token tracking:

Using with Anthropic#

Custom Model Integration#

For custom models that don't have a specific provider integration:

For more examples and detailed usage, check out our Manual Logger with Streaming cookbook.

Direct Stream Logging#

For direct control over streaming responses, you can use the send_log method to manually track time to first token:

This approach gives you complete control over the streaming process while still capturing important metrics like time to first token.