Heroku Managed Inference
The llama-index-llms-heroku package contains LlamaIndex integrations for building applications with models on Heroku's Managed Inference platform. This integration allows you to easily connect to and use AI models deployed on Heroku's infrastructure.
Installation
pip install llama-index-llms-heroku
Setup
1. Create a Heroku App
First, create an app in Heroku:
heroku create $APP_NAME
2. Create and Attach AI Models
Create and attach a chat model to your app:
heroku ai:models:create -a $APP_NAME claude-3-5-haiku
3. Export Configuration Variables
Export the required configuration variables:
export INFERENCE_KEY=$(heroku config:get INFERENCE_KEY -a $APP_NAME)
export INFERENCE_MODEL_ID=$(heroku config:get INFERENCE_MODEL_ID -a $APP_NAME)
export INFERENCE_URL=$(heroku config:get INFERENCE_URL -a $APP_NAME)
Usage
Basic Usage
from llama_index.llms.heroku import Heroku
from llama_index.core.llms import ChatMessage, MessageRole
# Initialize the Heroku LLM
llm = Heroku()
# Create chat messages
messages = [
ChatMessage(
role=MessageRole.SYSTEM, content="You are a helpful assistant."
),
ChatMessage(
role=MessageRole.USER,
content="What are the most popular house pets in North America?",
),
]
# Get response
response = llm.chat(messages)
print(response)
Using Environment Variables
The integration automatically reads from environment variables:
import os
# Set environment variables
os.environ["INFERENCE_KEY"] = "your-inference-key"
os.environ["INFERENCE_URL"] = "https://us.inference.heroku.com"
os.environ["INFERENCE_MODEL_ID"] = "claude-3-5-haiku"
# Initialize without parameters
llm = Heroku()
Using Parameters
You can also pass parameters directly:
import os
llm = Heroku(
model=os.getenv("INFERENCE_MODEL_ID", "claude-3-5-haiku"),
api_key=os.getenv("INFERENCE_KEY", "your-inference-key"),
inference_url=os.getenv(
"INFERENCE_URL", "https://us.inference.heroku.com"
),
max_tokens=1024,
)
Text Completion
# Simple text completion
response = llm.complete("Explain the importance of open source LLMs")
print(response.text)
Available Models
For a complete list of available models, see the Heroku Managed Inference documentation.
Error Handling
The integration includes proper error handling for common issues:
- Missing API key
- Invalid inference URL
- Missing model configuration
Additional Information
For more information about Heroku Managed Inference, visit the official documentation.
Metadata
Release files for llama-index-llms-heroku 0.3.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_heroku-0.3.1.tar.gz | 5.0 kB | Without provenance | Details for llama_index_llms_heroku-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_llms_heroku-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for llama_index_llms_heroku-0.3.1-py3-none-any.whl |
Total release size: 9.4 kB
Release files / llama_index_llms_heroku-0.3.1.tar.gz
| Download URL | llama_index_llms_heroku-0.3.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
702c65306e586c916829c7a3e8d90ee48599c70f4aabac9712de059c04a10656
|
|
BLAKE2b-256 checksum How to use checksums |
2ec02b9d9c7ba70fa861f3760a07fcc9bea0cecb289de858ebd2e12e97a95b4a
|
| 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_heroku-0.3.1-py3-none-any.whl
| Download URL | llama_index_llms_heroku-0.3.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1977887a1dfdac7e5776631479c9ef7fa68ac93c16a4ba6e3d54a684769dc81
|
|
BLAKE2b-256 checksum How to use checksums |
24c936f6067fb99817ae61552df0b79f17aee7816444dc8d061a0023bd1ba520
|
| 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-heroku 0.3.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.