packages/provider-openai sends tracked queries to the OpenAI Responses API with web search. Canonry uses the answer text for mentions and URL citation annotations for cited domains.
validateConfig(config: OpenAIConfig): OpenAIHealthcheckResultValidates that the config has a non-empty API key. Returns the model name that will be used.
healthcheck(config: OpenAIConfig, signal?: AbortSignal): Promise<OpenAIHealthcheckResult>Makes a lightweight OpenAI API call to verify the key works. Returns ok/error with a message.
executeTrackedQuery(input: OpenAITrackedQueryInput): Promise<OpenAIRawResult>Sends the unchanged query to the OpenAI Responses API without instructions. The adapter requires the web_search tool and sends a requested location in user_location. See Retrieval contract. The result includes these fields.
rawResponse — the full OpenAI API response (output items, usage metadata)groundingSources — extracted { uri, title } pairs from URL citation annotationssearchQueries — web search queries extracted from web_search_call.action.query / action.queriesmodel — the model used (default: gpt-5.4)retrievalStatus — whether the response shows a search (see Retrieval detection)retrievalContract — always search-required-v1 (OPENAI_RETRIEVAL_CONTRACT)normalizeResult(raw: OpenAIRawResult): OpenAINormalizedResultExtracts analyst-relevant fields from the raw response:
answerText — concatenated text from output_text content items in message outputscitedDomains — unique domains extracted from URL citation annotations (www. stripped)groundingSources — pass-through of { uri, title } pairssearchQueries — pass-through of search queries usedretrievalStatus — re-derived from the response output when present, otherwise the recorded valueOpenAI records search-required-v1 in query_snapshots.retrieval_contract. The request sends tool_choice: "required" with web_search as its only tool. Adding another tool changes that contract, since required lets the model select from the tools in the request. These observations measure the Responses API. The cdp:chatgpt browser adapter measures the ChatGPT web UI separately.
retrievalStatus is read from the response, not assumed from the contract:
| Response | retrievalStatus |
|---|---|
any web_search_call output item (any action: search, open_page, find_in_page; with or without a query) |
used |
Nonempty output, status: "completed" or omitted, and no web_search_call item |
not-used |
no search call and status is incomplete, failed, or any other unfinished state |
unknown |
output missing, not an array, or empty |
unknown |
unknown never collapses into not-used: only an intact response can prove that no search happened. Under forced search nearly every row reads used; that is the contract holding, and a not-used row is the visible breach.
native-auto-v1Releases 4.139.0 (the first to record a contract) through 5.19.0 labelled OpenAI rows native-auto-v1 and retrievalStatus: unknown, although every one of those releases sent the identical forced-search request above. The label was wrong, not merely old, and left alone it would show a contract change at the upgrade where the method never changed. canonry backfill answer-visibility corrects those rows: native-auto-v1 becomes search-required-v1, and the status is re-derived from the stored apiResponse (left unknown when no payload was stored). It reports the count as retrievalRelabeled, touches no other provider, and never moves a row already on search-required-v1. Rows with a NULL contract predate the field and stay NULL: early releases wrapped the query in a search prompt, so those rows were not all built one way.
Default: gpt-5.4. Configurable via OpenAIConfig.model.
Optional. Set OpenAIConfig.baseUrl — via the OPENAI_BASE_URL env var or providers.openai.baseUrl in ~/.canonry/config.yaml — to route requests through a proxy or gateway in front of the OpenAI API. It maps to the SDK’s baseURL. When unset, the SDK uses its default endpoint (https://api.openai.com/v1).
The provider uses OpenAI’s web search tool (web_search, the current GA tool — released 2025-08-26 in the SDK as web_search_2025_08_26). When enabled, the Responses API:
web_search_call output items)output_text content blocksCitation detection works by extracting domains from final output_text.annotations entries where type === 'url_citation'. The provider intentionally does not treat web_search_call.action.sources as citations, because those are retrieval/search telemetry rather than final answer citations. The job runner then matches the cited domains against the project’s canonical domain and competitor domains to determine citation state.
We deliberately do not set the new web_search tool’s filters.allowed_domains — Canonry tracks who actually gets cited across the open web, so allow-listing would defeat the point. web_search (GA) is used over the legacy web_search_preview for the same reason: measure the open web as users see it.
new URL()www. prefix is strippedQuota policy is passed via OpenAIConfig.quotaPolicy but enforcement is handled by the job runner (not the provider itself).
The job runner stores the following in query_snapshots.raw_response as JSON:
{
"model": "gpt-4o",
"groundingSources": [
{ "uri": "https://example.com/page", "title": "Page Title" }
],
"searchQueries": ["keyword related search"],
"apiResponse": { "output": [...] }
}
retrieval_status and retrieval_contract are separate query_snapshots columns, not part of this envelope.
Live OpenAI API calls implemented with Responses API web search. The openai SDK is used for API communication.