Skip to main content
Build an intelligent financial data copilot that generates custom visualizations and insights based on natural language queries. This guide teaches you how to combine financial APIs with C1 to create dynamic charts, tables, and insights.
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:
Instead of pre-built dashboards, the copilot generates the perfect visualization for each query - charts for trends, tables for comparisons, cards for summaries.

Setup

Prerequisites

Create Next.js Project

npm
When prompted, select:
  • 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:
Sign up for Financial Datasets at financialdatasets.ai to get real-time stock, crypto, and financial data.

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
The writeThinkingState calls create a better UX by showing users which data sources are being queried in real-time.

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
Why threads matter:

Step 6: Set Up the Frontend UI

Create the conversational analytics interface using C1Chat:
app/page.tsx
C1Chat provides the complete conversational analytics UI with:
  • 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
Open http://localhost:3000 and try these queries:
  1. “Show me Tesla’s stock price” - See current price with change indicators
  2. “What’s Apple’s revenue trend over the last 4 quarters?” - Get financial statements with charts
  3. “Compare Bitcoin and Ethereum prices” - See multi-asset comparison
  4. 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

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.
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.
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.
Yes! Use Custom Components to define domain-specific charts like candlestick charts, correlation matrices, or portfolio allocations.

Going to Production

Before deploying:
  1. Add rate limiting to prevent API quota exhaustion
  2. Implement error handling for failed API calls
  3. Monitor API costs - financial data APIs can get expensive
  4. Add authentication if serving multiple users

Full Example & Source Code

Try Live Demo

Experience the full data copilot. Try asking about stocks, crypto, or company financials to see C1 generate custom visualizations.Try it now →

View Source Code

Complete implementation with all financial tools, thread management, and deployment config.Star on GitHub →