Feat: Make model optional in CreateModelResponseQuery for prompt_id flow#419
Merged
nezhyborets merged 1 commit intoMay 18, 2026
Merged
Conversation
When referencing a stored prompt via prompt_id, the OpenAI Responses API takes the model from the prompt configuration and does not require a model field on the request. Force-requiring it on the Swift type blocks that flow. Make `model` an optional `String?` (defaulting to nil in the initializer) so JSONEncoder omits it when not supplied. Existing call sites that pass a model continue to work unchanged. Closes #385 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
nezhyborets
approved these changes
May 18, 2026
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.
What
Make
modeloptional onCreateModelResponseQuery:public let model: String→public let model: String?model: String→model: String? = nilininitJSONEncoderalready omitsnilkeys, so whenmodelis not provided the encoded request will not include the"model"field.Why
Closes #385. The Responses API does not require
modelwhen a stored prompt is referenced viaprompt_id(the model is taken from the prompt's configuration). The current type forced callers to passmodel:, blocking the prompt-by-id flow.Affected Areas
Sources/OpenAI/Public/Models/Responses API/CreateModelResponseQuery.swift—modeland its init parameter are now optional.Tests/OpenAITests/OpenAITestsDecoder.swift— new tests verifying that:modelis omitted from the encoded JSON when constructed withprompt:only;modelis still encoded as the model raw value when supplied.More Info
.modelas non-optional becomes invalid for any consumer that previously did so; callers must unwrap. This matches the spec.Demoalready passmodel:explicitly, so they compile unchanged.OpenAITestsDecodertests pass locally, including the 3 new ones (testCreateResponseQueryOmitsModelWhenNil,testCreateResponseQueryEncodesModelWhenProvided, plus the existing prompt-cache-key tests).🤖 Generated with Claude Code