Skip to content

Commit a8b4eff

Browse files
Merge pull request #28 from IABTechLab/feature/integrate-llm-providers
Feature/integrate llm providers
2 parents a7c2dc7 + 8571d91 commit a8b4eff

18 files changed

Lines changed: 264 additions & 27 deletions

.env.example

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,61 @@ PREFERRED_DEAL_DISCOUNT_MAX=0.15
147147
# =============================================================================
148148
# LLM Configuration
149149
# =============================================================================
150+
# Only one provider can be active at a time.
151+
# Uncomment the block for your chosen provider and comment out the others.
152+
153+
# Provider: Anthropic (default)
154+
ANTHROPIC_API_KEY=your-anthropic-api-key-here
150155
DEFAULT_LLM_MODEL=anthropic/claude-sonnet-4-5-20250929
151-
MANAGER_LLM_MODEL=anthropic/claude-sonnet-4-5-20250929
156+
MANAGER_LLM_MODEL=anthropic/claude-opus-4-20250514
152157
LLM_TEMPERATURE=0.3
153158
LLM_MAX_TOKENS=4096
154159

160+
# Provider: OpenAI (alternative)
161+
# To switch to OpenAI, set DEFAULT_LLM_MODEL and OPENAI_API_KEY:
162+
# OPENAI_API_KEY=your-openai-api-key-here
163+
# DEFAULT_LLM_MODEL=openai/gpt-4o
164+
# MANAGER_LLM_MODEL=openai/gpt-4o
165+
166+
# Provider: Google Gemini (alternative)
167+
# To switch to Gemini, set DEFAULT_LLM_MODEL and GOOGLE_API_KEY:
168+
# GOOGLE_API_KEY=your-google-api-key-here
169+
# DEFAULT_LLM_MODEL=gemini/gemini-2.5-flash
170+
# MANAGER_LLM_MODEL=gemini/gemini-2.5-flash
171+
172+
# Provider: AWS Bedrock (alternative)
173+
# To switch to Bedrock, set DEFAULT_LLM_MODEL and AWS credentials:
174+
# AWS_ACCESS_KEY_ID=your-aws-access-key
175+
# AWS_SECRET_ACCESS_KEY=your-aws-secret-key
176+
# AWS_REGION=us-west-2
177+
# DEFAULT_LLM_MODEL=bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0
178+
# MANAGER_LLM_MODEL=bedrock/us.anthropic.claude-opus-4-20250514-v1:0
179+
180+
# Provider: Custom OpenAI-compatible endpoint (alternative)
181+
# For endpoints with no CrewAI native provider prefix of their own — NVIDIA
182+
# NIM, Ollama, HuggingFace TGI, vLLM, LM Studio, etc. Set DEFAULT_LLM_MODEL to
183+
# the raw model id the endpoint expects, plus
184+
# OPENAI_COMPATIBLE_LLM_API_BASE_URL. OPENAI_COMPATIBLE_LLM_API_KEY is
185+
# optional — omit it for endpoints (e.g. a local Ollama server) that don't
186+
# require one.
187+
#
188+
# NVIDIA NIM:
189+
# OPENAI_COMPATIBLE_LLM_API_KEY=nvapi-your-nvidia-api-key
190+
# OPENAI_COMPATIBLE_LLM_API_BASE_URL=https://integrate.api.nvidia.com/v1
191+
# DEFAULT_LLM_MODEL=meta/llama-3.1-70b-instruct
192+
# MANAGER_LLM_MODEL=meta/llama-3.1-70b-instruct
193+
#
194+
# Ollama (local or self-hosted):
195+
# OPENAI_COMPATIBLE_LLM_API_BASE_URL=http://localhost:11434/v1
196+
# DEFAULT_LLM_MODEL=llama3
197+
# MANAGER_LLM_MODEL=llama3
198+
#
199+
# HuggingFace TGI (self-hosted):
200+
# OPENAI_COMPATIBLE_LLM_API_KEY=hf_your-huggingface-token
201+
# OPENAI_COMPATIBLE_LLM_API_BASE_URL=https://your-tgi-endpoint.example.com/v1
202+
# DEFAULT_LLM_MODEL=meta-llama/Meta-Llama-3-8B-Instruct
203+
# MANAGER_LLM_MODEL=meta-llama/Meta-Llama-3-8B-Instruct
204+
155205
# =============================================================================
156206
# CrewAI Configuration
157207
# =============================================================================

docs/guides/configuration.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ ad-seller freewheel-login --provider bc
8989
| `MANAGER_LLM_MODEL` | `str` | `"anthropic/claude-opus-4-20250514"` | Model for manager/orchestrator agents |
9090
| `LLM_TEMPERATURE` | `float` | `0.3` | LLM temperature (lower = more deterministic) |
9191
| `LLM_MAX_TOKENS` | `int` | `4096` | Maximum tokens per LLM response |
92+
| `OPENAI_COMPATIBLE_LLM_API_KEY` | `str` | `None` | API key for a [custom OpenAI-compatible endpoint](#custom-openai-compatible-endpoints) (optional — some endpoints don't require one) |
93+
| `OPENAI_COMPATIBLE_LLM_API_BASE_URL` | `str` | `None` | Base URL for a custom OpenAI-compatible endpoint; when set, `DEFAULT_LLM_MODEL`/`MANAGER_LLM_MODEL` are sent as-is to that endpoint instead of being routed by provider prefix |
9294

9395
### Supported Providers
9496

@@ -98,7 +100,7 @@ The seller agent uses CrewAI's native provider integrations via `provider/model-
98100
|----------|-------------|-----------------|---------------|
99101
| **Anthropic** (default) | `anthropic/claude-sonnet-4-5-20250929` | `ANTHROPIC_API_KEY` | `crewai[anthropic]` |
100102
| **OpenAI** | `openai/gpt-4o` | `OPENAI_API_KEY` | `crewai[openai]` |
101-
| **Google Gemini** | `gemini/gemini-2.0-flash` | `GOOGLE_API_KEY` | `crewai[gemini]` |
103+
| **Google Gemini** | `gemini/gemini-2.5-flash` | `GOOGLE_API_KEY` | `crewai[gemini]` |
102104
| **Azure OpenAI** | `azure/my-deployment` | `AZURE_API_KEY`, `AZURE_API_BASE` | `crewai[azure]` |
103105
| **AWS Bedrock** | `bedrock/anthropic.claude-3-sonnet` | AWS credentials | `crewai[bedrock]` |
104106

@@ -116,6 +118,33 @@ OPENAI_API_KEY=sk-xxxxx
116118

117119
For other providers, see the [CrewAI LLM documentation](https://docs.crewai.com/en/learn/litellm-removal-guide).
118120

121+
### Custom OpenAI-Compatible Endpoints
122+
123+
For endpoints that don't have one of the native provider prefixes above —
124+
NVIDIA NIM, Ollama, HuggingFace TGI, vLLM, LM Studio, and similar — set
125+
`OPENAI_COMPATIBLE_LLM_API_BASE_URL`. This pins the request to CrewAI's native OpenAI-compatible
126+
client regardless of the model id's shape, so `DEFAULT_LLM_MODEL` /
127+
`MANAGER_LLM_MODEL` should be set to the raw model id the endpoint expects
128+
(no provider prefix). `OPENAI_COMPATIBLE_LLM_API_KEY` is optional — omit it for endpoints, such
129+
as a local Ollama server, that don't require one.
130+
131+
**Example — NVIDIA NIM:**
132+
133+
```bash
134+
OPENAI_COMPATIBLE_LLM_API_KEY=nvapi-xxxxx
135+
OPENAI_COMPATIBLE_LLM_API_BASE_URL=https://integrate.api.nvidia.com/v1
136+
DEFAULT_LLM_MODEL=meta/llama-3.1-70b-instruct
137+
MANAGER_LLM_MODEL=meta/llama-3.1-70b-instruct
138+
```
139+
140+
**Example — Ollama, local or self-hosted:**
141+
142+
```bash
143+
OPENAI_COMPATIBLE_LLM_API_BASE_URL=http://localhost:11434/v1
144+
DEFAULT_LLM_MODEL=llama3
145+
MANAGER_LLM_MODEL=llama3
146+
```
147+
119148
## Database & Storage
120149

121150
| Variable | Type | Default | Description |

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
]
2020

2121
dependencies = [
22-
"crewai[anthropic,bedrock]>=1.14.4,<2.0.0",
22+
"crewai[anthropic,bedrock,openai,gemini]>=1.14.4,<2.0.0",
2323
"crewai-tools>=1.14.0,<2.0.0",
2424
"pydantic>=2.0.0",
2525
"pydantic-settings>=2.0.0",

src/ad_seller/agents/level1/inventory_manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
function, evaluates proposals, and coordinates specialist agents.
99
"""
1010

11-
from crewai import LLM, Agent
11+
from crewai import Agent
1212

1313
from ...config import get_settings
14+
from ...llm import build_llm
1415

1516

1617
def create_inventory_manager() -> Agent:
@@ -28,7 +29,7 @@ def create_inventory_manager() -> Agent:
2829
"""
2930
settings = get_settings()
3031

31-
llm = LLM(
32+
llm = build_llm(
3233
model=settings.manager_llm_model,
3334
temperature=0.3,
3435
max_tokens=settings.llm_max_tokens,

src/ad_seller/agents/level2/ctv_inventory_agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
OTT apps, FAST channels, and household-targeted inventory.
88
"""
99

10-
from crewai import LLM, Agent
10+
from crewai import Agent
1111

1212
from ...config import get_settings
13+
from ...llm import build_llm
1314

1415

1516
def create_ctv_inventory_agent() -> Agent:
@@ -27,7 +28,7 @@ def create_ctv_inventory_agent() -> Agent:
2728
"""
2829
settings = get_settings()
2930

30-
llm = LLM(
31+
llm = build_llm(
3132
model=settings.default_llm_model,
3233
temperature=0.5,
3334
max_tokens=settings.llm_max_tokens,

src/ad_seller/agents/level2/display_inventory_agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
and premium homepage takeovers.
88
"""
99

10-
from crewai import LLM, Agent
10+
from crewai import Agent
1111

1212
from ...config import get_settings
13+
from ...llm import build_llm
1314

1415

1516
def create_display_inventory_agent() -> Agent:
@@ -26,7 +27,7 @@ def create_display_inventory_agent() -> Agent:
2627
"""
2728
settings = get_settings()
2829

29-
llm = LLM(
30+
llm = build_llm(
3031
model=settings.default_llm_model,
3132
temperature=0.5,
3233
max_tokens=settings.llm_max_tokens,

src/ad_seller/agents/level2/linear_tv_inventory_agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
integration lands)
2020
"""
2121

22-
from crewai import LLM, Agent
22+
from crewai import Agent
2323

2424
from ...config import get_settings
25+
from ...llm import build_llm
2526

2627

2728
def create_linear_tv_inventory_agent() -> Agent:
@@ -41,7 +42,7 @@ def create_linear_tv_inventory_agent() -> Agent:
4142
"""
4243
settings = get_settings()
4344

44-
llm = LLM(
45+
llm = build_llm(
4546
model=settings.default_llm_model,
4647
temperature=0.5,
4748
max_tokens=settings.llm_max_tokens,

src/ad_seller/agents/level2/mobile_app_inventory_agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
SDK inventory, rewarded video, interstitials, and in-app bidding.
88
"""
99

10-
from crewai import LLM, Agent
10+
from crewai import Agent
1111

1212
from ...config import get_settings
13+
from ...llm import build_llm
1314

1415

1516
def create_mobile_app_inventory_agent() -> Agent:
@@ -29,7 +30,7 @@ def create_mobile_app_inventory_agent() -> Agent:
2930
"""
3031
settings = get_settings()
3132

32-
llm = LLM(
33+
llm = build_llm(
3334
model=settings.default_llm_model,
3435
temperature=0.5,
3536
max_tokens=settings.llm_max_tokens,

src/ad_seller/agents/level2/native_inventory_agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
content recommendations, and sponsored content.
88
"""
99

10-
from crewai import LLM, Agent
10+
from crewai import Agent
1111

1212
from ...config import get_settings
13+
from ...llm import build_llm
1314

1415

1516
def create_native_inventory_agent() -> Agent:
@@ -27,7 +28,7 @@ def create_native_inventory_agent() -> Agent:
2728
"""
2829
settings = get_settings()
2930

30-
llm = LLM(
31+
llm = build_llm(
3132
model=settings.default_llm_model,
3233
temperature=0.5,
3334
max_tokens=settings.llm_max_tokens,

src/ad_seller/agents/level2/video_inventory_agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
and outstream formats.
88
"""
99

10-
from crewai import LLM, Agent
10+
from crewai import Agent
1111

1212
from ...config import get_settings
13+
from ...llm import build_llm
1314

1415

1516
def create_video_inventory_agent() -> Agent:
@@ -26,7 +27,7 @@ def create_video_inventory_agent() -> Agent:
2627
"""
2728
settings = get_settings()
2829

29-
llm = LLM(
30+
llm = build_llm(
3031
model=settings.default_llm_model,
3132
temperature=0.5,
3233
max_tokens=settings.llm_max_tokens,

0 commit comments

Comments
 (0)