Skip to content

Python client library overview#

The Neptune client library (Neptune API) is an open source suite of libraries to help you log, query, and download model-building metadata. You can also use the Neptune API to manage projects, users, and model stages.

The API is lightweight and designed to integrate with your MLOps tech stack in a flexible manner. It's up to you to define what to log for each run and in what kind of structure.

Visit neptune-client repo on GitHub 


To start using the library, install it via pip or conda:

pip install neptune
conda install -c conda-forge neptune
Installing through Anaconda Navigator

To find neptune, you may need to update your channels and index.

  1. In the Navigator, select Environments.
  2. In the package view, click Channels.
  3. Click Add..., enter conda-forge, and click Update channels.
  4. In the package view, click Update index... and wait until the update is complete. This can take several minutes.
  5. You should now be able to search for neptune.

Note: The displayed version may be outdated. The latest version of the package will be installed.

Note: On Bioconda, there is a "neptune" package available which is not the client library. Make sure to specify the "conda-forge" channel when installing

then import Neptune in your model training script:

import neptune

and initialize a run, model, or project object that you'll log metadata to:

run = neptune.init_run() # (1)!
  1. You can omit your credentials from the init functions once you've saved them as environment variables. For details, see Set your API token.

    You can also use a class constructor:

    from neptune import Run
    run = Run()

Assign metadata or files to your object, and execute the script as you normally would.
# Log metrics inside loops
for epoch in range(n_epochs):
    # Your training loop

    run["train/epoch/loss"].append(loss)  # Each append() call appends a value

# Track artifact versions and metadata

# Upload entire files

# Log text or other metadata, in a structure of your choosing
run["tokenizer"] = "regexp_tokenize"

# It's a good practice to stop the run when done


The Neptune API is also available to use integrated with various machine learning tools, which lets you log typical metadata with less manual setup.

To learn more, see Integrations.

Neptune CLI#

The Neptune client library comes with a command-line interface (CLI) tool.

You can use Neptune CLI to locally manage the synchronization of your data with Neptune servers, which comes in handy if you have data that's only stored locally (for example, if you experience connectivity issues).

To learn more, see the Neptune CLI overview.