Skip to content

fix(tools): pass tavilyApiKey to TavilySearch constructor#6353

Open
asimar007 wants to merge 1 commit intoFlowiseAI:mainfrom
asimar007:fix/tavily-api-key-param
Open

fix(tools): pass tavilyApiKey to TavilySearch constructor#6353
asimar007 wants to merge 1 commit intoFlowiseAI:mainfrom
asimar007:fix/tavily-api-key-param

Conversation

@asimar007
Copy link
Copy Markdown

@asimar007 asimar007 commented May 6, 2026

Root cause

packages/components/nodes/tools/TavilyAPI/TavilyAPI.ts constructed TavilySearch with the field apiKey, but @langchain/tavily@1.2.0 (and its BaseTavilyAPIWrapper) accept the key under the name tavilyApiKey. The wrong field was silently dropped, so the wrapper fell back to process.env.TAVILY_API_KEY and threw:

Error in Agent node: Tavily API key not found. Please provide it as an argument or set the TAVILY_API_KEY environment variable.

Fix

Pass the credential under the correct key name.

 const config: any = {
-    apiKey: tavilyApiKey,
+    tavilyApiKey,
     topic,

How to verify

  1. Add a Tavily API credential in the UI (do not set TAVILY_API_KEY env var).
  2. Build an Agent flow with the Tavily API tool attached.
  3. Run a query — it should now reach Tavily without the "API key not found" error.

Out of scope

The reporter also mentions a second error after setting TAVILY_API_KEY directly (message.content.map is not a function). That error is downstream of this fix (in Agent ↔ tool response handling) and looks unrelated to this file, so I've kept this PR scoped to the clear credential-passing bug. Happy to open a follow-up if maintainers can point me at the right area.

Fixes #6343

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the TavilyAPI tool by renaming the apiKey property to tavilyApiKey within the configuration object using shorthand notation. As there are no review comments provided, I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tavily API does not work

1 participant