migrate-sonar-to-agent-api
Skill by perplexityai
Migrates code from Perplexity's Sonar chat completions API to the Agent API at /v1/agent. Built for developers who need to update Sonar calls, models, citations and streaming to the new endpoint.
Install migrate-sonar-to-agent-api
Built from the published package, never by AI.
git clone --depth 1 https://github.com/perplexityai/api-platform-developers /tmp/api-platform-developers && mkdir -p ~/.claude/skills && cp -r /tmp/api-platform-developers/skills/migrate-sonar-to-agent-api ~/.claude/skills/migrate-sonar-to-agent-apiRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
Step-by-step: install migrate-sonar-to-agent-api in Claude Code
git clone --depth 1 https://github.com/perplexityai/api-platform-developers /tmp/api-platform-developers && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/api-platform-developers/skills/migrate-sonar-to-agent-api ~/.gemini/antigravity-cli/skills/migrate-sonar-to-agent-apiAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install migrate-sonar-to-agent-api in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This agent skill migrates code from Perplexity's Sonar API, which uses chat completions, to the Agent API at /v1/agent using responses.create. It maps endpoints, request parameters, model slugs such as sonar and sonar-pro, response parsing, streaming and citations. The migration keeps each call site's integration style, whether raw HTTP, the OpenAI SDK, the Perplexity SDK or a framework bridge.
The skill starts with a scan script that lists Sonar usage file by file, with line numbers and reference notes. It warns that the Agent API rejects unknown fields with HTTP 400 and that web search is not automatic. It is aimed at developers moving existing Sonar code, and it says the live Perplexity docs take priority if they disagree with the skill.
Written from the project's SKILL.md and checked against it.
What it can do
- Scan for Sonar usageRuns a script that lists Sonar call sites file by file, with line numbers.
- Classify integration styleSorts each call site as raw HTTP, OpenAI SDK, Perplexity SDK or framework bridge.
- Rewrite request bodiesMoves requests to /v1/agent and maps messages to input and model slugs to presets.
- Rewrite response handlingUpdates response parsing, output_text, usage keys and status branching.
- Map citationsReads citations from the search_results output item instead of a top-level field.
- Migrate streaming consumersReplaces delta.content handling with typed SSE events and handles all terminal events.
- Migrate function callingUpdates tool shapes, renames reserved tool names and adds the function output loop.
- Verify the migrationDescribes live smoke tests and grep checks for leftover Sonar code.
What you need
- Perplexity API key (PERPLEXITY_API_KEY) for live verification
- Python to run the scan script
- openai Python SDK 1.66 or newer, if the code uses the OpenAI SDK
Try asking
- Migrate the Sonar chat completions calls in this repo to the Agent API
- Scan my project for Sonar usage and list each file that needs changes
- Convert my Sonar streaming consumer to handle Agent API SSE events
Good to know
- The Agent API rejects any leftover Sonar field with HTTP 400.
- Web search is not automatic and must be added as a tool or through a preset.
- There is no perplexity/sonar-pro slug; sonar-pro needs a mapping choice.
- Anthropic models require max_output_tokens.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: skills/migrate-sonar-to-agent-api/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to migrate-sonar-to-agent-api
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
migrate-sonar-to-agent-api: common questions
Does this skill change Search API code?
No. The skill says Search API code, such as client.search.create() and POST /search, is a different product and is unaffected.
Where do citations come from after migrating to the Agent API?
The skill says there is no top-level citations field on Agent responses. Citations are read from the search_results output item inside output[].
Why does the migrated code return HTTP 200 on failed runs?
The skill says failed and cancelled runs return HTTP 200 with status set to failed or cancelled, so code should branch on response.status.
How do I install migrate-sonar-to-agent-api?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is migrate-sonar-to-agent-api free?
The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.
Is migrate-sonar-to-agent-api safe to use?
It scores 65 of 100. Grades: maintenance B, licence A, quality B. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to migrate-sonar-to-agent-api?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
