---
title: "AI Facts"
description: "A Next.js application that transcribes and validates speech in realtime with the AI SDK."
url: "https://vercel.com/templates/next.js/ai-facts"
links:
  repository: "https://github.com/vercel-labs/ai-facts"
  demo: "https://ai-facts.vercel.app/"
  deploy: "https://vercel.com/new/clone?demo-title=AI+Facts&demo-description=A+Next.js+application+that+transcribes+and+validates+speech+in+realtime+with+the+AI+SDK.&demo-url=https%3A%2F%2Fai-facts.vercel.app%2F&demo-image=%2F%2Fimages.ctfassets.net%2Fe5382hct74si%2F6zlCfn1jtot7EH2k4YF3g2%2F5bc742a93ab393551472e37d7a657184%2FUntitled_design__22_.png&project-name=AI+Facts&repository-name=ai-facts&repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-facts&from=templates&skippable-integrations=1&env=DEEPGRAM_API_KEY%2CPERPLEXITY_API_KEY%2COPENAI_API_KEY&envDescription=API+Keys+Required"
---

# AI Facts

A Next.js application that transcribes and validates speech in realtime with the AI SDK.

# AI Facts

**Note:** LLMs can sometimes provide incorrect or outdated information. Always verify critical information through trusted sources.

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-facts&env=DEEPGRAM_API_KEY&envDescription=Learn%20more%20about%20how%20to%20get%20the%20API%20Keys%20for%20the%20application&envLink=https%3A%2F%2Fgithub.com%2Fvercel-labs%2Fai-facts%2Fblob%2Fmain%2F.env.example&demo-title=AI%20Facts&demo-description=Real-time%20fact%20checking%20using%20audio%20transcription%20and%20AI&demo-url=https%3A%2F%2Fai-facts.vercel.app)

This project is a Next.js application that performs real-time fact checking on spoken statements. It uses Deepgram for audio transcription and leverages OpenAI and Perplexity (via the Vercel AI Gateway) to verify the accuracy of claims.

## Features

- Real-time Audio Transcription: Captures and transcribes spoken audio using Deepgram's API
- AI Fact Checking: Uses both OpenAI and Perplexity to cross-reference and verify statements
- Live Results: Shows fact-checking results in real-time as statements are processed
- Explanation of Validity: Provides detailed explanations for why statements are considered true or false

## Technology Stack

- [Next.js](https://nextjs.org/) for the frontend and API routes
- [AI SDK](https://sdk.vercel.ai/) for interacting with LLMs
- [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) for unified access to OpenAI and Perplexity
- [Deepgram](https://deepgram.com/) for audio transcription
- [ShadcnUI](https://ui.shadcn.com/) for UI components
- [Tailwind CSS](https://tailwindcss.com/) for styling

## How It Works

1. Speak into microphone
2. Deepgram processes the audio stream in real-time and returns transcribed text
3. The transcribed text is analyzed for distinct statements ('?!.')
4. Each statement is routed through the AI Gateway to OpenAI and Perplexity for fact checking
5. The verification status and explanation are displayed to the user

## Getting Started

To get the project up and running, follow these steps:

1. Install dependencies:

   ```bash
   npm install
   ```

2. Copy the example environment file:

   ```bash
   cp .env.example .env
   ```

3. Add your API keys to the `.env` file:

   ```
   AI_GATEWAY_API_KEY=your_api_key_here
   DEEPGRAM_API_KEY=your_api_key_here
   ```

   You can create an AI Gateway API key from the [Vercel dashboard](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway%2Fapi-keys&title=AI+Gateway+API+Keys). When deployed on Vercel, authentication happens automatically via OIDC and `AI_GATEWAY_API_KEY` is not required.

4. Start the development server:
   ```bash
   npm run dev
   ```

Your project should now be running on [http://localhost:3000](http://localhost:3000).

## Deployment

The project is set up for one-click deployment on Vercel. Use the "Deploy with Vercel" button above to create your own instance of the application.

## Learn More

To learn more about the technologies used in this project, check out the following resources:

- [Next.js Documentation](https://nextjs.org/docs)
- [AI SDK](https://sdk.vercel.ai/docs)
- [Vercel AI Gateway](https://vercel.com/docs/ai-gateway)
- [Deepgram](https://deepgram.com/)
- [ShadcnUI](https://ui.shadcn.com/)
- [Tailwind CSS](https://tailwindcss.com/docs)

## Related Templates

### [Dynamic Model Usage with AI SDK](https://vercel.com/templates/next.js/ai-sdk-feature-flags-edge-config)

A chatbot that allows you to dynamically set the LLM using Vercel AI SDK with Feature Flags and Edge Config

### [Chatbot](https://vercel.com/templates/next.js/chatbot)

A full-featured, hackable Next.js AI chatbot built by Vercel

---

## Additional documentation

The [Vercel Knowledge Base](https://vercel.com/kb) contains guides and answers to common questions about Vercel, including deployment, framework configuration, domains, caching, and troubleshooting.
