# Crew/Litellm Support of Function and Tool Parameters in Gemini

**URL:** <https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531>\
**Category:** General\
**Created:** [September 24, 2024, 10:00pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531 "2024-09-24T22:00:46Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![moto](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@moto](https://community.crewai.com/u/moto)\
**Post date:** [September 24, 2024, 10:00pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/1 "2024-09-24T22:00:46Z")

</div>

does Crewai support the tool and function parameters of gemini that litellm does?

---

<div class="post-metadata">

**Author:** ![matt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/matt/32/3_2.png) [@matt](https://community.crewai.com/u/matt)\
**Post date:** [September 24, 2024, 11:38pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/2 "2024-09-24T23:38:57Z")

</div>

Doesn’t look like it, I’ll spin up a PR

---

<div class="post-metadata">

**Author:** ![achris7](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/achris7/32/850_2.png) [@achris7](https://community.crewai.com/u/achris7)\
**Post date:** [December 6, 2024, 6:40pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/3 "2024-12-06T18:40:31Z")

</div>

hi Matt, any updates on gemini support?

---

<div class="post-metadata">

**Author:** ![sevvaalm](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/sevvaalm/32/1299_2.png) [@sevvaalm](https://community.crewai.com/u/sevvaalm)\
**Post date:** [December 6, 2024, 9:16pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/4 "2024-12-06T21:16:18Z")

</div>

I see Gemini in the documents [here](https://docs.crewai.com/concepts/llms#available-models-and-their-capabilities) at the others tab. But I didn’t try yet.

---

<div class="post-metadata">

**Author:** ![achris7](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/achris7/32/850_2.png) [@achris7](https://community.crewai.com/u/achris7)\
**Post date:** [December 6, 2024, 10:12pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/5 "2024-12-06T22:12:50Z")

</div>

i see that but it’s errorring

---

<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:** [December 7, 2024, 7:39am UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/6 "2024-12-07T07:39:46Z")

</div>

> [@achris7](#):
>
> i see that but it’s errorring

What error do you get?

---

<div class="post-metadata">

**Author:** ![achris7](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/achris7/32/850_2.png) [@achris7](https://community.crewai.com/u/achris7)\
**Post date:** [December 10, 2024, 9:53pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/7 "2024-12-10T21:53:41Z")

</div>

Now mostly around embeddings

1. File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/embedchain/embedder/openai.py”, line 18, in **init**  
api\_key = self.config.api\_key or os.environ[“OPENAI\_API\_KEY”]  
~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^  
File “”, line 685, in **getitem**  
KeyError: ‘OPENAI\_API\_KEY’

---

<div class="post-metadata">

**Author:** ![achris7](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/achris7/32/850_2.png) [@achris7](https://community.crewai.com/u/achris7)\
**Post date:** [December 10, 2024, 9:56pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/8 "2024-12-10T21:56:31Z")

</div>

ImportError: cannot import name ‘rag\_tool’ from ‘config’

---

<div class="post-metadata">

**Author:** ![achris7](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/achris7/32/850_2.png) [@achris7](https://community.crewai.com/u/achris7)\
**Post date:** [December 10, 2024, 9:57pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/9 "2024-12-10T21:57:13Z")

</div>

Had to remove the rag tool to bypass…

now running into this error

An error occurred: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=model=‘models/gemini-pro’ google\_api\_key=SecretStr(‘\*\*\*\*\*\*\*\*\*\*’) client=\<google.ai.generativelanguage\_v1beta.services.generative\_service.client.GenerativeServiceClient object at 0x155d3b9b0\> default\_metadata=()  
Pass model as E.g. For ‘Huggingface’ inference endpoints pass in `completion(model='huggingface/starcoder',..)`

updated code to restructure litellm config then this error

2024-12-10 13:59:54,540 - 8520267840 - llm.py-llm:170 - ERROR: LiteLLM call failed: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=model=‘models/gemini-pro’ google\_api\_key=SecretStr(‘**‘) client=\<google.ai.generativelanguage\_v1beta.services.generative\_service.client.GenerativeServiceClient object at 0x15ee2c6e0\> default\_metadata=()  
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)  
An error occurred: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=model=‘models/gemini-pro’ google\_api\_key=SecretStr(’**’) client=\<google.ai.generativelanguage\_v1beta.services.generative\_service.client.GenerativeServiceClient object at 0x15ee2c6e0\> default\_metadata=()  
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:** ![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:** [December 11, 2024, 8:48am UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/10 "2024-12-11T08:48:30Z")

</div>

## Error #1

> [@achris7](#):
>
> File “/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/embedchain/embedder/openai.py”, line 18, in **init**  
> api\_key = self.config.api\_key or os.environ[“OPENAI\_API\_KEY”]
> 
> ```auto
> File “”, line 685, in **getitem**
> KeyError: ‘OPENAI_API_KEY’
> 
> ```

You got this error because you used a RAG tool, which needs an embedding LLM to work because this is how RAGs work. CrewAI uses the OpenAI embedding LLM by default, and that’s why the code searched for the OpenAI API key that couldn’t be found. However, you can customize the embedding LLM to your liking.

Create a configuration dictionary with an `embedder` key:

```
config = {
    'embedder': {
        'provider': 'your-provider', # Providers like 'openai', 'ollama', etc.
        'config': {
            'model': 'your-provider/your-embedding-llm',
            'task_type': 'retrieval_document',
            # You can add other configuration options here
        }
    }
}

```

When initializing your tool, pass the configuration:

```auto
my_tool = YourTool(config=config)

```

## Error #2

> [@achris7](#):
>
> An error occurred: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=model=‘models/gemini-pro’ google\_api\_key=SecretStr(‘\*\*\*\*\*\*\*\*\*\*’) client=\<google.ai.generativelanguage\_v1beta.services.generative\_service.client.GenerativeServiceClient object at 0x155d3b9b0\> default\_metadata=()  
> Pass model as E.g. For ‘Huggingface’ inference endpoints pass in `completion(model='huggingface/starcoder',..)`

CrewAI LLM class leverages [LiteLLM](https://docs.litellm.ai/) in the background, which supports a wide range of [LLM providers](https://docs.litellm.ai/docs/providers). Before the LLM, you need to set the LLM provider. In case of using [Google AI Studio](https://docs.litellm.ai/docs/providers/gemini), set it as follows:

```
from crewai import Agent, LLM

my_llm = LLM(
    api_key=os.getenv("GEMINI_API_KEY"),
    model="gemini/gemini-pro",
)

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

```

---

<div class="post-metadata">

**Author:** ![achris7](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/achris7/32/850_2.png) [@achris7](https://community.crewai.com/u/achris7)\
**Post date:** [December 11, 2024, 3:24pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/11 "2024-12-11T15:24:33Z")

</div>

thanks Rok!  
I was also able to touch base with GCP Gemini team who suggested to integrate through Gemini’s OpenAI API compatibility instead of the native Gemini SDKs, which resolved the errors!

FYI two options  
a. Through Vertex AI: [OpenAI ライブラリを使用して Vertex AI モデルを呼び出す &nbsp;|&nbsp; Generative AI on Vertex AI &nbsp;|&nbsp; Google Cloud](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/call-vertex-using-openai-library)  
b. Through Google AI Studio:\*\* [Compatibilità con OpenAI &nbsp;|&nbsp; Gemini API &nbsp;|&nbsp; Google AI for Developers](https://ai.google.dev/gemini-api/docs/openai)

---

<div class="post-metadata">

**Author:** ![achris7](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/achris7/32/850_2.png) [@achris7](https://community.crewai.com/u/achris7)\
**Post date:** [December 13, 2024, 7:05pm UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/12 "2024-12-13T19:05:44Z")

</div>

btw @rokbenko the only gemini model name that’s not erroring out is gemini-pro. i’ve tried most of options and naming conventions they’re all erroring out per above

Here’s the snippet

# Initialize Google API key

GOOGLE\_API\_KEY = os.getenv(‘GOOGLE\_API\_KEY’)  
if not GOOGLE\_API\_KEY:  
raise ValueError(“GOOGLE\_API\_KEY not found in environment variables”)

class CustomGeminiLLM:  
def **init** (self):  
self.client = OpenAI(  
api\_key=os.getenv(‘GOOGLE\_API\_KEY’),  
base\_url=“[https://generativelanguage.googleapis.com/v1/models](https://generativelanguage.googleapis.com/v1/models)”  
)  
self.temperature = 0.7  
self.max\_tokens = 8100  
self.model\_name = “gemini-pro”  
self.supports\_stop\_words = False  
self.supports\_functions = False

---

<div class="post-metadata">

**Author:** ![ritesh\_sangani](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/ritesh_sangani/32/2188_2.png) [@ritesh\_sangani](https://community.crewai.com/u/ritesh_sangani)\
**Post date:** [January 22, 2025, 10:09am UTC](https://community.crewai.com/t/crew-litellm-support-of-function-and-tool-parameters-in-gemini/531/13 "2025-01-22T10:09:18Z")

</div>

I resolved the issues by using the provider name / model name  
here is the code snippet from my code

llm = LLM(  
model=“gemini/gemini-1.5-flash”,  
api\_key=get\_api\_key(model\_name),

)  
It solved all my errors
