perplexity-migration-deep-dive
Migrate to Perplexity Sonar from other search/LLM APIs using the strangler fig pattern. Use when switching from Google Custom Search, Bing API, or other LLMs to Perplexity, or migrating from legacy pplx-api models. Trigger with phrases like "migrate to perplexity", "switch to perplexity", "replace search API with perplexity", "perplexity replatform".
Best use case
perplexity-migration-deep-dive is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Migrate to Perplexity Sonar from other search/LLM APIs using the strangler fig pattern. Use when switching from Google Custom Search, Bing API, or other LLMs to Perplexity, or migrating from legacy pplx-api models. Trigger with phrases like "migrate to perplexity", "switch to perplexity", "replace search API with perplexity", "perplexity replatform".
Teams using perplexity-migration-deep-dive should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/perplexity-migration-deep-dive/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How perplexity-migration-deep-dive Compares
| Feature / Agent | perplexity-migration-deep-dive | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Migrate to Perplexity Sonar from other search/LLM APIs using the strangler fig pattern. Use when switching from Google Custom Search, Bing API, or other LLMs to Perplexity, or migrating from legacy pplx-api models. Trigger with phrases like "migrate to perplexity", "switch to perplexity", "replace search API with perplexity", "perplexity replatform".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Perplexity Migration Deep Dive
## Current State
!`npm list openai 2>/dev/null | grep openai || echo 'N/A'`
!`grep -rn "google.*search\|bing.*api\|serpapi\|pplx-7b\|pplx-70b" --include="*.ts" --include="*.py" . 2>/dev/null | head -5 || echo 'No legacy search APIs found'`
## Overview
Migrate from traditional search APIs (Google Custom Search, Bing, SerpAPI) or legacy LLMs to Perplexity Sonar. Key advantage: Perplexity combines search + LLM summarization in a single API call, replacing a multi-step pipeline.
## Migration Comparison
| Feature | Google CSE / Bing | Perplexity Sonar |
|---------|-------------------|------------------|
| Returns | Raw search results (links + snippets) | Synthesized answer + citations |
| Answer generation | Requires separate LLM call | Built-in |
| Citation handling | Manual extraction | Automatic `citations` array |
| Cost structure | Per-search ($5/1K queries) | Per-token + per-request |
| Recency filter | Date range parameters | `search_recency_filter` |
| Domain filter | Site restriction | `search_domain_filter` |
## Instructions
### Step 1: Assess Current Integration
```bash
set -euo pipefail
# Find existing search API usage
grep -rn "googleapis.*customsearch\|bing.*search\|serpapi\|serper\|tavily" \
--include="*.ts" --include="*.py" --include="*.js" \
. 2>/dev/null || echo "No search APIs found"
# Count integration points
grep -rln "search.*api\|customsearch\|bing.*web" \
--include="*.ts" --include="*.py" --include="*.js" \
. 2>/dev/null | wc -l
```
### Step 2: Build Adapter Layer
```typescript
// src/search/adapter.ts
export interface SearchResult {
answer: string;
citations: string[];
rawResults?: Array<{ title: string; url: string; snippet: string }>;
}
export interface SearchAdapter {
search(query: string, opts?: { recency?: string; domains?: string[] }): Promise<SearchResult>;
}
// Legacy adapter (existing Google/Bing implementation)
class GoogleSearchAdapter implements SearchAdapter {
async search(query: string): Promise<SearchResult> {
// Existing Google CSE code
const results = await googleCustomSearch(query);
return {
answer: "", // No built-in answer generation
citations: results.items.map((i: any) => i.link),
rawResults: results.items.map((i: any) => ({
title: i.title,
url: i.link,
snippet: i.snippet,
})),
};
}
}
// New Perplexity adapter
class PerplexitySearchAdapter implements SearchAdapter {
private client: OpenAI;
constructor() {
this.client = new OpenAI({
apiKey: process.env.PERPLEXITY_API_KEY!,
baseURL: "https://api.perplexity.ai",
});
}
async search(query: string, opts?: { recency?: string; domains?: string[] }): Promise<SearchResult> {
const response = await this.client.chat.completions.create({
model: "sonar",
messages: [{ role: "user", content: query }],
...(opts?.recency && { search_recency_filter: opts.recency }),
...(opts?.domains && { search_domain_filter: opts.domains }),
} as any);
return {
answer: response.choices[0].message.content || "",
citations: (response as any).citations || [],
rawResults: (response as any).search_results || [],
};
}
}
```
### Step 3: Feature Flag Traffic Split
```typescript
// src/search/factory.ts
function getSearchAdapter(): SearchAdapter {
const perplexityPercent = parseInt(process.env.PERPLEXITY_TRAFFIC_PERCENT || "0");
if (Math.random() * 100 < perplexityPercent) {
return new PerplexitySearchAdapter();
}
return new GoogleSearchAdapter();
}
// Migration schedule:
// Week 1: PERPLEXITY_TRAFFIC_PERCENT=10 (canary)
// Week 2: PERPLEXITY_TRAFFIC_PERCENT=50 (half traffic)
// Week 3: PERPLEXITY_TRAFFIC_PERCENT=100 (full migration)
// Week 4: Remove Google adapter code
```
### Step 4: Validate Migration Quality
```typescript
// Compare results between old and new adapter
async function compareSearchResults(query: string): Promise<{
perplexity: SearchResult;
google: SearchResult;
citationOverlap: number;
}> {
const [perplexity, google] = await Promise.all([
new PerplexitySearchAdapter().search(query),
new GoogleSearchAdapter().search(query),
]);
// Check citation overlap (shared domains)
const pplxDomains = new Set(perplexity.citations.map((u) => new URL(u).hostname));
const googleDomains = new Set(google.citations.map((u) => new URL(u).hostname));
const overlap = [...pplxDomains].filter((d) => googleDomains.has(d)).length;
return {
perplexity,
google,
citationOverlap: overlap / Math.max(pplxDomains.size, 1),
};
}
```
### Step 5: Simplify Post-Migration
```typescript
// Before migration: 3-step pipeline
// 1. Google Custom Search API → raw results
// 2. Send results to LLM for summarization
// 3. Extract citations manually
// After migration: 1-step
async function search(query: string): Promise<{ answer: string; sources: string[] }> {
const client = new OpenAI({
apiKey: process.env.PERPLEXITY_API_KEY!,
baseURL: "https://api.perplexity.ai",
});
const response = await client.chat.completions.create({
model: "sonar",
messages: [{ role: "user", content: query }],
});
return {
answer: response.choices[0].message.content || "",
sources: (response as any).citations || [],
};
}
```
## Rollback Plan
```bash
set -euo pipefail
# Instant rollback: set traffic to 0%
# kubectl set env deployment/search-app PERPLEXITY_TRAFFIC_PERCENT=0
# The adapter layer keeps both implementations live until decommissioned
```
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Citation format differs | Google returns titles, Perplexity returns URLs | Normalize in adapter |
| No raw results | Perplexity returns synthesized answer | Use `search_results` field if available |
| Higher latency | Perplexity does search + synthesis | Expected; cache to compensate |
| Cost increase | Perplexity uses more tokens | Route simple queries to sonar, limit max_tokens |
## Output
- Adapter layer abstracting search implementations
- Feature-flagged traffic split for gradual migration
- Quality comparison between old and new search
- Simplified single-API architecture post-migration
## Resources
- [Perplexity API Documentation](https://docs.perplexity.ai)
- [Strangler Fig Pattern](https://martinfowler.com/bliki/StranglerFigApplication.html)
## Next Steps
For advanced troubleshooting, see `perplexity-advanced-troubleshooting`.Related Skills
workhuman-upgrade-migration
Workhuman upgrade migration for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman upgrade migration".
wispr-upgrade-migration
Wispr Flow upgrade migration for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr upgrade migration".
windsurf-upgrade-migration
Upgrade Windsurf IDE, migrate settings from VS Code or Cursor, and handle breaking changes. Use when upgrading Windsurf versions, migrating from another editor, or handling configuration changes after updates. Trigger with phrases like "upgrade windsurf", "windsurf update", "migrate to windsurf", "windsurf from cursor", "windsurf from vscode".
windsurf-migration-deep-dive
Migrate to Windsurf from VS Code, Cursor, or other AI IDEs with full configuration transfer. Use when migrating a team to Windsurf, transferring Cursor rules, or evaluating Windsurf against other AI editors. Trigger with phrases like "migrate to windsurf", "switch to windsurf", "windsurf from cursor", "windsurf from copilot", "windsurf evaluation".
webflow-upgrade-migration
Analyze, plan, and execute Webflow SDK upgrades (webflow-api v1 to v3) with breaking change detection, API v1-to-v2 migration, and deprecation handling. Trigger with phrases like "upgrade webflow", "webflow migration", "webflow breaking changes", "update webflow SDK", "webflow v1 to v2".
webflow-migration-deep-dive
Execute major Webflow migrations — from other CMS platforms to Webflow CMS, between Webflow sites, or large-scale content re-architecture using the Data API v2 bulk endpoints, strangler fig pattern, and data validation. Trigger with phrases like "migrate to webflow", "webflow migration", "import into webflow", "webflow replatform", "move content to webflow", "webflow bulk import", "wordpress to webflow".
vercel-upgrade-migration
Upgrade Vercel CLI, Node.js runtime, and Next.js framework versions with breaking change detection. Use when upgrading Vercel CLI versions, migrating Node.js runtimes, or updating Next.js between major versions on Vercel. Trigger with phrases like "upgrade vercel", "vercel migration", "vercel breaking changes", "update vercel CLI", "next.js upgrade on vercel".
vercel-migration-deep-dive
Migrate to Vercel from other platforms or re-architecture existing Vercel deployments. Use when migrating from Netlify, AWS, or Cloudflare to Vercel, or when re-platforming an existing Vercel application. Trigger with phrases like "migrate to vercel", "vercel migration", "switch to vercel", "netlify to vercel", "aws to vercel", "vercel replatform".
veeva-upgrade-migration
Veeva Vault upgrade migration for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva upgrade migration".
veeva-migration-deep-dive
Veeva Vault migration deep dive for enterprise operations. Use when implementing advanced Veeva Vault patterns. Trigger: "veeva migration deep dive".
vastai-upgrade-migration
Upgrade Vast.ai CLI, migrate API versions, and handle breaking changes. Use when upgrading vastai CLI, detecting deprecations, or migrating between API versions. Trigger with phrases like "upgrade vastai", "vastai migration", "vastai breaking changes", "update vastai CLI".
vastai-migration-deep-dive
Migrate GPU workloads to or from Vast.ai, or between GPU providers. Use when switching from AWS/GCP/Azure GPU instances to Vast.ai, migrating between GPU types, or re-platforming ML infrastructure. Trigger with phrases like "migrate to vastai", "vastai migration", "switch to vastai", "vastai from aws", "vastai from lambda".