From 8063cec6b4af1b6bd987e281f8b2fd2b892f991d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 06:26:19 +0000 Subject: [PATCH 1/5] Initial plan From 35e9ec2d6f5497cbb7a1c29db0fc5e355ec83bfe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 06:35:51 +0000 Subject: [PATCH 2/5] Changes before error encountered Co-authored-by: miguelmanlyx <220451577+miguelmanlyx@users.noreply.github.com> --- .../docs/pipeline-components/generators.mdx | 1 + .../generators/aibadgrchatgenerator.mdx | 157 ++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 docs-website/docs/pipeline-components/generators/aibadgrchatgenerator.mdx diff --git a/docs-website/docs/pipeline-components/generators.mdx b/docs-website/docs/pipeline-components/generators.mdx index f49778444f..72b1472bd7 100644 --- a/docs-website/docs/pipeline-components/generators.mdx +++ b/docs-website/docs/pipeline-components/generators.mdx @@ -11,6 +11,7 @@ Generators are responsible for generating text after you give them a prompt. The | Generator | Description | Streaming Support | | --- | --- | --- | +| [AI Badgr (Budget/Utility)](generators/aibadgrchatgenerator.mdx) | Use AI Badgr models through OpenAI-compatible API for budget-friendly chat completions. | ✅ | | [AmazonBedrockChatGenerator](generators/amazonbedrockchatgenerator.mdx) | Enables chat completion using models through Amazon Bedrock service. | ✅ | | [AmazonBedrockGenerator](generators/amazonbedrockgenerator.mdx) | Enables text generation using models through Amazon Bedrock service. | ✅ | | [AIMLAPIChatGenerator](generators/aimllapichatgenerator.mdx) | Enables chat completion using AI models through the AIMLAPI. | ✅ | diff --git a/docs-website/docs/pipeline-components/generators/aibadgrchatgenerator.mdx b/docs-website/docs/pipeline-components/generators/aibadgrchatgenerator.mdx new file mode 100644 index 0000000000..5dafca7a4a --- /dev/null +++ b/docs-website/docs/pipeline-components/generators/aibadgrchatgenerator.mdx @@ -0,0 +1,157 @@ +--- +title: "AI Badgr (Budget/Utility, OpenAI-compatible)" +id: aibadgrchatgenerator +slug: "/aibadgrchatgenerator" +description: "Use AI Badgr models through OpenAI-compatible API for budget-friendly chat completions." +--- + +# AI Badgr (Budget/Utility, OpenAI-compatible) + +Use AI Badgr models through OpenAI-compatible API for budget-friendly chat completions. + +
+ +| | | +| --- | --- | +| **Most common position in a pipeline** | After a [ChatPromptBuilder](../builders/chatpromptbuilder.mdx) | +| **Mandatory init variables** | `api_key`: An AI Badgr API key. Can be set with `AIBADGR_API_KEY` env var. | +| **Mandatory run variables** | `messages`: A list of [`ChatMessage`](../../concepts/data-classes/chatmessage.mdx) objects | +| **Output variables** | `replies`: A list of [`ChatMessage`](../../concepts/data-classes/chatmessage.mdx) objects | +| **API reference** | [Generators](/reference/generators-api) | +| **Provider website** | https://aibadgr.com | + +
+ +## Overview + +AI Badgr is a budget/utility OpenAI-compatible provider. You can use AI Badgr models with Haystack's [`OpenAIChatGenerator`](openaichatgenerator.mdx) component by configuring the `api_base_url` parameter. + +AI Badgr uses tier-based model names for simplicity: +- `basic` - Entry-level model for simple tasks +- `normal` - Balanced performance for general use +- `premium` - Best performance and capabilities (recommended) + +:::info Power-user Model Names +AI Badgr also accepts specific model names that map to tiers: +- `phi-3-mini` → basic +- `mistral-7b` → normal +- `llama3-8b-instruct` → premium + +OpenAI model names are accepted and mapped automatically. +::: + +### Authentication + +To use AI Badgr, you need an API key. You can provide it with: + +- The `AIBADGR_API_KEY` environment variable (recommended) +- The `api_key` init parameter using Haystack [Secret](../../concepts/secret-management.mdx) API: `Secret.from_token("your-api-key-here")` + +Optionally, you can override the base URL with the `AIBADGR_BASE_URL` environment variable or `api_base_url` parameter. The default is `https://aibadgr.com/api/v1`. + +### Streaming + +AI Badgr supports [streaming](guides-to-generators/choosing-the-right-generator.mdx#streaming-support) responses through the OpenAI-compatible interface. To enable streaming, pass a callable to the `streaming_callback` parameter during initialization. + +## Usage + +AI Badgr is OpenAI-compatible, so you use the standard Haystack OpenAI components. + +### On its own + +Basic usage with tier model name: + +```python +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack.utils import Secret + +client = OpenAIChatGenerator( + api_key=Secret.from_env_var("AIBADGR_API_KEY"), + model="premium", + api_base_url="https://aibadgr.com/api/v1" +) + +messages = [ChatMessage.from_user("What's Natural Language Processing? Be brief.")] +response = client.run(messages) +print(response["replies"][0].text) +``` + +With streaming: + +```python +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.components.generators.utils import print_streaming_chunk +from haystack.dataclasses import ChatMessage +from haystack.utils import Secret + +client = OpenAIChatGenerator( + api_key=Secret.from_env_var("AIBADGR_API_KEY"), + model="premium", + api_base_url="https://aibadgr.com/api/v1", + streaming_callback=print_streaming_chunk +) + +messages = [ChatMessage.from_user("What's Natural Language Processing? Be brief.")] +response = client.run(messages) +``` + +### In a Pipeline + +```python +from haystack import Pipeline +from haystack.components.builders import ChatPromptBuilder +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack.utils import Secret + +prompt_builder = ChatPromptBuilder() +llm = OpenAIChatGenerator( + api_key=Secret.from_env_var("AIBADGR_API_KEY"), + model="premium", + api_base_url="https://aibadgr.com/api/v1" +) + +pipe = Pipeline() +pipe.add_component("prompt_builder", prompt_builder) +pipe.add_component("llm", llm) +pipe.connect("prompt_builder.prompt", "llm.messages") + +messages = [ + ChatMessage.from_system("Give brief answers."), + ChatMessage.from_user("Tell me about {{city}}"), +] + +response = pipe.run( + data={"prompt_builder": {"template": messages, "template_variables": {"city": "Berlin"}}} +) +print(response["llm"]["replies"][0].text) +``` + +### Using Environment Variables + +For convenience, set environment variables: + +```bash +export AIBADGR_API_KEY="your-api-key-here" +export AIBADGR_BASE_URL="https://aibadgr.com/api/v1" +``` + +Then use in code: + +```python +from haystack.components.generators.chat import OpenAIChatGenerator +from haystack.dataclasses import ChatMessage +from haystack.utils import Secret +import os + +client = OpenAIChatGenerator( + api_key=Secret.from_env_var("AIBADGR_API_KEY"), + model="premium", + api_base_url=os.getenv("AIBADGR_BASE_URL", "https://aibadgr.com/api/v1") +) + +messages = [ChatMessage.from_user("Hello!")] +response = client.run(messages) +print(response["replies"][0].text) +``` From 108f3f0321fb086450e871da739a28c1654abab0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 20:02:01 +0000 Subject: [PATCH 3/5] Add AI Badgr to sidebars navigation Co-authored-by: miguelmanlyx <220451577+miguelmanlyx@users.noreply.github.com> --- docs-website/sidebars.js | 1 + 1 file changed, 1 insertion(+) diff --git a/docs-website/sidebars.js b/docs-website/sidebars.js index cf27ecfc98..04df79e9f1 100644 --- a/docs-website/sidebars.js +++ b/docs-website/sidebars.js @@ -377,6 +377,7 @@ export default { 'pipeline-components/generators/guides-to-generators/generators-vs-chat-generators', ], }, + 'pipeline-components/generators/aibadgrchatgenerator', 'pipeline-components/generators/amazonbedrockchatgenerator', 'pipeline-components/generators/amazonbedrockgenerator', 'pipeline-components/generators/aimllapichatgenerator', From 3dd0c29eac0dc30521546e840a521c03e4f72541 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 05:07:43 +0000 Subject: [PATCH 4/5] Initial plan From 50f5f0ffd539eb1c5e3f10d818a6777926847ff4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 05:11:39 +0000 Subject: [PATCH 5/5] docs: add release note for AI Badgr provider documentation Co-authored-by: miguelmanlyx <220451577+miguelmanlyx@users.noreply.github.com> --- .../add-aibadgr-provider-documentation-987d5e6923e042.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 releasenotes/notes/add-aibadgr-provider-documentation-987d5e6923e042.yaml diff --git a/releasenotes/notes/add-aibadgr-provider-documentation-987d5e6923e042.yaml b/releasenotes/notes/add-aibadgr-provider-documentation-987d5e6923e042.yaml new file mode 100644 index 0000000000..6f689e2b51 --- /dev/null +++ b/releasenotes/notes/add-aibadgr-provider-documentation-987d5e6923e042.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add documentation for AI Badgr provider integration. AI Badgr is a budget/utility OpenAI-compatible + provider that can be used with Haystack's OpenAIChatGenerator component by configuring the api_base_url + parameter. The documentation includes usage examples for tier-based model names (basic, normal, premium) + and guidance on authentication, streaming, and environment variable configuration.