Skip to main content

A plugin to add support for the Neuralwatt AI inference service to llm

Project description

llm-neuralwatt

PyPI Changelog Tests License

An plugin to add support for the OpenAI compatible Neuralwatt inference service, to run inference against various open weights models, and return the direct energy measurements in the response as well as logging it locally in llm's logs.db sqlite file.

This is not an official plugin from Neuralwatt.

Installation

Install this plugin in the same environment as LLM.

llm install llm-neuralwatt

Usage

Once you have llm-neuralwatt installed, you should see new models available when you call llm models:

Neuralwatt: neuralwatt/deepseek-coder-33b-instruct (aliases: neuralwatt-deepseek-coder)
Neuralwatt: neuralwatt/gpt-oss-20b (aliases: neuralwatt-gpt-oss)
Neuralwatt: neuralwatt/Qwen3-Coder-480B-A35B-Instruct (aliases: neuralwatt-qwen3-coder)

You will need to set a key with:

llm keys set neuralwatt

You can sign up for Neuralwatt, and get an API key from https://portal.neuralwatt.com.

Energy Consumption Logging

This plugin automatically captures and logs energy consumption data from Neuralwatt API responses. Energy data is stored in the response_json field of the llm logs database.

To view energy consumption for your requests:

# View recent logs with energy data
llm logs --model neuralwatt-gpt-oss --json | jq '.[-1:].[].response_json.energy'

# Query specific energy metrics
llm logs --model neuralwatt-deepseek-coder --json | jq -r '.[] | select(.response_json.energy != null) | "\(.datetime_utc): \(.response_json.energy.energy_joules) joules, \(.response_json.energy.energy_kwh) kWh"'

Each energy measurement includes:

  • energy_joules: Energy consumption in joules
  • energy_kwh: Energy consumption in kilowatt-hours
  • avg_power_watts: Average power consumption in watts
  • duration_seconds: Duration of the API call
  • attribution_method: How energy was attributed
  • attribution_ratio: Ratio of energy attribution

You can read more about how energy consumption is attributed to a single use in the Neuralwatt docs

Streaming Support

Energy consumption data is captured in both streaming and non-streaming modes. The plugin uses a custom HTTP streaming implementation to capture the energy data that Neuralwatt sends as an SSE comment just before the [DONE] marker.

# Both streaming and non-streaming capture energy data
llm "Explain quantum computing" -m neuralwatt-gpt-oss
llm "Explain quantum computing" -m neuralwatt-gpt-oss --no-stream

For more details on how Neuralwatt handles streaming, see the Neuralwatt streaming docs.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd llm-neuralwatt
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

python -m pip install -e '.[test]'

To run the tests:

python -m pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_neuralwatt-0.0.4.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_neuralwatt-0.0.4-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file llm_neuralwatt-0.0.4.tar.gz.

File metadata

  • Download URL: llm_neuralwatt-0.0.4.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llm_neuralwatt-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f8f3a828d302cf3e2121b3e11875f5b20aa00c530ea7a2bba53a3a2fe6fc1358
MD5 6eeefefcbb44954f3a9fa7d47d296290
BLAKE2b-256 e2dc34f4b096dfbbda88d97c681f6a5c799898a48194c46dc7213849386901ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_neuralwatt-0.0.4.tar.gz:

Publisher: publish.yml on mrchrisadams/llm-neuralwatt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_neuralwatt-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: llm_neuralwatt-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llm_neuralwatt-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4b8d95a01dd4b3403fad22e025f7f3ee9c307f64ff6f598988114aab1681f3ae
MD5 2f0dc71357f82e361e4af0d84860a1e9
BLAKE2b-256 5a7aa6525225fb76e982b5e0ffb889f5ee537522b23c4382a2a5484288fcbe8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_neuralwatt-0.0.4-py3-none-any.whl:

Publisher: publish.yml on mrchrisadams/llm-neuralwatt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page