feat: Add openai-responses-api support and filter out unsupported models. - #22
Open
tinysnake wants to merge 1 commit into
Open
feat: Add openai-responses-api support and filter out unsupported models.#22tinysnake wants to merge 1 commit into
tinysnake wants to merge 1 commit into
Conversation
Support openai-responses models in callVisionModel: new responses path (POST /responses, input[] body with input_image/input_text, max_output_tokens >= 16, nested reasoning.effort, output_text parsing). chat/completions path is preserved unchanged via a symmetric if/else dispatcher; unknown API types throw a clear error and flow into the existing fallback. Pickers and auto-detect filter to supported API types via new lib/supported.ts so users never select a model that can't run. Tests: +8 (responses request/response shape, unsupported-type error + fallback, auto-detect filtering). 361 pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
callVisionModelcurrently hardcodes one REST shape (POST {baseUrl}/chat/completionswith amessagesbody andchoices[].message.contentparsing). Every model in pi-ai's registry carries a declaredapitype, and the delegate path already holds the fullModel<Api>frommodelRegistry.find()— so we can dispatch the request/response shape on that authority instead of guessing.This PR makes vision delegation speak both
openai-completionsandopenai-responses:model.apiopenai-completionsPOST {baseUrl}/chat/completionsmessages[]withimage_urldata URL (unchanged)choices[].message.content || reasoning_contentopenai-responsesPOST {baseUrl}/responsesinput[]withinput_image/input_text,max_output_tokens(≥16), nestedreasoning: { effort }output[].message.content[].output_textMotivation
With a
openai-responsesmodel (e.g.gpt-5.6-lunaon opencode-go) configured as the vision model, delegation sent a well-formed request to the wrong endpoint semantics and failed with a 400 — the model registry already declared the correct API type, but the extension ignored it. Fallback (openai-codex) was also broken in that environment.Behavior changes
anthropic-messages,google-generative-ai, …) now fail with an explicit error and flow into the existing retry/fallback path — classified as a client error, so no retry is wasted and the configured fallback model still fires. Previously they silently hit/chat/completionsand failed confusingly.visionCapableModels()andautoDetectDefaults()now use the newlib/supported.ts(isUsableVisionModel()), so users only see vision models the delegate path can actually run. Adding a future API type means relaxing one filter + adding one dispatch branch.Testing
pnpm typecheckclean,pnpm test:run— 361 tests pass (was 353)./responsesURL,input[]body,input_image/input_text,max_output_tokens ≥ 16,systemrole, nestedreasoning.effort(and no flatreasoning_effort)output[].message.content[].output_text, empty-output → "no content" erroranthropic-messagesmodels filtered out;openai-responsesmodels still pickedopencode-go/gpt-5.6-luna(responses): image description returned correctly.