Skip to main content

llama-index llms aibadgr integration

Project description

LlamaIndex LLMs Integration: AI Badgr

AI Badgr (Budget/Utility, OpenAI-compatible)

Installation

To install the required packages, run:

pip install llama-index-llms-aibadgr

Setup

Initialize AI Badgr

You need to set either the environment variable AIBADGR_API_KEY or pass your API key directly in the class constructor. Replace <your-api-key> with your actual API key:

from llama_index.llms.aibadgr import AIBadgr
from llama_index.core.llms import ChatMessage

llm = AIBadgr(
    api_key="<your-api-key>",
    model="premium",
)

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

AI Badgr supports tier-based model names for easy selection:

  • basic - Budget tier model (maps to phi-3-mini)
  • normal - Standard tier model (maps to mistral-7b)
  • premium - Premium tier model (maps to llama3-8b-instruct, recommended default)
# Using tier names (recommended)
llm = AIBadgr(model="premium", api_key="your_api_key")
resp = llm.complete("Write a story about a dragon who can code in Rust")
print(resp)

Advanced: Power-User Model Names

You can also use specific model names directly:

llm = AIBadgr(model="llama3-8b-instruct", api_key="your_api_key")
resp = llm.complete("Explain quantum computing")
print(resp)

OpenAI model names are accepted and mapped automatically.

Environment Variables

You can configure AI Badgr using environment variables:

export AIBADGR_API_KEY="your_api_key"
export AIBADGR_BASE_URL="https://aibadgr.com/api/v1"

Project details


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_aibadgr-0.2.0.tar.gz (4.3 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_aibadgr-0.2.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_aibadgr-0.2.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_aibadgr-0.2.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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_aibadgr-0.2.0.tar.gz
Algorithm Hash digest
SHA256 477a77d1560f1523df7578319bab0a3385f8a2a11b4d845224893004a578521c
MD5 38aea54ffd5a43fcbcb02ba8d7410f30
BLAKE2b-256 3a3fc6d1b54ad5405ca21dce418d9a670057d8831a8f93c20aefe7c07505e1ea

See more details on using hashes here.

File details

Details for the file llama_index_llms_aibadgr-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_aibadgr-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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_aibadgr-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69ec291ec9732d03a9e59dd14fb131e0bd0bbc76de08c3cf0c2766fc0841c843
MD5 ce8c137148d118314c9dd32486393444
BLAKE2b-256 3ef82029b1079e6361db6bb38d151808986e9bb4a268c34ea0b03c9467245c89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page