Parallel Examples

Task API: Company Data Enrichment

Enrich CRM records or company databases with web intelligence.

company_enrichment.py
"""
Task API — Company Data Enrichment
==================================

Enrich CRM records or company databases with web intelligence.

USE CASE:
You have a list of company names. You want to add:
- Funding information
- Employee count
- Key executives
- Recent news

The Task API researches each company and returns structured data
that matches your schema.

Prerequisites:
- pip install parallel-web
- export PARALLEL_API_KEY=<your-api-key>
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.parallel import ParallelTools

# =============================================================================
# COMPANY ENRICHMENT SCHEMA
# =============================================================================
# Define exactly what fields you want for each company.

enrichment_tools = ParallelTools(
    enable_search=False,
    enable_extract=False,
    enable_task=True,
    default_processor="base",
    default_output_schema={
        "type": "json",
        "json_schema": {
            "type": "object",
            "properties": {
                "company_name": {"type": "string"},
                "website": {"type": "string"},
                "founding_year": {"type": "string"},
                "headquarters": {"type": "string"},
                "employee_count": {"type": "string"},
                "total_funding": {"type": "string"},
                "latest_round": {
                    "type": "object",
                    "properties": {
                        "type": {"type": "string"},
                        "amount": {"type": "string"},
                        "date": {"type": "string"},
                    },
                },
                "key_investors": {
                    "type": "array",
                    "items": {"type": "string"},
                },
                "executives": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "name": {"type": "string"},
                            "title": {"type": "string"},
                        },
                    },
                },
                "description": {"type": "string"},
            },
            "required": ["company_name"],
        },
    },
)

# =============================================================================
# ENRICHMENT AGENT
# =============================================================================

enrichment_agent = Agent(
    model=OpenAIResponses(id="gpt-5.4"),
    tools=[enrichment_tools],
    markdown=True,
    instructions="""You enrich company records with web data.
    Use create_task() to research a company, then get_task_result() to retrieve the data.
    Return the structured data for database insertion.""",
)

# =============================================================================
# RUN
# =============================================================================
if __name__ == "__main__":
    # Enrich a company record
    enrichment_agent.print_response(
        "Enrich this company record: Anthropic",
        stream=True,
    )

create_task returns a provider run_id, not the finished report. Call get_task_result(run_id) to retrieve content and its citation basis; this can block for up to default_timeout (1,800 seconds by default). Agno’s stream=True does not make that tool call stream report tokens. A timeout does not cancel the provider task; retain the ID to check status or retry retrieval.

The script researches one company and prints an agent response. It does not update a CRM or database. The Parallel schema constrains the tool’s research output; the outer Agno response has no output_schema. Validate returned content before inserting it into your own database.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai parallel-web

Export your API keys

export OPENAI_API_KEY="your_openai_api_key_here"
export PARALLEL_API_KEY="your_parallel_api_key_here"

Run the example

Save the code above as company_enrichment.py, then run:

python company_enrichment.py

Full source: cookbook/91_tools/parallel/company_enrichment.py