Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Building a Prediction Market Assistant with Perplexity Sonar and Kalshi APIs in Python

Part Time Larry via YouTube

Overview

Coursera Plus Annual Sale: All Certificates & Courses 25% Off!
Learn to build an AI-powered prediction market assistant in Python through a detailed coding tutorial that combines the Kalshi API for fetching market odds with the Perplexity Sonar Reasoning API for odds evaluation. Follow along with the development of a Streamlit-based user interface that enables programmatic order placement for underpriced contracts, featuring structured outputs to extract bid prices, trading sides, pricing analysis, and confidence scores. Explore key concepts including API integration, data caching for performance optimization, Pydantic model implementation, and the limitations of language models in market analysis. Access the complete source code on GitHub to create a practical tool that demonstrates the intersection of AI and prediction markets, while understanding important considerations about model reliability and the distinction between AI assistants and agents.

Syllabus

0:00 Demo of the App
2:16 Perplexity Sonar API with DeepSeek and Structured Output
3:36 Kalshi API and events as context
4:13 Grok3 has pretty good analysis of prediction markets
6:56 These models are more willing to speculate
7:21 Testing responses in Perplexity Sonar Reasoning playground
8:23 Going beyond an assistant to an agent
9:07 Getting the code from my Github
10:09 Python code walkthrough, dependencies, environment
11:32 Running the Streamlit app, caching Kalshi event data
12:40 Events vs. Markets, my Super Bowl and Kendrick Lamar bets
14:55 Event and category json, pagination, caching for speed
17:23 Quick Streamlit UI component review
18:33 Matching search term, capturing markdown for context
19:53 Evaluate Bet button, callback function, odds markdown as context
20:47 Evaluate bet function, Perplexity payload, system prompt
21:57 Pydantic model for contract data
22:49 Perplexity JSON output is in beta, not 100% reliable
23:47 Displaying the analysis in a dialog
24:58 Language models are not deterministic, not 100% reliable
26:05 Why I called it an assistant and not an agent
26:45 Wrapping up: do you want more prediction market content?

Taught by

Part Time Larry

Reviews

Start your review of Building a Prediction Market Assistant with Perplexity Sonar and Kalshi APIs in Python

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.