Semantic Kernel Plasmate Integration

April 12, 2026 ยท View on GitHub

Plasmate integration for Microsoft Semantic Kernel - the browser engine for AI agents.

Plasmate converts HTML to structured JSON (Semantic Object Model) with 10-100x token compression, making web browsing dramatically more efficient for LLM-based agents.

Features

  • PlasmatePlugin: Semantic Kernel plugin with web browsing functions
  • PlasmateConnector: Memory connector for storing and searching web content
  • PlasmateWebPlanner: Pre-built plans for research and monitoring tasks
  • Full async support: All operations are async-native

Installation

pip install semantic-kernel-plasmate

Or install from source:

git clone https://github.com/nicholasoxford/plasmate
cd plasmate/integrations/semantic-kernel
pip install -e .

Prerequisites

  • Python 3.10+
  • Plasmate CLI installed and in PATH
  • Semantic Kernel 1.0+

Quick Start

Register the Plugin

from semantic_kernel import Kernel
from semantic_kernel_plasmate import PlasmatePlugin

# Create kernel
kernel = Kernel()

# Add Plasmate plugin
plasmate = PlasmatePlugin()
kernel.add_plugin(plasmate, plugin_name="plasmate")

Fetch a Web Page

# Get the plugin function
fetch = kernel.get_plugin("plasmate").get("fetch_page")

# Fetch a page and get structured SOM
result = await fetch.invoke(kernel, url="https://example.com")
print(result)  # Structured JSON with 10-100x compression

Extract Clean Text

extract = kernel.get_plugin("plasmate").get("extract_text")
text = await extract.invoke(kernel, url="https://news.ycombinator.com")
print(text)  # Clean, readable text without HTML

Search and Fetch

search = kernel.get_plugin("plasmate").get("search_and_fetch")
results = await search.invoke(
    kernel,
    query="python async best practices",
    num_results=3
)
print(results)  # Search results with SOM content

Plugin Functions

fetch_page(url, headers?)

Fetch a web page and return its Semantic Object Model representation.

result = await plasmate.fetch_page(
    url="https://api.example.com/data",
    headers='{"Authorization": "Bearer token123"}'
)

extract_text(url)

Extract clean, readable text from a web page.

text = await plasmate.extract_text(url="https://blog.example.com/article")

extract_links(url)

Extract all links from a page with context.

links = await plasmate.extract_links(url="https://example.com")
# Returns: [{"href": "...", "text": "...", "context": "..."}]

search_and_fetch(query, num_results?)

Perform a web search and fetch top results.

results = await plasmate.search_and_fetch(
    query="machine learning tutorials",
    num_results=5
)

fetch_multiple(urls)

Fetch multiple URLs in parallel.

results = await plasmate.fetch_multiple(
    urls='["https://a.com", "https://b.com", "https://c.com"]'
)

Memory Connector

Store and search web content with embeddings:

from semantic_kernel_plasmate import PlasmateConnector, WebContentRecord

# Create connector
connector = PlasmateConnector()
await connector.create_collection("research")

# Store content
record = WebContentRecord(
    url="https://example.com/article",
    som={"title": "Example", "content": "..."},
    text="Article text content...",
    embedding=[0.1, 0.2, ...]  # From your embedding model
)
await connector.upsert("research", record)

# Search by embedding
results = await connector.search(
    "research",
    query_embedding=[0.1, 0.2, ...],
    limit=10
)

# Search by text
results = await connector.search_by_text("research", "example query")

Planner Integration

Use pre-built plans for complex research tasks:

from semantic_kernel_plasmate import PlasmateWebPlanner, ResearchPlan

# Create planner
planner = PlasmateWebPlanner(kernel)

# Create research plan
plan = ResearchPlan(
    topic="quantum computing applications",
    depth=3,
    focus_areas=["healthcare", "cryptography"],
    include_academic=True
)

# Execute plan
result = await planner.execute(plan)
print(result["results"])

Research Plan

Structured web research with multiple search queries:

plan = ResearchPlan(
    topic="renewable energy",
    depth=3,                           # Results per search
    focus_areas=["solar", "wind"],     # Additional focused searches
    include_academic=True,             # Include academic sources
    max_pages=10                        # Total page limit
)

Monitor Plan

Monitor websites for changes:

from semantic_kernel_plasmate import MonitorPlan

plan = MonitorPlan(
    urls=["https://news.example.com"],
    check_interval_minutes=30,
    notify_on=["new_article", "price_change"],
    store_history=True
)

Complete Example

See examples/web_research_kernel.py for a full example with:

  • Kernel setup with OpenAI
  • Interactive chat with web browsing
  • Structured research execution
  • Memory storage and search
export OPENAI_API_KEY="your-key"
python examples/web_research_kernel.py

Configuration

Custom Plasmate Path

plasmate = PlasmatePlugin(
    plasmate_path="/usr/local/bin/plasmate",
    timeout=60.0,
    default_headers={"User-Agent": "MyBot/1.0"}
)

Using with Azure OpenAI

from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion

kernel.add_service(AzureChatCompletion(
    service_id="chat",
    deployment_name="gpt-4",
    endpoint="https://your-resource.openai.azure.com",
    api_key="your-azure-key"
))

Why Plasmate?

Traditional web scraping returns raw HTML, which is:

  • Token-heavy (wasting LLM context)
  • Unstructured (hard for LLMs to parse)
  • Noisy (scripts, styles, boilerplate)

Plasmate's Semantic Object Model (SOM) provides:

  • 10-100x compression: More content in less tokens
  • Structured output: Clean JSON the LLM can understand
  • Semantic elements: Meaningful structure preserved
  • Fast: Rust-based engine for speed

License

MIT