Skip to main content

LlamaIndex Llms Integration: Neutrino

Installation

To install the required packages, run:

%pip install llama-index-llms-neutrino
!pip install llama-index

Setup

Create Neutrino API Key

You can create an API key by visiting platform.neutrinoapp.com. Once you have the API key, set it as an environment variable:

import os

os.environ["NEUTRINO_API_KEY"] = "<your-neutrino-api-key>"

Using Your Router

A router is a collection of LLMs that you can route queries to. You can create a router in the Neutrino dashboard or use the default router, which includes all supported models. You can treat a router as a single LLM.

Initialize Neutrino

Create an instance of the Neutrino model:

from llama_index.llms.neutrino import Neutrino

llm = Neutrino(
    # api_key="<your-neutrino-api-key>",
    # router="<your-router-id>"  # Use 'default' for the default router
)

Generate Completions

To generate a text completion for a prompt, use the complete method:

response = llm.complete("In short, a Neutrino is")
print(f"Optimal model: {response.raw['model']}")
print(response)

Chat Responses

To send a chat message and receive a response, create a ChatMessage and use the chat method:

from llama_index.core.llms import ChatMessage

message = ChatMessage(
    role="user",
    content="Explain the difference between statically typed and dynamically typed languages.",
)

resp = llm.chat([message])
print(f"Optimal model: {resp.raw['model']}")
print(resp)

Streaming Responses

To stream responses for a chat message, use the stream_chat method:

message = ChatMessage(
    role="user", content="What is the approximate population of Mexico?"
)

resp = llm.stream_chat([message])
for i, r in enumerate(resp):
    if i == 0:
        print(f"Optimal model: {r.raw['model']}")
    print(r.delta, end="")

LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/neutrino/

Download files

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

Source Distribution

llama_index_llms_neutrino-0.6.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

llama_index_llms_neutrino-0.6.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_neutrino-0.6.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_neutrino-0.6.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_neutrino-0.6.0.tar.gz
Algorithm Hash digest
SHA256 c43513f25e56c8f9b3832fb56ee333ea9b250a7a11896639d0660c12469a52f7
MD5 468a17d8bf48c65e4e49b376743448aa
BLAKE2b-256 0a16a819253a8d59f294bb17b7676fbc4b501f240fb61c2391572c9cabcfbe11

See more details on using hashes here.

File details

Details for the file llama_index_llms_neutrino-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_neutrino-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_neutrino-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e20fcab9f847dca9b732362a253859e0bad0ae4c8a89c23a88ac6f3a77b8930e
MD5 865909a8ad31938220cb9da595b8f2d9
BLAKE2b-256 5a266b2c4ad58332fe4b4d5cff2332b4263c3ec738ac5f0e2038007da179a4ef

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.1

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page