Skip to content

[Feature]: Support non-standard provider params (e.g. DashScope enable_search) via extra_body #4688

Description

@leoleils

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

  • Core / Backend (app, agents, config, providers, utils, local_models)

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

  1. Document that users must manually wrap in extra_body — poor UX, non-obvious
  2. Hard-code known DashScope params — fragile, doesn't generalize to other providers

Willing to Contribute

  • I am willing to open a PR for this feature (after discussion).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions