DEV Community

Yash Sonawane
Yash Sonawane

Posted on

๐Ÿš€ Build an AI Agent with Sanity: From Structured Content to Intelligent Applications

What if your AI agent didn't have to rely on a messy collection of PDFs, hardcoded prompts, or constantly changing application code?

What if you could give your AI structured, queryable, constantly updatable content and let it use that information intelligently?

That's where Sanity becomes interesting.

The Sanity Challenge is currently running from September 18 to October 4, with $2,500 in prizes.

The challenge asks developers to either:

  • Build an AI agent on structured content
  • Build a vibe-coded application with Sanity behind it

And honestly, this is a great opportunity to experiment with something that sits at the intersection of AI + modern web development + structured content.


๐Ÿง  First: What Is Sanity?

If you've never used Sanity before, the easiest way to understand it is:

Sanity lets you model your content as structured data and make that content available to your applications.

Instead of thinking about content as:

HTML pages
      โ†“
Random text
      โ†“
Application
Enter fullscreen mode Exit fullscreen mode

you can think about it as:

Structured Content
       โ†“
Sanity Content Lake
       โ†“
Your Application
       โ†“
AI Agent
Enter fullscreen mode Exit fullscreen mode

Sanity describes its platform as an AI Content Operating System.

Your content is stored as JSON documents, you define schemas using TypeScript, and you can query the content using GROQ.

That combination is particularly interesting for AI applications.


๐Ÿค– Why Structured Content Matters for AI

Let's say you're building an AI assistant for a university.

You could give it a huge document containing:

College Information
Course Information
Faculty Information
Events
Clubs
Rules
Placement Information
FAQs
Enter fullscreen mode Exit fullscreen mode

But that's not necessarily the cleanest way to represent the information.

Instead, imagine storing it as structured documents.

For example:

Course
 โ”œโ”€โ”€ name
 โ”œโ”€โ”€ duration
 โ”œโ”€โ”€ subjects
 โ”œโ”€โ”€ eligibility
 โ””โ”€โ”€ department
Enter fullscreen mode Exit fullscreen mode

And:

Event
 โ”œโ”€โ”€ title
 โ”œโ”€โ”€ date
 โ”œโ”€โ”€ location
 โ”œโ”€โ”€ description
 โ””โ”€โ”€ organizer
Enter fullscreen mode Exit fullscreen mode

Now your AI agent isn't just reading a giant blob of text.

It can work with structured information.


๐Ÿ—๏ธ The Architecture

A simple AI application using Sanity could look like this:

                   User
                     โ”‚
                     โ–ผ
                AI Agent
                     โ”‚
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚               โ”‚
             โ–ผ               โ–ผ
          LLM            Sanity API
                             โ”‚
                             โ–ผ
                      Content Lake
                             โ”‚
                             โ–ผ
                    Structured Content
Enter fullscreen mode Exit fullscreen mode

The AI agent receives a question.

It determines what information it needs.

It retrieves relevant structured content.

Then it generates a response.

This is a powerful pattern because the AI model doesn't have to contain all of your application's knowledge.


๐Ÿ”ฅ Imagine Building This

Let's say we create:

"CampusAI"

An AI assistant that knows everything about a college.

A student could ask:

"What events are happening this week?"

The agent could query structured event data.

Or:

"What subjects are in the 7th semester?"

The agent retrieves course information.

Or:

"Who organizes the coding club?"

The agent retrieves the relevant structured document.

Instead of hardcoding these answers into the application, you manage them through Sanity.


๐Ÿงฉ Sanity Schemas

One of the most interesting parts of Sanity is defining schemas.

Imagine an event schema:

export default {
  name: 'event',
  title: 'Event',
  type: 'document',
  fields: [
    {
      name: 'title',
      title: 'Title',
      type: 'string',
    },
    {
      name: 'description',
      title: 'Description',
      type: 'text',
    },
    {
      name: 'date',
      title: 'Date',
      type: 'datetime',
    },
  ],
}
Enter fullscreen mode Exit fullscreen mode

Now your content has structure.

Instead of:

"Tech event tomorrow at 10 AM..."
Enter fullscreen mode Exit fullscreen mode

you have:

{
  "title": "Tech Workshop",
  "description": "Cloud computing workshop",
  "date": "2026-10-03T10:00:00Z"
}
Enter fullscreen mode Exit fullscreen mode

That structure becomes incredibly useful when applications and AI agents need to work with the content.


๐Ÿ”Ž GROQ: Query Your Content

Sanity uses GROQ to query content.

For example, you might query events like:

*[_type == "event"] {
  title,
  description,
  date
}
Enter fullscreen mode Exit fullscreen mode

You can also filter content.

For example:

*[
  _type == "event" &&
  date >= now()
] {
  title,
  description,
  date
}
Enter fullscreen mode Exit fullscreen mode

Now your application can retrieve upcoming events.

Imagine combining that with an AI agent:

User:
"What events are happening soon?"

        โ†“

AI Agent

        โ†“

GROQ Query

        โ†“

Sanity

        โ†“

Upcoming Events

        โ†“

AI Response
Enter fullscreen mode Exit fullscreen mode

That's where structured content becomes really interesting.


๐Ÿง  AI Agent + Sanity

An AI agent can potentially use Sanity as one of its information sources.

For example:

                 AI Agent
                    โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚            โ”‚            โ”‚
       โ–ผ            โ–ผ            โ–ผ
   Sanity       Database       APIs
   Content
       โ”‚
       โ–ผ
Structured Knowledge
Enter fullscreen mode Exit fullscreen mode

The agent can decide what information it needs and retrieve it from the appropriate source.

This is much more flexible than creating a chatbot with one giant system prompt.


๐Ÿ’ก What Could You Build for the Challenge?

This is where things get exciting.

You don't need to build another generic chatbot.

Build something where structured content actually matters.

Here are some ideas.


๐Ÿ’ผ Idea 1 โ€” AI Career Agent

Build an AI career assistant.

Sanity stores:

Jobs
Companies
Skills
Technologies
Courses
Interview Questions
Projects
Enter fullscreen mode Exit fullscreen mode

The AI agent could answer:

"What skills do I need for this DevOps role?"

Or:

"Which projects should I build to improve my profile?"

Architecture:

User
 โ†“
AI Career Agent
 โ†“
Sanity
 โ”œโ”€โ”€ Jobs
 โ”œโ”€โ”€ Skills
 โ”œโ”€โ”€ Projects
 โ””โ”€โ”€ Learning Resources
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“š Idea 2 โ€” AI Learning Agent

Build a personalized learning assistant.

Sanity contains:

Courses
 โ”œโ”€โ”€ Modules
 โ”œโ”€โ”€ Lessons
 โ”œโ”€โ”€ Topics
 โ””โ”€โ”€ Resources
Enter fullscreen mode Exit fullscreen mode

The user asks:

"Teach me Kubernetes from beginner level."

The agent can retrieve structured lessons and generate a personalized learning path.

You could even add:

Progress Tracking
Quizzes
Projects
Difficulty Levels
Prerequisites
Enter fullscreen mode Exit fullscreen mode

Now you've got something much more useful than a basic chatbot.


๐Ÿ“ฐ Idea 3 โ€” AI News Knowledge Agent

Sanity could store structured articles:

Article
 โ”œโ”€โ”€ Title
 โ”œโ”€โ”€ Author
 โ”œโ”€โ”€ Category
 โ”œโ”€โ”€ Tags
 โ”œโ”€โ”€ Date
 โ””โ”€โ”€ Content
Enter fullscreen mode Exit fullscreen mode

The AI could answer questions such as:

"Summarize the latest cloud infrastructure articles."

or:

"What changed recently in Kubernetes?"

The structured metadata makes filtering and retrieval much easier.


๐Ÿ  Idea 4 โ€” AI Real Estate Assistant

Imagine Sanity stores:

Properties
 โ”œโ”€โ”€ Location
 โ”œโ”€โ”€ Price
 โ”œโ”€โ”€ Bedrooms
 โ”œโ”€โ”€ Amenities
 โ”œโ”€โ”€ Type
 โ””โ”€โ”€ Availability
Enter fullscreen mode Exit fullscreen mode

A user asks:

"Show me apartments under โ‚น50 lakh with two bedrooms."

The application retrieves matching structured content.

Then the AI turns the results into a natural conversation.


๐Ÿ› ๏ธ Idea 5 โ€” AI DevOps Knowledge Agent

This one is particularly interesting for developers.

Create a structured DevOps knowledge base:

Technology
 โ”œโ”€โ”€ Docker
 โ”œโ”€โ”€ Kubernetes
 โ”œโ”€โ”€ Terraform
 โ”œโ”€โ”€ AWS
 โ”œโ”€โ”€ Jenkins
 โ””โ”€โ”€ Ansible
Enter fullscreen mode Exit fullscreen mode

Each technology could contain:

Technology
 โ”œโ”€โ”€ Description
 โ”œโ”€โ”€ Prerequisites
 โ”œโ”€โ”€ Commands
 โ”œโ”€โ”€ Tutorials
 โ”œโ”€โ”€ Projects
 โ”œโ”€โ”€ Interview Questions
 โ””โ”€โ”€ Troubleshooting
Enter fullscreen mode Exit fullscreen mode

Then build an AI agent around it.

A user asks:

"Why is my Kubernetes Pod in CrashLoopBackOff?"

The agent retrieves relevant troubleshooting content and explains the possible causes.

That's a much stronger demonstration of structured content than simply connecting an LLM to a text box.


๐ŸŽฏ The Important Part: Don't Build Just Another Chatbot

This is probably the biggest lesson I'd take from this challenge.

A basic project looks like:

Chat UI
   โ†“
LLM
   โ†“
Answer
Enter fullscreen mode Exit fullscreen mode

Thousands of projects can do that.

A more interesting architecture is:

                    User
                      โ†“
                   AI Agent
                      โ†“
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ†“               โ†“
          Reasoning         Tools
                              โ†“
                           Sanity
                              โ†“
                     Structured Content
Enter fullscreen mode Exit fullscreen mode

Now the AI isn't just generating text.

It's interacting with your application's knowledge layer.


โšก Where Vibe Coding Comes In

The challenge also allows you to vibe-code an application with Sanity behind it.

This opens up another possibility.

You could start with a simple idea:

"Build me a beautiful dashboard for managing AI-powered learning content."

Then use modern AI coding tools to rapidly create:

Frontend
Backend
Sanity Integration
AI Features
Authentication
Dashboard
Enter fullscreen mode Exit fullscreen mode

But here's the important part:

Vibe coding doesn't mean skipping engineering.

AI can generate the initial application quickly.

You still need to:

  • Understand the architecture
  • Test the application
  • Validate API calls
  • Secure credentials
  • Handle errors
  • Optimize queries
  • Fix bugs
  • Deploy it properly

AI can accelerate development.

It doesn't remove the need to understand what you're building.


๐Ÿงช A Simple Project Architecture

If I were building a challenge project, I'd keep the architecture understandable:

Next.js
   โ”‚
   โ”œโ”€โ”€ UI
   โ”‚
   โ”œโ”€โ”€ AI Agent
   โ”‚
   โ””โ”€โ”€ Sanity Client
            โ”‚
            โ–ผ
      Sanity Content Lake
            โ”‚
            โ–ผ
     Structured Documents
Enter fullscreen mode Exit fullscreen mode

For example:

app/
โ”œโ”€โ”€ dashboard/
โ”œโ”€โ”€ agent/
โ”œโ”€โ”€ content/
โ”œโ”€โ”€ api/
โ””โ”€โ”€ components/
Enter fullscreen mode Exit fullscreen mode

And Sanity manages the content model.


๐Ÿ” Don't Forget Security

If you're building an AI application, don't expose API keys in frontend code.

Bad:

const API_KEY = "secret-key";
Enter fullscreen mode Exit fullscreen mode

Your secrets should live in secure environment configuration.

For example:

.env.local
Enter fullscreen mode Exit fullscreen mode

And your application should access them server-side where appropriate.

Also think about:

  • Authentication
  • Authorization
  • Input validation
  • Rate limiting
  • Prompt injection
  • Data exposure
  • API security

A beautiful demo that leaks credentials isn't a good project.


๐Ÿš€ How I Would Build the Project

Here's a practical development plan.

Step 1 โ€” Choose One Specific Problem

Don't start with:

"I'm going to build an AI platform."

Start with:

"I'm building an AI assistant that helps students find and understand university courses."

Specific problems produce better projects.


Step 2 โ€” Design Your Content Model

Before writing the AI agent, decide what information exists.

For example:

Course
 โ”œโ”€โ”€ title
 โ”œโ”€โ”€ description
 โ”œโ”€โ”€ difficulty
 โ”œโ”€โ”€ prerequisites
 โ”œโ”€โ”€ duration
 โ””โ”€โ”€ lessons
Enter fullscreen mode Exit fullscreen mode

Now Sanity has a clear purpose.


Step 3 โ€” Build the Sanity Schemas

Create your structured documents.

Populate them with realistic data.


Step 4 โ€” Build the Application

Create the UI.

For example:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          AI Learning Agent          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                     โ”‚
โ”‚  Ask me anything about your        โ”‚
โ”‚  learning path...                   โ”‚
โ”‚                                     โ”‚
โ”‚  [ What should I learn next? ]      โ”‚
โ”‚                                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Enter fullscreen mode Exit fullscreen mode

Step 5 โ€” Connect the Agent

The agent should retrieve relevant Sanity content when necessary.

For example:

Question
   โ†“
Determine intent
   โ†“
Query Sanity
   โ†“
Retrieve structured content
   โ†“
Generate response
Enter fullscreen mode Exit fullscreen mode

Step 6 โ€” Add Something Memorable

This is where your project can stand out.

Maybe:

  • Personalized recommendations
  • Visual learning roadmap
  • Progress tracking
  • AI-generated quizzes
  • Voice interaction
  • Content summarization
  • Smart search
  • Personalized dashboard

Don't add features just to increase the feature count.

Add one feature that makes people say:

"That's actually useful."


๐Ÿ† What Makes a Good Challenge Submission?

I'd focus on four things:

1. Clear Problem

Can someone understand what your application does in 10 seconds?

2. Real Use of Sanity

Is Sanity actually important to the application?

3. Useful AI

Does AI solve a real problem instead of simply generating text?

4. Great Demo

Can someone understand the value by watching a short demonstration?

Your architecture can be impressive, but if nobody understands the product, the project becomes difficult to appreciate.


๐ŸŒ Learn More About the Challenge

The challenge runs September 18 through October 4 and offers $2,500 in prizes.

You can read the official challenge information on:

Sanity Challenge on DEV Community

You can also explore:

Sanity


๐Ÿ“– Want to Go Deeper Into AI + Developer Tools?

If you're building your skills across AI, Cloud, DevOps, and software engineering, I've also created several learning resources.

๐Ÿน Mastering Go

Build a stronger foundation in Go for backend, cloud-native, and systems development.

Mastering Go

โ˜ธ๏ธ CKA Complete Study Guide

Learn Kubernetes concepts and administration with a CKA-focused approach.

CKA Complete Study Guide

๐Ÿณ Docker Mastery

Learn Docker and containerization fundamentals.

Docker Mastery

๐Ÿ—๏ธ Terraform Associate Crash Course

Learn infrastructure as code with Terraform.

Terraform Associate Crash Course

๐Ÿ”€ Git Mastery

Build a strong Git and version-control foundation.

Git Mastery

โš™๏ธ DevOps Complete Pack

A broader collection for your DevOps learning journey.

DevOps Complete Pack


Final Thoughts

The interesting thing about Sanity isn't simply that it can store content.

It's the combination of:

Structured Content
       +
Queryable Data
       +
Modern Web Applications
       +
AI Agents
Enter fullscreen mode Exit fullscreen mode

That creates a powerful foundation for building applications where AI has access to organized, application-specific knowledge.

And that's exactly the kind of project I'd explore in this challenge.

Don't build an AI chatbot just because AI is trending.

Build something where:

the structured content matters,

the AI has a real job,

and the user gets something genuinely useful.

The best project isn't necessarily the one with the most features.

It's the one where someone sees the demo and immediately thinks:

"I would actually use this."

Top comments (0)