# Using Snowflake Cortex LLMs with Crew AI

**URL:** <https://community.crewai.com/t/using-snowflake-cortex-llms-with-crew-ai/4823>\
**Category:** General\
**Tags:** crewai, feature\
**Created:** [March 19, 2025, 1:51pm UTC](https://community.crewai.com/t/using-snowflake-cortex-llms-with-crew-ai/4823 "2025-03-19T13:51:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prince\_Thakkar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/prince_thakkar/32/3117_2.png) [@Prince\_Thakkar](https://community.crewai.com/u/Prince_Thakkar)\
**Post date:** [March 19, 2025, 1:51pm UTC](https://community.crewai.com/t/using-snowflake-cortex-llms-with-crew-ai/4823/1 "2025-03-19T13:51:27Z")

</div>

Hi , I wanted to use Snowflake Cortex LLM in Crew AI but did not find any way how do I do it , kindly help me with a short implementation example , because , Snowflake cortex LLMs are approved for us and we can only use those , so need help in setting up Crew AI agents which use Snowflake cortex LLMs

Following is the custom Langchain class code I tried

class SnowflakeCortexLLM:  
def **init** (self, sp\_session, model=“claude-3-5-sonnet”):  
self.sp\_session = sp\_session  
self.model = model

```
def call(self, prompt, **kwargs):
    """This method will be called by CrewAI"""
    try:
        # Properly escape single quotes in the prompt
        # This is critical for SQL injection prevention
        safe_prompt = prompt.replace("'", "''")
        
        # Execute Cortex function
        result_df = self.sp_session.sql(
            f"SELECT complete('{self.model}', '{safe_prompt}')"
        ).collect()
        
        # Extract response from result
        return result_df[0][0] if result_df else "No response from Cortex."
    except Exception as e:
        print(f"Error in Snowflake Cortex LLM: {e}")
        return f"Error: {str(e)}"

```

chat = SnowflakeCortexLLM(sp\_session = session)

I used this chat in Crew AI agents ,  
data\_analyst\_agent = Agent(  
role=“Data Analyst”,  
goal="Monitor and analyze market data in real-time "  
“to identify trends and predict market movements.”,  
backstory="Specializing in financial markets, this agent "  
"uses statistical modeling and machine learning "  
"to provide crucial insights. With a knack for data, "  
"the Data Analyst Agent is the cornerstone for "  
“informing trading decisions.”,  
verbose=True,  
allow\_delegation=True,  
llm = {  
“provider”: “custom”,  
“config”: chat  
},  
tools = [simple\_search\_tool , web\_scraper]  
)

I have already added the connection parameters and authentication part to form connection with snowflake , I get the following error on using it

After authentication got the following error  
🚀 Crew: crew  
└── 📋 Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7  
Status: Executing Task…

🚀 Crew: crew  
└── 📋 Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7  
Status: Executing Task…  
└── 🤖 Agent: Crew Manager  
Status: In Progress

# Agent: Crew Manager

## Task: Continuously monitor and analyze market data for the selected stock (AAPL). Use statistical modeling and machine learning to identify trends and predict market movements.

🚀 Crew: crew  
└── 📋 Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7  
Status: Executing Task…  
└── 🤖 Agent: Crew Manager  
Status: In Progress  
└── 🧠 Thinking…

🚀 Crew: crew  
└── 📋 Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7  
Status: Executing Task…  
└── 🤖 Agent: Crew Manager  
Status: In Progress  
└── ❌ LLM Failed

╭─────────────────────────────────────────────────────────────────────────────────────────────────── LLM Error ────────────────────────────────────────────────────────────────────────────────────────────────────╮  
│ │  
│ ❌ LLM Call Failed │  
│ Error: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet │  
│ Pass model as E.g. For ‘Huggingface’ inference endpoints pass in `completion(model='huggingface/starcoder',..)` Learn more: h │  
│ │  
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

2025-03-19 19:09:56,229 - 16588 - llm.py-llm:751 - ERROR: LiteLLM call failed: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet  
Pass model as E.g. For ‘Huggingface’ inference endpoints pass in `completion(model='huggingface/starcoder',..)` Learn more:  
Error during LLM call: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet  
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 unknown error occurred. Please check the details below.  
Error details: litellm.BadRequestError: LLM Provider NOT provided. Pass in the LLM provider you are trying to call. You passed model=claude-3-5-sonnet  
Pass model as E.g. For ‘Huggingface’ inference endpoints pass in `completion(model='huggingface/starcoder',..)` Learn more:  
🚀 Crew: crew  
└── 📋 Task: b8b498ad-76ee-49ec-8a60-705aeafe29b7  
Assigned to: Crew Manager  
Status: ❌ Failed  
└── 🤖 Agent: Crew Manager  
Status: In Progress  
└── ❌ LLM Failed  
╭────────────────────────────────────────────────────────────────────────────────────────────────── Task Failure ──────────────────────────────────────────────────────────────────────────────────────────────────╮  
│ │  
│ Task Failed │  
│ Name: b8b498ad-76ee-49ec-8a60-705aeafe29b7 │  
│ Agent: Crew Manager │  
│ │  
│ │  
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭────────────────────────────────────────────────────────────────────────────────────────────────── Crew Failure ──────────────────────────────────────────────────────────────────────────────────────────────────╮  
│ │  
│ Crew Execution Failed │  
│ Name: crew │  
│ ID: e03e7942-8e81-497d-9d3c-205c6fc891ac │  
│ │  
│ │  
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Traceback (most recent call last):  
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

---

<div class="post-metadata">

**Author:** ![maxmoura](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/maxmoura/32/4206_2.png) [@maxmoura](https://community.crewai.com/u/maxmoura)\
**Post date:** [March 19, 2025, 3:11pm UTC](https://community.crewai.com/t/using-snowflake-cortex-llms-with-crew-ai/4823/2 "2025-03-19T15:11:12Z")

</div>

It seems that [support for Snowflake is on the way in LiteLLM](https://github.com/BerriAI/litellm/issues/7979), which CrewAI depends on.
