# Enablement of WatsonxLLM as the provider in crewai project setup

**URL:** <https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112>\
**Category:** General\
**Tags:** crewai\
**Created:** [October 29, 2024, 11:21am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112 "2024-10-29T11:21:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paarttipaabhalaji](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/paarttipaabhalaji/32/2053_2.png) [@Paarttipaabhalaji](https://community.crewai.com/u/Paarttipaabhalaji)\
**Post date:** [October 29, 2024, 11:21am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/1 "2024-10-29T11:21:44Z")

</div>

Hi Team,  
Today when I am creating the crewai project using ‘crewai create crew ’ , Its asked to choose the provider. I want to use the watsonx as the LLM provide. But the Watsonx option is not available here. How to proceed further.

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [October 29, 2024, 12:36pm UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/2 "2024-10-29T12:36:45Z")

</div>

> [@Paarttipaabhalaji](#):
>
> But the Watsonx option is not available here.

Where? What are you trying to do?

---

<div class="post-metadata">

**Author:** ![Paarttipaabhalaji](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/paarttipaabhalaji/32/2053_2.png) [@Paarttipaabhalaji](https://community.crewai.com/u/Paarttipaabhalaji)\
**Post date:** [October 30, 2024, 3:53am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/3 "2024-10-30T03:53:23Z")

</div>

(.backlogs\_SLC) MacBook-Pro 10 % **crewai create crew bklog10**  
Creating folder bklog10…  
Cache expired or not found. Fetching provider data from the web…  
Downloading [####################################] 240693/12180  
Select a provider to set up:

1. openai
2. anthropic
3. gemini
4. groq
5. ollama
6. other  
q. Quit  
Enter the number of your choice or ‘q’ to quit: 6  
Select a provider from the full list:
7. ai21
8. aleph\_alpha
9. anthropic
10. anyscale
11. azure
12. azure\_ai
13. bedrock
14. cerebras
15. cloudflare
16. codestral
17. cohere
18. cohere\_chat
19. databricks
20. deepinfra
21. deepseek
22. fireworks\_ai
23. fireworks\_ai-embedding-models
24. friendliai
25. gemini
26. groq
27. mistral
28. nlp\_cloud
29. ollama
30. openai
31. openrouter
32. palm
33. perplexity
34. replicate
35. sagemaker
36. text-completion-codestral
37. text-completion-openai
38. together\_ai
39. vertex\_ai-ai21\_models
40. vertex\_ai-anthropic\_models
41. vertex\_ai-chat-models
42. vertex\_ai-code-chat-models
43. vertex\_ai-code-text-models
44. vertex\_ai-embedding-models
45. vertex\_ai-image-models
46. vertex\_ai-language-models
47. vertex\_ai-llama\_models
48. vertex\_ai-mistral\_models
49. vertex\_ai-text-models
50. vertex\_ai-vision-models
51. voyage  
q. Quit  
Enter the number of your choice or ‘q’ to quit: q  
Exiting…

Here WatsonX option is not available.

---

<div class="post-metadata">

**Author:** ![Paarttipaabhalaji](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/paarttipaabhalaji/32/2053_2.png) [@Paarttipaabhalaji](https://community.crewai.com/u/Paarttipaabhalaji)\
**Post date:** [November 1, 2024, 8:36am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/4 "2024-11-01T08:36:45Z")

</div>

I am trying to use the IBM Watsonx Model.

---

<div class="post-metadata">

**Author:** ![Paarttipaabhalaji](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/paarttipaabhalaji/32/2053_2.png) [@Paarttipaabhalaji](https://community.crewai.com/u/Paarttipaabhalaji)\
**Post date:** [November 3, 2024, 5:00am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/5 "2024-11-03T05:00:26Z")

</div>

BadRequestError: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=IBMWatsonLLM  
Params: {}  
Pass model as E.g. For ‘Huggingface’ inference endpoints pass in `completion(model='huggingface/starcoder',..)` Learn more: [Providers | liteLLM](https://docs.litellm.ai/docs/providers)

---

<div class="post-metadata">

**Author:** ![Paarttipaabhalaji](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/paarttipaabhalaji/32/2053_2.png) [@Paarttipaabhalaji](https://community.crewai.com/u/Paarttipaabhalaji)\
**Post date:** [November 3, 2024, 5:33am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/6 "2024-11-03T05:33:58Z")

</div>

Hi @team,  
Its high priority.

# I am encountered with this error:

raise exception\_type(  
File “/Users/paarttipaa/ProjectTask/GithubProj/BCK\_Log\_SLC\_Code\_Explanation\_Project/.agenticApproach/lib/python3.12/site-packages/litellm/main.py”, line 905, in completion  
model, custom\_llm\_provider, dynamic\_api\_key, api\_base = get\_llm\_provider(  
^^^^^^^^^^^^^^^^^  
File “/Users/paarttipaa/ProjectTask/GithubProj/BCK\_Log\_SLC\_Code\_Explanation\_Project/.agenticApproach/lib/python3.12/site-packages/litellm/litellm\_core\_utils/get\_llm\_provider\_logic.py”, line 313, in get\_llm\_provider  
raise e  
File “/Users/paarttipaa/ProjectTask/GithubProj/BCK\_Log\_SLC\_Code\_Explanation\_Project/.agenticApproach/lib/python3.12/site-packages/litellm/litellm\_core\_utils/get\_llm\_provider\_logic.py”, line 290, in get\_llm\_provider  
raise litellm.exceptions.BadRequestError( # type: ignore  
litellm.exceptions.BadRequestError: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=WatsonxLLM  
Params: {‘model\_id’: ‘mistralai/mistral-large’, ‘deployment\_id’: None, ‘params’: {‘decoding\_method’: ‘sample’, ‘max\_new\_tokens’: 1000, ‘temperature’: 0.7, ‘top\_k’: 50, ‘top\_p’: 1, ‘repetition\_penalty’: 1}, ‘project\_id’: ‘f7312b11-b2dc-4581-b321-11515293a1f1’, ‘space\_id’: None}  
Pass model as E.g. For ‘Huggingface’ inference endpoints pass in `completion(model='huggingface/starcoder',..)` Learn more: [Providers | liteLLM](https://docs.litellm.ai/docs/providers)  
(.agenticApproach) paarttipaa@Paarttipaabhalajis-MacBook-Pro BCK\_Log\_SLC\_Code\_Explanation\_Project %

# watsonx.py

from langchain\_ibm import WatsonxLLM  
import os  
from dotenv import load\_dotenv  
class WatsonLLLM:  
def **init** (self):  
# Load environment variables  
load\_dotenv()  
self.llm\_mixtral\_l = None # Placeholder for llm\_mixtral\_l  
self.modelConfig() # Call the config method to initialize the LLMs

```
def modelConfig(self):
    model_id_mistral_l = "mistralai/mistral-large"
    # model_id_llama_3 = "meta-llama/llama-3-405b-instruct"

    wml_url=os.getenv("WATSONX_URL")
    wml_api=os.getenv("WATSONX_APIKEY")
    wml_project_id = os.getenv("PROJECT_ID")
    
    # Parameters for Mistral
    parameters_mistral_l = {
        "decoding_method": "sample",
        "max_new_tokens": 1000,
        "temperature": 0.7,
        "top_k": 50,
        "top_p": 1,
        "repetition_penalty": 1
    }

    # Create manager llm (Mistral)
    self.llm_mixtral_l = WatsonxLLM(
        model_id=model_id_mistral_l,
        url=wml_url,
        apikey=wml_api,
        params=parameters_mistral_l,
        project_id=wml_project_id,
    )

```

# Agent.py

from textwrap import dedent  
from crewai import Agent  
import watsonx

class backlog10Agents():  
def **init** (self):  
# # Instantiate the class  
self.watson\_llm = watsonx.WatsonLLLM()  
#Accessing the Mixtral LLM  
self.mixtral\_llm=self.watson\_llm.llm\_mixtral\_l

```
def fileRetriverAgent(self) -> Agent :
   return Agent(
      # Creating the File Retriever Agent
      role="File data Retriever Agent",
      goal="Retrieve the list of Java files in a given directory and retrive the file data it one by one and context to the other agents",
      backstory=(
          "You specialize in scanning directories to find, retrive data and return files."
      ),
      llm=self.mixtral_llm,
      allow_delegation=True,
      verbose=True,
      memory=False,
  )

def Conditional_Matrix_generator(self) -> Agent:
  return Agent(
    role='Java Matrix Analyst',
    goal='Develop detailed conditional matrices for each and every Java methods, aiding in the analysis of method flow and potential paths based on different conditions.',
    backstory=dedent(\
    """You are a highly skilled software analyst with deep knowledge of Java programming.
    Your expertise lies in deconstructing complex Java methods and generating
    conditional matrices to represent logical flows. You have worked on numerous
    projects involving code analysis, helping developers optimize their
    conditional logic and understand the relationships between various code paths."""),
    verbose=True,
    llm=self.mixtral_llm
  )

```

# Note: IBM is collaborated with Crewai, I dont understand why its throwing this error.

# Request: Please help me to resolve this issue.

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [November 3, 2024, 10:46am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/7 "2024-11-03T10:46:24Z")

</div>

@Paarttipaabhalaji If you encounter this error, follow these two steps:

1. Use the CrewAI `LLM` class, which leverages [LiteLLM](https://docs.litellm.ai/) in the background.
2. Make sure to set the LLM provider before configuring the LLM. For watsonx.ai, use `watsonx/<LLM provider>/<LLM name>`. If you’re unsure how to do this for a specific LLM provider, refer to the [LiteLLM Providers page](https://docs.litellm.ai/docs/providers) for guidance.

```auto
from crewai import Agent, LLM

my_llm = LLM(
    api_key=os.getenv("WATSONX_API_KEY"),
    model="watsonx/meta-llama/llama-3-8b-instruct",
)

my_agent = Agent(
    ...,
    llm=my_llm,
)

```

---

<div class="post-metadata">

**Author:** ![Paarttipaabhalaji](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/paarttipaabhalaji/32/2053_2.png) [@Paarttipaabhalaji](https://community.crewai.com/u/Paarttipaabhalaji)\
**Post date:** [November 3, 2024, 10:51am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/8 "2024-11-03T10:51:26Z")

</div>

Thank you for your guidance @rokbenko 🙂

---

<div class="post-metadata">

**Author:** ![rokbenko](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/rokbenko/32/492_2.png) [@rokbenko](https://community.crewai.com/u/rokbenko)\
**Post date:** [November 3, 2024, 10:52am UTC](https://community.crewai.com/t/enablement-of-watsonxllm-as-the-provider-in-crewai-project-setup/1112/9 "2024-11-03T10:52:29Z")

</div>

@Paarttipaabhalaji You’re welcome! 🙂
