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
Metadata
Release files for llama-index-llms-neutrino 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_llms_neutrino-0.6.1.tar.gz | 4.5 kB | Without provenance | Details for llama_index_llms_neutrino-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_llms_neutrino-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for llama_index_llms_neutrino-0.6.1-py3-none-any.whl |
Total release size: 8.9 kB
Release files / llama_index_llms_neutrino-0.6.1.tar.gz
| Download URL | llama_index_llms_neutrino-0.6.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9a28776502f5e029a641ebe519eafa01816fffad7f9b8048062525d2f5d5ab3
|
|
BLAKE2b-256 checksum How to use checksums |
ff7515bb51eda8c99b2e16509dfdc21fef78ab7111c50a645392f38934cb77ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / llama_index_llms_neutrino-0.6.1-py3-none-any.whl
| Download URL | llama_index_llms_neutrino-0.6.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b4a9ee2aacc77ee0fd36d54e941944d98ff27fe8099e86b14d1318c9640b73b
|
|
BLAKE2b-256 checksum How to use checksums |
a389af06e6ccad5dffc4f8452c346c37f51de21068fc5771901f6f900f3c2a5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for llama-index-llms-neutrino 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.