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:
AIBADGR_API_KEY- Your API keyAIBADGR_BASE_URL- Custom base URL (default: https://aibadgr.com/api/v1)
export AIBADGR_API_KEY="your_api_key"
export AIBADGR_BASE_URL="https://aibadgr.com/api/v1"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_llms_aibadgr-0.1.0.tar.gz.
File metadata
- Download URL: llama_index_llms_aibadgr-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
946bb797cec8ec51680ca21fecf3a96e0883d32230d23d4992ef849d47262181
|
|
| MD5 |
b629e8172a3462054dc9a3e6c3a1e58b
|
|
| BLAKE2b-256 |
2598895f545710d0a5851d9a6fd170de546044afb28d6d1a7b9f86031f65deed
|
File details
Details for the file llama_index_llms_aibadgr-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_llms_aibadgr-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c211fbe254b9da26f09d91fc764cefc127947ddd693b1594e34eaf361ef785a
|
|
| MD5 |
611212cf7d29d3e49b980cba8c897e11
|
|
| BLAKE2b-256 |
f69ac91239227c80c540e79fc8926f9854dc46a5869f3235a5a4c2ebe890bf53
|