Try it above or visit analytics-with-c1.vercel.app
What You’ll Learn
- Connecting C1 with financial data APIs using tool calling
- Building a suite of analytics tools (stocks, crypto, financials)
- Designing system prompts for data visualization
- Automatic chart generation based on data type
- Adding web search for market context
- Thread management for multi-turn conversations
- Setting up C1Chat for financial analysis UI
Architecture Overview
AI data copilots work differently from traditional dashboards:Setup
Prerequisites
- Node.js 18+
- Thesys API key from console.thesys.dev
- Financial Datasets API key from financialdatasets.ai
- (Optional) Exa API key from exa.ai for web search
Create Next.js Project
npm
- TypeScript: Yes
- ESLint: Yes
- Tailwind CSS: Yes
- App Router: Yes
- Customize default import alias: No
Install Dependencies
npm
Environment Variables
Create a.env.local file:
Step 1: Set Up Financial Data Tools
Create tools that fetch financial data. C1 will call these automatically based on user queries:tools/financial.ts
Step 2: Add Web Search for Context
Financial data is more useful with context. Add web search to explain market movements:tools/web-search.ts
Step 3: Create the Analytics Endpoint
Connect your tools with C1 to create the main analytics endpoint:app/api/chat/route.ts
Step 4: Craft the System Prompt for Analytics
The system prompt guides C1 to create appropriate visualizations:Being specific about when to use each visualization type (charts vs tables vs cards) leads to consistent, professional-looking outputs.
Step 5: Thread Management
Enable multi-turn analysis by maintaining conversation context:threads.ts
Step 6: Set Up the Frontend UI
Create the conversational analytics interface using C1Chat:app/page.tsx
- Message history
- Streaming responses with live chart generation
- Thinking states showing which APIs are being queried
- Automatic thread management for follow-ups
- Responsive design for charts and tables
Step 7: Run Your Analytics Copilot
Start the development server:npm
- “Show me Tesla’s stock price” - See current price with change indicators
- “What’s Apple’s revenue trend over the last 4 quarters?” - Get financial statements with charts
- “Compare Bitcoin and Ethereum prices” - See multi-asset comparison
- Follow up: “Which one performed better this month?” - Test thread continuity
The first query might take a few seconds as financial data is fetched. The copilot will show thinking states like “Fetching Stock Price for TSLA” so users know what’s happening.
Key Concepts
Why use multiple financial tools instead of one general API?
Why use multiple financial tools instead of one general API?
Separate tools let the LLM understand what data is needed. Instead of you parsing “show me Apple’s revenue”, the LLM sees this needs
get_income_statements with ticker “AAPL”. The LLM becomes your query planner.How does C1 choose which chart type to generate?
How does C1 choose which chart type to generate?
C1 analyzes the data structure and your system prompt. If data has timestamps, it generates time-series charts. If comparing multiple values, it creates comparison charts. Your prompt guides these decisions.
Should I use Anthropic's Claude directly or C1's wrapper?
Should I use Anthropic's Claude directly or C1's wrapper?
Use C1 (
c1/anthropic/claude-sonnet-4/v-20250930) instead of direct Claude API. C1 adds UI generation capabilities on top of Claude’s analysis. Direct Claude only returns text.Can I add custom visualizations?
Can I add custom visualizations?
Yes! Use Custom Components to define domain-specific charts like candlestick charts, correlation matrices, or portfolio allocations.
Going to Production
Before deploying:- Add rate limiting to prevent API quota exhaustion
- Implement error handling for failed API calls
- Monitor API costs - financial data APIs can get expensive
- Add authentication if serving multiple users