fix(insights): map in-body OpenRouter errors and drop unusable OpenAI models (#367)

* fix(insights): map in-body OpenRouter errors and drop unusable OpenAI models

OpenRouter can answer a non-streaming request with 200 OK and only an
error object, or a choice finished with "error". Map the error code
through the same status table as HTTP failures instead of reporting an
unexpected format, so a rate limit or exhausted credits keeps its reason.

OpenAI model discovery no longer lists Responses-only pro and
deep-research models or GPT-4, GPT-4 Turbo, and GPT-3.5, which lack
json_schema structured outputs, so Test connection stops calling them
usable.

Documentation impact: docs/ai-insights.md request contract and model
discovery; CHANGELOG Unreleased.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(insights): drop pre-schema OpenAI snapshots and honor 200-error Retry-After

Exclude chatgpt-4o-latest and GPT-4o snapshots before 2024-08-06 from
model discovery: neither accepts a json_schema response format, so
listing them offers models whose requests always fail.

Thread response headers from generate to completion_content so an
OpenRouter failure reported as 200 OK with an error code keeps the
response Retry-After instead of falling back to the minimum pause.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
6e93105bdaSimone committed on 9/24/2026, 7:47:18 PM· committed by GitHubparent73724e2
4 files changedLine totals unavailable