Summary
Non-standard provider parameters (like DashScope's enable_search) configured in generate_kwargs are silently rejected by the OpenAI Python SDK because client.chat.completions.create() does not accept unknown keyword arguments.
Component(s) Affected
Problem / Motivation
DashScope's web search feature requires passing enable_search: true in the request body. Per DashScope's own documentation, when using the OpenAI Python SDK, this must be passed via extra_body — not as a top-level parameter.
Currently, qwenpaw spreads generate_kwargs directly into client.chat.completions.create(**kwargs). Since the SDK's create() method uses an explicit parameter list (no **kwargs), any non-standard parameter like enable_search causes a TypeError or gets silently dropped.
Users who configure {"enable_search": true} in the model's generate_kwargs via the UI find that web search does not work.
Proposed Solution
Add an __init__ override in OpenAIChatModelCompat that automatically detects non-standard parameters in generate_kwargs (keys not in the SDK's known parameter set) and moves them into extra_body. The SDK correctly merges extra_body into the HTTP request body.
This way:
{"enable_search": true} → automatically becomes extra_body={"enable_search": true}
{"extra_body": {"enable_search": true}} → also works (explicit form)
- Standard params like
temperature, max_tokens remain as top-level kwargs
Alternatives Considered
- Document that users must manually wrap in
extra_body — poor UX, non-obvious
- Hard-code known DashScope params — fragile, doesn't generalize to other providers
Willing to Contribute
Summary
Non-standard provider parameters (like DashScope's
enable_search) configured ingenerate_kwargsare silently rejected by the OpenAI Python SDK becauseclient.chat.completions.create()does not accept unknown keyword arguments.Component(s) Affected
Problem / Motivation
DashScope's web search feature requires passing
enable_search: truein the request body. Per DashScope's own documentation, when using the OpenAI Python SDK, this must be passed viaextra_body— not as a top-level parameter.Currently, qwenpaw spreads
generate_kwargsdirectly intoclient.chat.completions.create(**kwargs). Since the SDK'screate()method uses an explicit parameter list (no**kwargs), any non-standard parameter likeenable_searchcauses aTypeErroror gets silently dropped.Users who configure
{"enable_search": true}in the model'sgenerate_kwargsvia the UI find that web search does not work.Proposed Solution
Add an
__init__override inOpenAIChatModelCompatthat automatically detects non-standard parameters ingenerate_kwargs(keys not in the SDK's known parameter set) and moves them intoextra_body. The SDK correctly mergesextra_bodyinto the HTTP request body.This way:
{"enable_search": true}→ automatically becomesextra_body={"enable_search": true}{"extra_body": {"enable_search": true}}→ also works (explicit form)temperature,max_tokensremain as top-level kwargsAlternatives Considered
extra_body— poor UX, non-obviousWilling to Contribute