---
layout: default
---

# Ejemplo: Agente con Tavily Search

<div class="text-xs mt-2">

```typescript
import { createAgent } from "langchain";
import { TavilySearchResults } from "@langchain/community/tools/tavily_search";

const searchTool = new TavilySearchResults({ apiKey: process.env.TAVILY_API_KEY, maxResults: 5 });
const agent = createAgent({
  model: "openai:gpt-4.1-mini",
  tools: [searchTool],
});

const result = await agent.invoke({
  messages: [{ role: "user", content: "¿Cuales son las ultimas noticias sobre IA?" }],
});
```

<div class="mt-2 grid grid-cols-2 gap-3">

<div class="bg-blue-50 dark:bg-blue-900/20 p-2 rounded">

**Tavily** - Optimizado para LLMs: extrae contenido relevante, filtra anuncios/ruido, API key gratuita limitada

</div>

<div class="bg-green-50 dark:bg-green-900/20 p-2 rounded">

**Docs**: [langchain.com/integrations/tools](https://docs.langchain.com/oss/javascript/integrations/tools)

</div>

</div>

</div>

