Expected Behavior

I noticed that the chat.completions.create method in version 1.82.1 of the Python OpenAI package includes support for extra_headers, extra_query, and extra_body.

completion = client.chat.completions.create(
        model="qwen-plus-2025-04-28",
        messages=messages,
        extra_headers={
            "Authorization": f"Bearer {os.getenv('DASHSCOPE_API_KEY')}"
        },
        extra_body={"enable_thinking": True},
        stream=True
    )

In OpenAiChatOptions, we already have the httpHeaders parameter which can serve as an alternative to extra_headers. However, there are no corresponding alternatives for extra_query and extra_body.

Will Spring AI support these two parameters? Doing so might avoid the need for a lot of model-specific implementations.

Context https://pypi.org/project/openai/

Image

Comment From: asaikali

Looks like extra_headers, extra_query, and extra_body are supported in the offical python sdk, you can find them in the _base_client.py https://github.com/openai/openai-python/blob/db5c35049accb05f5fb03791ef9c12547fd309a7/src/openai/_base_client.py#L1841

I searched through the openai python sdk codebase and found these parameters everywhere here is an example

these https://github.com/openai/openai-python/blob/db5c35049accb05f5fb03791ef9c12547fd309a7/src/openai/resources/chat/completions/completions.py#L119

Since a lot of providers offer openai compatible endpoints that can be serving models that have settings that don't have equivalent in the official openai api, spring-ai users can't send requests to these providers. For example the very popular vllm engine uses [Extra Parametes)[https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html#extra-parameters] when serving models with options that can not be represented by the open AI API.

While extra_headers, extra_query, and extra_body are not part of the official contract with api.openai.com they are part of the official python sdk. Adding these extra fields to spring-ai will make spring-ai usable against a wider range of models.