Pydantic AI agents use Pexafy through its MCP server, https://mcp.pexafy.com/mcp, with your API key in the Authorization header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line.

Install

pip install "pydantic-ai-slim[mcp,anthropic]"
export PEXAFY_API_KEY="pexafy_..."      # free key: pexafy.com/dashboard/api-keys/create
export ANTHROPIC_API_KEY="sk-ant-..."   # for this example; any Pydantic AI model works

Use

import os

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPToolset, StreamableHttpTransport

pexafy = MCPToolset(
    StreamableHttpTransport(
        "https://mcp.pexafy.com/mcp",
        headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"},
    )
).filtered(lambda ctx, tool: tool.name in {"search_photos", "search_photos_by_image"})

agent = Agent(
    "anthropic:claude-haiku-4-5",
    instructions="Find free stock photos and give each photo's credit line.",
    toolsets=[pexafy],
)

result = agent.run_sync("Find a header photo for a post about remote work.")
print(result.output)
The filtered call keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See MCP server for the full tool list.