Skip to content

Feat: BYOM API flavor constants and factory resolution#61

Merged
cosminacho merged 6 commits intomainfrom
feat/byom-api-flavors
Apr 16, 2026
Merged

Feat: BYOM API flavor constants and factory resolution#61
cosminacho merged 6 commits intomainfrom
feat/byom-api-flavors

Conversation

@cosminacho
Copy link
Copy Markdown
Collaborator

Summary

  • Added 7 new BYOM API flavor constants to ApiFlavor enum: OpenAiChatCompletions, OpenAiResponses, OpenAiEmbeddings, GeminiGenerateContent, GeminiEmbeddings, AwsBedrockInvoke, AwsBedrockConverse
  • Extended API_FLAVOR_TO_VENDOR_TYPE mapping so BYOM discovery flavors automatically resolve to the correct vendor type
  • Added BYOM_TO_ROUTING_FLAVOR mapping to translate BYOM discovery flavors to routing-level API flavors
  • Updated LangChain factory (get_chat_model) to derive api_flavor from the discovered BYOM flavor when user doesn't supply one
  • Updated LiteLLM client to resolve BYOM flavors during discovery before building API config

Test plan

  • ruff check passes
  • ruff format --check passes
  • pyright passes (0 errors)
  • pytest tests passes (1502 passed)
  • Verify with real BYOM model discovery that the correct client is instantiated

🤖 Generated with Claude Code

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>
@cosminacho cosminacho merged commit 69d9cf3 into main Apr 16, 2026
8 checks passed
@cosminacho cosminacho deleted the feat/byom-api-flavors branch April 16, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant