Skip to main content
from praisonaiagents import Agent, search_web

agent = Agent(name="Researcher", tools=[search_web])
agent.start("Compare cloud GPU pricing for fine-tuning")
The user asks a research question; the agent uses You.com-backed search and returns a concise answer.
Prerequisites
  • Python 3.10 or higher
  • PraisonAI Agents package installed
  • youdotcom package installed
  • YDC_API_KEY environment variable set
You.com provides AI-powered search capabilities optimized for LLM applications. PraisonAI includes built-in You.com tools for easy integration.

Quick Start

1

Install and set key

pip install praisonaiagents youdotcom
export YDC_API_KEY=your_ydc_api_key
2

Search with agent

from praisonaiagents import Agent, search_web

agent = Agent(
    name="YouAgent",
    instructions="Search the web for the latest information.",
    tools=[search_web],
)

agent.start("Find recent news about space exploration")

Installation

pip install praisonaiagents youdotcom

Setup

export YDC_API_KEY=your_ydc_api_key
export OPENAI_API_KEY=your_openai_api_key

Built-in You.com Tool

PraisonAI provides a built-in ydc tool that you can import directly:
from praisonaiagents import Agent
from praisonaiagents import ydc

agent = Agent(
    name="SearchAgent",
    role="Web Researcher",
    goal="Find information on the web",
    tools=[ydc]
)

result = agent.start("What are the latest AI trends in 2025?")
print(result)

Available Functions

FunctionDescription
ydcWeb search (alias for ydc_search)
ydc_searchUnified web + news search
ydc_contentsExtract content from URLs
ydc_newsLive news search
ydc_imagesImage search

Basic Usage

from praisonaiagents import ydc

# Simple search
results = ydc("Python programming best practices")
print(results)

Search with Options

from praisonaiagents import ydc_search

results = ydc_search(
    query="AI trends 2025",
    count=10,                    # Max results per section
    freshness="week",            # "day", "week", "month", "year"
    country="US",                # ISO country code
    safesearch="moderate",       # "off", "moderate", "strict"
    livecrawl="web",             # "web", "news", "all"
    livecrawl_formats="markdown" # "html" or "markdown"
)

# Access web results
for r in results.get("results", {}).get("web", []):
    print(f"- {r['title']}: {r['url']}")

# Access news results
for r in results.get("results", {}).get("news", []):
    print(f"- {r['title']}: {r['url']}")

Extract Content from URLs

from praisonaiagents import ydc_contents

content = ydc_contents(
    urls=["https://praison.ai/docs", "https://example.com"],
    format="markdown"  # "html" or "markdown"
)

for result in content.get("results", []):
    print(f"URL: {result['url']}")
    print(f"Content: {result.get('markdown', '')[:500]}...")
from praisonaiagents import ydc_news

news = ydc_news(
    query="artificial intelligence",
    count=10
)

for article in news.get("news", {}).get("results", []):
    print(f"- {article['title']}")
    print(f"  Source: {article.get('source_name', 'Unknown')}")
from praisonaiagents import ydc_images

images = ydc_images(query="AI robots")

for img in images.get("images", {}).get("results", []):
    print(f"- {img['title']}: {img['image_url']}")

With PraisonAI Agent

from praisonaiagents import Agent
from praisonaiagents import ydc

agent = Agent(
    name="SearchAgent",
    role="Web Researcher",
    goal="Find and analyze information from the web",
    tools=[ydc]
)

result = agent.start("Research the latest developments in quantum computing")
print(result)

Using YouTools Class

For more control, use the YouTools class directly:
from praisonaiagents import YouTools

# Initialize with custom API key (optional)
tools = YouTools(api_key="your_api_key")  # or uses YDC_API_KEY env var

# Search
results = tools.search("AI news", count=5)

# Get contents
content = tools.get_contents(["https://example.com"], format="markdown")

# Live news
news = tools.live_news("technology trends")

# Images
images = tools.images("AI robots")

Search Parameters

ParameterTypeDescription
querystrSearch query (supports operators)
countintMax results per section (default 10, max 100)
freshnessstr”day”, “week”, “month”, “year” or date range
countrystrISO country code (e.g., “US”, “GB”)
languagestrBCP 47 language code (e.g., “EN”, “JP”)
offsetintPagination offset (0-9)
safesearchstr”off”, “moderate”, “strict”
livecrawlstr”web”, “news”, or “all”
livecrawl_formatsstr”html” or “markdown”

Search Operators

You.com supports advanced search operators:
from praisonaiagents import ydc_search

# Site-specific search
results = ydc_search("site:github.com python AI")

# File type filter
results = ydc_search("machine learning filetype:pdf")

# Include/exclude terms
results = ydc_search("AI +ethics -bias")

# Boolean operators
results = ydc_search("(Python OR JavaScript) AND machine learning")

Key Points

  • Simple function signature: Tool accepts query: str and returns dict
  • Environment variable: Set YDC_API_KEY before running
  • Unified results: Web and news results in single response
  • LLM-ready snippets: Pre-extracted relevant text excerpts

Best Practices

You.com AI snippets provide pre-summarized answers - use them for quick, concise responses.
The free tier has low rate limits - set YDC_API_KEY for production workloads.
Use search_web with providers=['you.com', 'duckduckgo'] for automatic fallback.
Set search_type='news' for current events queries to get fresher results.

Custom Tools

Build your own agent tools

Tools Overview

Browse PraisonAI tool documentation