ScavioScavio
ProductoPreciosDocumentación
Iniciar sesionComenzar
  1. Inicio
  2. Tutoriales
  3. Cómo construir el agente de búsqueda Genkit con Scavio
Tutorial

Cómo construir el agente de búsqueda Genkit con Scavio

Cree un agente Firebase Genkit con búsqueda web utilizando la API de Scavio. Definición de herramientas, configuración de flujo e implementación de TypeScript.

Obtener clave API gratisDocumentacion API

Firebase Genkit proporciona una forma estructurada de crear flujos de IA con herramientas. Agregar la búsqueda de Scavio como herramienta Genkit brinda a sus flujos acceso web en vivo para establecer bases, investigar y enriquecer los datos. Este tutorial define la herramienta, crea un flujo de búsqueda y la prueba de un extremo a otro en TypeScript.

Requisitos previos

  • Nodo.js 18+
  • Firebase Genkit instalado
  • Una clave API de Scavio de scavio.dev
  • Configuración del proyecto TypeScript

Guia paso a paso

Paso 1: Definir la herramienta de búsqueda Scavio para Genkit

Cree una definición de herramienta Genkit escrita para búsqueda web.

Python
import os, requests, json

# Python equivalent of the TypeScript Genkit tool
# (Genkit is TypeScript-first, but the API call is the same)

API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}

# Genkit tool schema (for reference when writing TypeScript)
genkit_tool_schema = {
    'name': 'webSearch',
    'description': 'Search the web for current information. Returns structured results.',
    'inputSchema': {
        'type': 'object',
        'properties': {
            'query': {'type': 'string', 'description': 'Search query'},
            'platform': {'type': 'string', 'enum': ['google', 'reddit', 'youtube', 'amazon'],
                         'description': 'Platform to search'}
        },
        'required': ['query']
    },
    'outputSchema': {
        'type': 'array',
        'items': {
            'type': 'object',
            'properties': {
                'title': {'type': 'string'},
                'link': {'type': 'string'},
                'snippet': {'type': 'string'}
            }
        }
    }
}

print('Genkit tool schema (TypeScript reference):')
print(json.dumps(genkit_tool_schema, indent=2))

Paso 2: Implementar la función de búsqueda

Cree la función de búsqueda real a la que llama la herramienta Genkit.

Python
def genkit_web_search(query, platform=None):
    """Implementation matching the Genkit tool schema."""
    body = {'query': query, 'country_code': 'us'}
    if platform and platform != 'google':
        body['platform'] = platform
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=SH, json=body).json()
    return [{'title': r.get('title', ''), 'link': r.get('link', ''),
             'snippet': r.get('snippet', '')} for r in data.get('organic_results', [])[:5]]

# TypeScript equivalent:
ts_code = """
// genkit-search-tool.ts
import { defineTool } from '@genkit-ai/ai';
import { z } from 'zod';

export const webSearch = defineTool(
  {
    name: 'webSearch',
    description: 'Search the web for current information',
    inputSchema: z.object({
      query: z.string().describe('Search query'),
      platform: z.enum(['google', 'reddit', 'youtube', 'amazon']).optional()
    }),
    outputSchema: z.array(z.object({
      title: z.string(),
      link: z.string(),
      snippet: z.string()
    }))
  },
  async ({ query, platform }) => {
    const body = { query, country_code: 'us', ...(platform && { platform }) };
    const resp = await fetch('https://api.scavio.dev/api/v1/search', {
      method: 'POST',
      headers: { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' },
      body: JSON.stringify(body)
    });
    const data = await resp.json();
    return (data.organic_results || []).slice(0, 5).map(r => ({
      title: r.title || '', link: r.link || '', snippet: r.snippet || ''
    }));
  }
);
"""
print(ts_code)

# Test the Python version
results = genkit_web_search('genkit firebase tutorial 2026')
print(f'Test: {len(results)} results')
for r in results[:2]:
    print(f'  {r["title"]}')

Paso 3: Crear un flujo Genkit con búsqueda

Conecte la herramienta de búsqueda a un flujo de investigación completo de Genkit.

Python
def simulate_genkit_flow(topic):
    """Simulate a Genkit flow that uses search for research."""
    print(f'\n=== Genkit Flow: Research "{topic}" ===')
    # Step 1: Search for overview
    overview = genkit_web_search(f'{topic} overview 2026')
    print(f'  [1] Overview search: {len(overview)} results')
    # Step 2: Search for comparisons
    comparisons = genkit_web_search(f'{topic} vs alternatives comparison')
    print(f'  [2] Comparison search: {len(comparisons)} results')
    # Step 3: Search Reddit for opinions
    opinions = genkit_web_search(f'{topic} review', platform='reddit')
    print(f'  [3] Reddit opinions: {len(opinions)} results')
    # Compile results
    all_sources = overview + comparisons + opinions
    print(f'\n  Total sources: {len(all_sources)}')
    print(f'  Cost: ${3 * 0.005:.3f} (3 search calls)')
    print(f'\n  Top findings:')
    for s in all_sources[:5]:
        print(f'    - {s["title"][:55]}')
    return all_sources

simulate_genkit_flow('Firebase Genkit')
simulate_genkit_flow('Vercel AI SDK')

Ejemplo en Python

Python
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

def genkit_search(query, platform=None):
    body = {'query': query, 'country_code': 'us'}
    if platform: body['platform'] = platform
    data = requests.post('https://api.scavio.dev/api/v1/search', headers=SH, json=body).json()
    return data.get('organic_results', [])[:5]

results = genkit_search('genkit search tool 2026')
for r in results:
    print(f'{r["title"]}: {r.get("link", "")}')
print('Cost: $0.005')

Ejemplo en JavaScript

JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
async function genkitSearch(query, platform) {
  const body = { query, country_code: 'us', ...(platform && { platform }) };
  const data = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: SH, body: JSON.stringify(body)
  }).then(r => r.json());
  return (data.organic_results || []).slice(0, 5);
}
const results = await genkitSearch('genkit tutorial 2026');
results.forEach(r => console.log(r.title));

Salida esperada

JSON
Genkit tool schema (TypeScript reference):
{
  "name": "webSearch",
  "description": "Search the web for current information..."
}

Test: 5 results
  Getting Started with Firebase Genkit
  Genkit AI Flows Tutorial 2026

=== Genkit Flow: Research "Firebase Genkit" ===
  [1] Overview search: 5 results
  [2] Comparison search: 5 results
  [3] Reddit opinions: 5 results

  Total sources: 15
  Cost: $0.015 (3 search calls)

Tutoriales relacionados

  • Cómo crear una herramienta de búsqueda LangChain con Scavio
  • Cómo agregar búsqueda a un agente LangGraph
  • Cómo agregar una base de búsqueda a cualquier agente Python

Preguntas frecuentes

La mayoria de los desarrolladores completan este tutorial en 15 a 30 minutos. Necesitaras una clave API de Scavio (el plan gratuito funciona) y un entorno de Python o JavaScript.

Nodo.js 18+. Firebase Genkit instalado. Una clave API de Scavio de scavio.dev. Configuración del proyecto TypeScript. Una clave API de Scavio te da 50 creditos gratuitos al registrarte.

Si. El plan gratuito incluye 50 creditos al registrarte, mas que suficiente para completar este tutorial y crear un prototipo funcional.

Scavio tiene un paquete nativo de LangChain (langchain-scavio), un servidor MCP y una API REST simple que funciona con cualquier cliente HTTP. Este tutorial usa the raw REST API, pero puedes adaptarlo al framework que prefieras.

Recursos relacionados

Use Case

Integración de búsqueda de Firebase Genkit

Read more
Best Of

Los mejores complementos de búsqueda para Google Genkit (2026)

Read more
Best Of

Las mejores API de búsqueda después de los cambios en el modo AI de Google I/O 2026

Read more
Use Case

Acceso web de IA de código abierto 2026

Read more
Glossary

Panorama de proveedores de API de búsqueda (2026)

Read more
Comparison

Parallel Web Systems vs Scavio

Read more

Empieza a construir

Cree un agente Firebase Genkit con búsqueda web utilizando la API de Scavio. Definición de herramientas, configuración de flujo e implementación de TypeScript.

Obtener clave API gratuitaLeer la documentacion
ScavioScavio

API de busqueda en tiempo real para agentes de IA. Busca en todas las plataformas, no solo en Google.

Producto

  • Funciones
  • Precios
  • Panel
  • Afiliados

Desarrolladores

  • Documentacion
  • Referencia de API
  • Inicio rapido
  • Integracion MCP
  • Python SDK

Alternativas

  • Alternativa a Tavily
  • Alternativa a SerpAPI
  • Alternativa a Firecrawl
  • Alternativa a Exa

Herramientas

  • Formateador JSON
  • cURL a codigo
  • Contador de tokens
  • Todas las herramientas

© 2026 Scavio. Todos los derechos reservados.

Featured on TAAFT
Terminos de servicioPolitica de privacidad