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.1

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.1
File Size Uploaded
llama_index_llms_aibadgr-0.3.1.tar.gz 4.3 kB Details

Built distribution (wheel)

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

Total release size: 8.3 kB

Release files / llama_index_llms_aibadgr-0.3.1.tar.gz

Download URL llama_index_llms_aibadgr-0.3.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bf21517d208bd11240b4057f9b9763541aeed6a6c33dc73a1ccb21a890561663
BLAKE2b-256 checksum
How to use checksums
a2d94d166cd52c31ea79e4cc17ad256e6b538e32d480d2d1c8e46ab193e43ca2
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.1-py3-none-any.whl

Download URL llama_index_llms_aibadgr-0.3.1-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ef1cbd0c4338a4ed7b0215fca2b7a9545c0d248c390a78b2a6f9cddd4dddef0
BLAKE2b-256 checksum
How to use checksums
e98b1c93d328d539154f1853ee2270e46d3b6927fa5eb45a9f862f290237d9d1
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

This release

0.3.1 This release

2 release files

0.3.0

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