# fix\(insights\): map in-body OpenRouter errors and drop unusable OpenAI models \(\#367\) · lucenx/codexbar-plasma

[View on GitCafe](https://git.cafe/lucenx/codexbar-plasma/commit/6e93105bdab859b335b55ff4fe3cffdc28a45bf8)

Repository: [lucenx/codexbar-plasma](https://git.cafe/lucenx/codexbar-plasma)

Visibility: public

Requested revision: 6e93105bdab859b335b55ff4fe3cffdc28a45bf8

Requested commit: 6e93105bdab859b335b55ff4fe3cffdc28a45bf8

Commit: 6e93105bdab859b335b55ff4fe3cffdc28a45bf8

Tree: 6d58d9c8d3f857b084bfaf7f25c2c73b58018476

Author: Simone

Committer: GitHub

## Message

```
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>
```

## Parents

- [73724e2099d98e793611baaf155207ee0575f8d7](https://git.cafe/lucenx/codexbar-plasma/commit/73724e2099d98e793611baaf155207ee0575f8d7?format=markdown)

[Source at this commit](https://git.cafe/lucenx/codexbar-plasma/tree/6e93105bdab859b335b55ff4fe3cffdc28a45bf8?format=markdown)
