Skip to content

docs: document sources API parameter and focusMode deprecation (v1.12.1)#1043

Open
willtwilson wants to merge 2 commits intoItzCrazyKns:masterfrom
willtwilson:docs/sources-api-migration-v1.12.1
Open

docs: document sources API parameter and focusMode deprecation (v1.12.1)#1043
willtwilson wants to merge 2 commits intoItzCrazyKns:masterfrom
willtwilson:docs/sources-api-migration-v1.12.1

Conversation

@willtwilson
Copy link

@willtwilson willtwilson commented Mar 8, 2026

Context

The v1.12.1 release replaced the \ ocusMode\ parameter with \sources\ in the API endpoints. This is a breaking change with no migration documentation — existing integrations that pass \ ocusMode\ get no error, but search does not work as expected because no sources are activated.

I discovered this while building an integration and had to read the source code to understand why web search had stopped working after upgrading.

Changes

Added to \docs/API/SEARCH.md:

  • Migration guide with \ ocusMode\ → \sources\ mapping table (e.g., \ ocusMode: 'webSearch'\ → \sources: ['web'])
  • Internal /api/chat\ endpoint documentation — request body parameters, NDJSON response event types, and JSON Patch accumulation pattern. This is documented as an internal API with a note to prefer /api/search\ for integrations.

Impact

This helps:

  • Developers upgrading from pre-v1.12.1 who are wondering why search stopped working
  • Integration authors who need to understand the /api/chat\ streaming format
  • Anyone building MCP servers, browser extensions, or other tools on top of Perplexica

Summary by cubic

Documents the v1.12.1 change replacing focusMode with sources, adds a migration guide, and updates internal /api/chat streaming docs (NDJSON events, JSON Patch, block.data). Clarifies endpoint behavior: /api/chat returns 200 with LLM-only output when sources is omitted, while /api/search returns 400; prefer /api/search.

  • Migration
    • Replace "focusMode": "webSearch" with "sources": ["web"], and "academicSearch" with ["academic"].
    • /api/chat strips focusMode (defaults sources to []); /api/search rejects it. Update to sources and set systemInstructions as string | null.

Written for commit 77f0099. Summary will update on new commits.

The v1.12.1 release replaced the focusMode parameter with sources
in the API endpoints. This was an undocumented breaking change that
caused silent failures in integrations.

Add to docs/API/SEARCH.md:
- Migration guide for focusMode -> sources with mapping table
- Internal /api/chat endpoint documentation (request/response format)
- NDJSON streaming response event types and JSON Patch format

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 8, 2026 22:50
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing migration and internal streaming endpoint documentation to help integrators understand the v1.12.1 breaking API change and the /api/chat NDJSON stream format.

Changes:

  • Document focusModesources migration for v1.12.1+.
  • Add internal /api/chat endpoint request body and streaming event documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.


| Type | Description | Fields |
|------|-------------|--------|
| `block` | New content block created | `block: { id, type }` |
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the /api/chat stream, block events include the full block object (e.g., { id, type, data: ... }), not just { id, type }. Documenting only id/type can mislead clients that need the block’s data payload (text chunks, widget params, research substeps, etc.). Please update the event schema description accordingly.

Suggested change
| `block` | New content block created | `block: { id, type }` |
| `block` | New content block created | `block` (full block object, e.g. `{ id, type, data, ... }`) |

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in follow-up commit (77f0099) — updated the block event description to include the full block object shape including the data payload, which is the most important field for clients assembling streamed content. Thanks for the clarification.

| `optimizationMode` | string | ✅ | `"speed"`, `"balanced"`, or `"quality"` |
| `history` | array | No | Previous conversation as `["human"/"assistant", "text"]` tuples |
| `files` | string[] | No | Uploaded file IDs to include in search context |
| `systemInstructions` | string | No | Custom instructions for the AI |
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

systemInstructions can be null in the /api/chat request body (the server schema accepts string | null). The docs currently list it as string only; please update the type/description so client implementations don’t fail strict validation when sending/receiving nulls.

Suggested change
| `systemInstructions` | string | No | Custom instructions for the AI |
| `systemInstructions` | string \| null | No | Custom instructions for the AI (may be `null` or omitted if not used) |

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in follow-up commit (77f0099) — updated the type to string | null to match the server's Zod schema. Good catch.

| `"focusMode": "webSearch"` | `"sources": ["web"]` |
| `"focusMode": "academicSearch"` | `"sources": ["academic"]` |

If you pass `focusMode` to v1.12.1+, it is silently ignored and no sources will be searched. Update your API calls to use `sources` instead.
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The note that focusMode is “silently ignored” is not accurate for /api/search: the handler returns a 400 when sources is missing (Missing sources or query). This silent-ignore behavior seems specific to /api/chat (Zod strips unknown keys and defaults sources to []). Please adjust the migration text to distinguish between /api/search vs /api/chat behavior so integrators know what to expect.

Suggested change
If you pass `focusMode` to v1.12.1+, it is silently ignored and no sources will be searched. Update your API calls to use `sources` instead.
For v1.12.1+ you must migrate to `sources`. On `/api/chat`, any `focusMode` value is ignored (Zod strips the field and defaults `sources` to `[]`, so no sources are searched). On `/api/search`, `focusMode` is not accepted as a replacement for `sources`: if you omit `sources` (even when sending `focusMode`), the request will fail with a 400 error such as `Missing sources or query`. Update your API calls to always send `sources` instead of `focusMode`.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — this was genuinely wrong. Fixed in the follow-up commit (77f0099). The updated text now correctly distinguishes the two failure modes: on /api/chat, Zod strips focusMode and defaults sources to [] (silent, no web data returned); on /api/search, omitting sources returns HTTP 400 Missing sources or query. Thanks for reading the source code to verify — I had only tested via /api/chat.

…block event schema

- Clarify that /api/chat returns HTTP 200 with no web data (sources defaults to [])
  while /api/search returns HTTP 400 when sources is missing
- Update systemInstructions type to string | null per Zod schema
- Include data field in block event documentation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants