Skip to main content

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"

Metadata

Release files for llama-index-llms-aibadgr 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-llms-aibadgr 0.3.0
File Size Uploaded
llama_index_llms_aibadgr-0.3.0.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-llms-aibadgr 0.3.0
File Interpreter ABI Platform
llama_index_llms_aibadgr-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / llama_index_llms_aibadgr-0.3.0.tar.gz

Download URL llama_index_llms_aibadgr-0.3.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3eb90e1e14c7034f621dd638454bc650d0add92f45c477a305c49483ff78d804
BLAKE2b-256 checksum
How to use checksums
6bf478305fc6e0cd4a6abd3dca3a42122b699188d1a6d3b01abf55ef5b6c9b72
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_aibadgr-0.3.0-py3-none-any.whl

Download URL llama_index_llms_aibadgr-0.3.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d14f64fe0bd2b8b10f0e261206515c03b040d268463764911ad86e30653512f
BLAKE2b-256 checksum
How to use checksums
c3a63a7eb2768c615be99198cd8f622ea4313d2269265d3fbd586cc3522338bb
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 history Release notifications | RSS feed

0.3.1

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release 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