Feat: BYOM API flavor constants and factory resolution#61
Merged
cosminacho merged 6 commits intomainfrom Apr 16, 2026
Merged
Conversation
BYOM models from the discovery endpoint return new PascalCase API flavors (e.g. OpenAiChatCompletions, GeminiGenerateContent, AwsBedrockConverse). Add these as constants and automatically resolve them to the correct routing-level flavors and vendor types so clients are instantiated correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move BYOM discovery flavors to their own ByomApiFlavor enum instead of mixing them into ApiFlavor. Remove embedding flavors from routing mapping since they can't be set on embedding classes. Version bump to 1.8.3. Tested against live BYO_AS discovery endpoint — factory correctly resolves: - OpenAiChatCompletions → UiPathChatOpenAI - OpenAiEmbeddings → UiPathOpenAIEmbeddings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…dings - Discovered BYOM api_flavor now overrides user-supplied api_flavor in both the LangChain chat factory and the LiteLLM client - get_embedding_model now reads discovered_api_flavor consistently (not just as a vendor fallback when vendor is None) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d flavor The OpenAI request hooks dynamically detected api_flavor from the URL path, allowing a model to use both chat-completions and responses. But models (BYOM or otherwise) may only support one specific flavor as reported by the discovery endpoint. Changes: - fix_url_and_api_flavor_header (langchain) accepts locked api_flavor - OpenAIRequestHandler (core) accepts locked api_flavor - LangChain OpenAI/Azure chat model hooks read api_config.api_flavor - Factory constructs api_config with the discovered flavor locked in - Discovered api_flavor (routing or BYOM) always takes precedence Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Follow the same pattern as UiPathChatAnthropic.vendor_type: add an api_flavor field to UiPathChatOpenAI, UiPathAzureChatOpenAI, and UiPathAzureAIChatCompletionsModel. The model_validator sets api_config.api_flavor from the field, and the request hook reads it. The factory now passes api_flavor= directly instead of constructing a full UiPathAPIConfig. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
LangChain's ChatOpenAI auto-infers use_responses_api from parameters
like reasoning={}, model names (gpt-5-pro), context_management, etc.
This can silently switch a chat-completions-only model to the Responses
API, sending an incompatible payload format.
When api_flavor is locked:
- chat-completions → use_responses_api = False (prevents auto-switch)
- responses → use_responses_api = True (ensures correct format)
- None → use_responses_api stays None (dynamic auto-detect)
Also removes redundant use_responses_api logic from the factory since
the model class now handles it.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
ApiFlavorenum:OpenAiChatCompletions,OpenAiResponses,OpenAiEmbeddings,GeminiGenerateContent,GeminiEmbeddings,AwsBedrockInvoke,AwsBedrockConverseAPI_FLAVOR_TO_VENDOR_TYPEmapping so BYOM discovery flavors automatically resolve to the correct vendor typeBYOM_TO_ROUTING_FLAVORmapping to translate BYOM discovery flavors to routing-level API flavorsget_chat_model) to deriveapi_flavorfrom the discovered BYOM flavor when user doesn't supply oneTest plan
ruff checkpassesruff format --checkpassespyrightpasses (0 errors)pytest testspasses (1502 passed)🤖 Generated with Claude Code