Skip to main content

LlamaIndex LLMs Integration: Helicone

Installation

To install the required packages, run:

pip install llama-index-llms-helicone
pip install llama-index

Setup

Initialize Helicone

Set your Helicone API key via HELICONE_API_KEY (or pass directly). No provider API keys are needed when using the Helicone AI Gateway.

from llama_index.llms.helicone import Helicone
from llama_index.core.llms import ChatMessage

llm = Helicone(
    api_key="<helicone-api-key>",  # or set HELICONE_API_KEY env var
    model="gpt-4o-mini",  # works across providers via gateway
)

Generate Chat Responses

You can generate a chat response by sending a list of ChatMessage instances:

message = ChatMessage(role="user", content="Tell me a joke")
resp = llm.chat([message])
print(resp)

Streaming Responses

To stream responses, use the stream_chat method:

message = ChatMessage(role="user", content="Tell me a story in 250 words")
resp = llm.stream_chat([message])
for r in resp:
    print(r.delta, end="")

Complete with Prompt

You can also generate completions with a prompt using the complete method:

resp = llm.complete("Tell me a joke")
print(resp)

Streaming Completion

To stream completions, use the stream_complete method:

resp = llm.stream_complete("Tell me a story in 250 words")
for r in resp:
    print(r.delta, end="")

Model Configuration

To use a specific model, you can specify it during initialization. For example, to use Mistral's Mixtral model, you can set it like this:

from llama_index.llms.helicone import Helicone

llm = Helicone(model="gpt-4o-mini")
resp = llm.complete("Write a story about a dragon who can code in Rust")
print(resp)

Notes

  • Default Helicone base URL is https://ai-gateway.helicone.ai/v1. Override with api_base or HELICONE_API_BASE if needed.
  • Only HELICONE_API_KEY is required. The gateway routes to the correct provider based on the model string.

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_helicone-0.3.0.tar.gz (4.9 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_helicone-0.3.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_helicone-0.3.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_helicone-0.3.0.tar.gz
  • Upload date:
  • Size: 4.9 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_helicone-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f57b8b9395e335880b83ce5a96888494593e1b52e5a506840da88e143368bf37
MD5 f01c0d9d238de2f5bb5f8cd81e7d5ccc
BLAKE2b-256 a1cdf50dd42a692e6ca6c1a8091bef4ee711a41b5d7f5544dc2cce95b7ee2b76

See more details on using hashes here.

File details

Details for the file llama_index_llms_helicone-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_helicone-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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_helicone-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9edcc3d427e922c67b66b716bddc274345605b2db0eaee4fbdf779c0f9f9ffd
MD5 f453d35da625211b48eb5ac0f370fdcc
BLAKE2b-256 d0e96a6f0866df459f02b18b77eb497e04f3121e1cad68f7dfdbfb0f4933d9a1

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.1

2 files

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

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