Switching clouds? Get up to $10K in credits + hands-on help.

Apply now

Pydantic Agents - Workflows

Deploy the Ask Render Anything RAG agent on Render Workflows. Build observable AI pipelines with Pydantic AI, Logfire, and full cost tracking.

Why deploy pydantic agents workflows on Render?

Pydantic Agents Workflows is a reference implementation demonstrating how to build observable AI pipelines using Pydantic AI, Pydantic Embedder, and Logfire for monitoring. It solves the problem of building production-ready LLM applications with full traceability, cost tracking, and quality evaluation across multi-stage retrieval-augmented generation (RAG) workflows.

This template wires together a complete AI observability stack: a FastAPI backend, Next.js frontend, ingestion service, and PostgreSQL with pgvector—all pre-connected with the correct environment variables and database URLs. Instead of manually configuring hybrid search, setting up workflow orchestration, and connecting four separate services, you get the full Pydantic Agents pipeline running with one click. Render Workflows handles the parallel fan-out for verification tasks across instances, and the managed Postgres gives you pgvector for semantic search without any extension setup.

Architecture

What you can build

After deploying, you'll have a working Q&A assistant that answers questions about Render's documentation, with a Next.js frontend, FastAPI backend, and a multi-stage AI pipeline running on Render Workflows. The pipeline retrieves relevant docs via hybrid search, generates answers with Claude, then runs parallel verification and quality checks across OpenAI and Anthropic models. Everything is instrumented with Logfire, so you can inspect traces, token costs, and evaluation scores for each question.

Key features

  • Render Workflows orchestration: 7-stage Q&A pipeline runs as durable workflow tasks with per-task retries, timeouts, and cross-instance parallel fan-out for concurrent evaluation.
  • Hybrid pgvector + BM25 search: Combines semantic vector similarity (pgvector) with keyword matching (full-text search) in a single PostgreSQL database for improved retrieval accuracy.
  • Multi-model verification pipeline: Answers pass through three distinct checks—claims extraction with source verification, factual-grounding accuracy review, and dual-model quality rating using both OpenAI and Anthropic.
  • Per-stage cost attribution: Token usage from each Pydantic AI agent is combined with pricing from pydantic/genai-prices registry to track exact costs per pipeline stage and execution.
  • Logfire auto-instrumentation: Distributed tracing automatically captures LLM calls, FastAPI requests, AsyncPG queries, and HTTPX traffic with custom metrics for quality and cost analytics.

Use cases

  • DevOps engineer monitors LLM pipeline costs and latency across multi-model workflows
  • Platform team builds internal docs chatbot with verified answers and source citations
  • SRE debugs slow AI responses using distributed traces across retrieval and generation stages
  • Developer learns observable AI patterns by deploying a production-ready RAG reference architecture

What's included

Service
Type
Purpose
pydantic-agents-workflows-api
Web Service
Handles API requests and business logic
pydantic-agents-workflows-ingest
Cron Job
Application service
pydantic-agents-workflows-frontend
Web Service
Serves the user interface
unnamed
rewrite
Application service
pydantic-agents-workflows-db
PostgreSQL
Primary database

Prerequisites

  • OpenAI API Key: API key for OpenAI services used for embeddings, question processing, and quality evaluation.
  • Anthropic API Key: API key for Anthropic's Claude model used for answer generation and dual-model quality rating.
  • Logfire Token: Write token for Pydantic Logfire to send traces, metrics, and observability data.

Next steps

  1. Open the frontend URL and ask a question like 'How do I deploy a Node.js app on Render?' — You should see the 7-stage pipeline progress (embedding → retrieval → generation → verification) and receive a detailed answer with source citations within 30 seconds
  2. Configure your Logfire dashboard and run a test question — You should see distributed traces appear showing LLM calls to both OpenAI and Anthropic, with per-stage cost attribution and token counts visible in the trace waterfall
  3. Test the dual-model quality evaluation by asking a complex question like 'What database plans are available and what are the differences?' — You should see both Accuracy and Quality scores in the response, confirming the parallel fan-out to Claude and GPT evaluators completed successfully

Resources

Stack

python
react
fastapi
postgresql

Tags

ai
ai-agent
chatbot
llm
rag
vector-database
full-stack
workflows

For AI agents

Drop into your coding agent to explore and deploy this template.