litellm - ✅(Solved) Fix [Bug]: store=true not forwarded for OpenAI gpt models 5.1/5.2 [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#23087Fetched 2026-04-08 00:38:38
View on GitHub
Comments
1
Participants
2
Timeline
11
Reactions
1
Author
Timeline (top)
referenced ×4labeled ×3cross-referenced ×2closed ×1

Error Message

litellm.BadRequestError: OpenAIException - The 'metadata' parameter is only allowed when 'store' is enabled.. Received Model Group=openai-gpt-5.1

Fix Action

Fixed

PR fix notes

PR #23094: fix: forward store param to OpenAI for gpt-5.1/5.2 models

Description (problem / solution / changelog)

Fixes #23087

Summary

  • The store parameter was listed as a supported OpenAI param but was never threaded through completion() -> get_optional_params(), so it was silently dropped
  • This caused OpenAI to reject requests that included metadata (added by the proxy for internal tracking) with: "The 'metadata' parameter is only allowed when 'store' is enabled."
  • Root cause: store was in OPENAI_CHAT_COMPLETION_PARAMS and DEFAULT_CHAT_COMPLETION_PARAM_VALUES but was not a named parameter of completion(), acompletion(), or get_optional_params(), so it was excluded from the parameter pipeline

Changes

  • Add store as a named parameter to acompletion() in litellm/main.py
  • Add store to completion_kwargs dict in acompletion() so it gets forwarded to completion()
  • Add store as a named parameter to completion() in litellm/main.py
  • Add store to optional_param_args dict in completion() so it gets passed to get_optional_params()
  • Add store as a named parameter to get_optional_params() in litellm/utils.py

Testing

  • Added 8 new unit tests in tests/test_litellm/llms/openai/chat/test_store_param.py covering:
    • store=True forwarded correctly for OpenAI models
    • store=False forwarded correctly
    • store=None (default) is not included in params
    • store=True works with GPT-5.1/5.2 models specifically
    • store is in supported params for relevant models
    • store appears in the final transform_request() output
    • store=True coexists correctly with metadata
    • store supported for GPT-5 search models
  • All 44 existing GPT-5 transformation tests continue to pass
  • All 16 existing OpenAI GPT transformation tests continue to pass

Changed files

  • litellm/main.py (modified, +4/-0)
  • litellm/utils.py (modified, +1/-0)
  • tests/test_litellm/llms/openai/chat/test_store_param.py (added, +111/-0)

PR #23234: Revert "Get optional params behavior"

Description (problem / solution / changelog)

Reverts BerriAI/litellm#23224

Changed files

  • litellm/main.py (modified, +0/-8)
  • tests/test_litellm/llms/openai/chat/test_store_param.py (removed, +0/-188)

Code Example

- model_name: openai-gpt-5.1
    litellm_params:
        model: openai/gpt-5.1
        api_key:  xxxxxxxxx
        allowed_openai_params: ["store"]
    model_info:
      access_groups: ["openai"]

---

curl --location 'https://my-domain/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: xxxxx' \
--data '{
    "model": "openai-gpt-5.1",
    "messages": [
        {
            "role": "user",
            "content": "what'\''s the latest gold price by today 2am UTC, citation format: simple numbered citations"
        }
    ],
    "store": true
}'

---

litellm.BadRequestError: OpenAIException - The 'metadata' parameter is only allowed when 'store' is enabled.. Received Model Group=openai-gpt-5.1

---

02:48:29 - LiteLLM Proxy:ERROR: common_request_processing.py:1121 - litellm.proxy.proxy_server._handle_llm_api_exception(): Exception occured - litellm.BadRequestError: OpenAIException - The 'metadata' parameter is only allowed when 'store' is enabled.. Received Model Group=openai-gpt-5.1
Available Model Group Fallbacks=None LiteLLM Retried: 3 times
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 923, in acompletion
    headers, response = await self.make_openai_chat_completion_request(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/logging_utils.py", line 297, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 460, in make_openai_chat_completion_request
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 437, in make_openai_chat_completion_request
    await openai_aclient.chat.completions.with_raw_response.create(
        **data, timeout=timeout
    )
  File "/usr/lib/python3.13/site-packages/openai/_legacy_response.py", line 381, in wrapped
    return cast(LegacyAPIResponse[R], await func(*args, **kwargs))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/openai/resources/chat/completions/completions.py", line 2678, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
    ...<49 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/openai/_base_client.py", line 1794, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/openai/_base_client.py", line 1594, in request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': "The 'metadata' parameter is only allowed when 'store' is enabled.", 'type': 'invalid_request_error', 'param': 'metadata', 'code': None}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/main.py", line 612, in acompletion
    response = await init_response
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 983, in acompletion
    raise OpenAIError(
    ...<4 lines>...
    )
litellm.llms.openai.common_utils.OpenAIError: Error code: 400 - {'error': {'message': "The 'metadata' parameter is only allowed when 'store' is enabled.", 'type': 'invalid_request_error', 'param': 'metadata', 'code': None}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/proxy/proxy_server.py", line 6264, in chat_completion
    result = await base_llm_response_processor.base_process_llm_request(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<16 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/proxy/common_request_processing.py", line 856, in base_process_llm_request
    responses = await llm_responses
                ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1533, in acompletion
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1509, in acompletion
    response = await self.async_function_with_fallbacks(**kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/ddtrace/internal/compat.py", line 162, in func_wrapper
    result = await coro(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5104, in async_function_with_fallbacks
    return await self.async_function_with_fallbacks_common_utils(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5061, in async_function_with_fallbacks_common_utils
    raise original_exception
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5095, in async_function_with_fallbacks
    response = await self.async_function_with_retries(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/ddtrace/internal/compat.py", line 162, in func_wrapper
    result = await coro(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5250, in async_function_with_retries
    self.should_retry_this_error(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        error=e,
        ^^^^^^^^
    ...<4 lines>...
        content_policy_fallbacks=content_policy_fallbacks,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5432, in should_retry_this_error
    raise error
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5201, in async_function_with_retries
    response = await self.make_call(original_function, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5347, in make_call
    response = await response
               ^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1891, in _acompletion
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1837, in _acompletion
    response = await _response
               ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/ddtrace/internal/compat.py", line 162, in func_wrapper
    result = await coro(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/utils.py", line 2041, in wrapper_async
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/utils.py", line 1862, in wrapper_async
    result = await original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/main.py", line 631, in acompletion
    raise exception_type(
          ~~~~~~~~~~~~~~^
        model=model,
        ^^^^^^^^^^^^
    ...<3 lines>...
        extra_kwargs=kwargs,
        ^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2398, in exception_type
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 451, in exception_type
    raise BadRequestError(
    ...<6 lines>...
    )
litellm.exceptions.BadRequestError: litellm.BadRequestError: OpenAIException - The 'metadata' parameter is only allowed when 'store' is enabled.. Received Model Group=openai-gpt-5.1
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Using LiteLLM as proxy to OpenAI GPT 5.1/5.2 LiteLLM does not forward store=True correctly for completion api

Steps to Reproduce

  1. version: v1.81.14-stable
  2. config:
  - model_name: openai-gpt-5.1
    litellm_params:
        model: openai/gpt-5.1
        api_key:  xxxxxxxxx
        allowed_openai_params: ["store"]
    model_info:
      access_groups: ["openai"]
  1. completion api call fails with following error
curl --location 'https://my-domain/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: xxxxx' \
--data '{
    "model": "openai-gpt-5.1",
    "messages": [
        {
            "role": "user",
            "content": "what'\''s the latest gold price by today 2am UTC, citation format: simple numbered citations"
        }
    ],
    "store": true
}'
litellm.BadRequestError: OpenAIException - The 'metadata' parameter is only allowed when 'store' is enabled.. Received Model Group=openai-gpt-5.1

Relevant log output

02:48:29 - LiteLLM Proxy:ERROR: common_request_processing.py:1121 - litellm.proxy.proxy_server._handle_llm_api_exception(): Exception occured - litellm.BadRequestError: OpenAIException - The 'metadata' parameter is only allowed when 'store' is enabled.. Received Model Group=openai-gpt-5.1
Available Model Group Fallbacks=None LiteLLM Retried: 3 times
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 923, in acompletion
    headers, response = await self.make_openai_chat_completion_request(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/logging_utils.py", line 297, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 460, in make_openai_chat_completion_request
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 437, in make_openai_chat_completion_request
    await openai_aclient.chat.completions.with_raw_response.create(
        **data, timeout=timeout
    )
  File "/usr/lib/python3.13/site-packages/openai/_legacy_response.py", line 381, in wrapped
    return cast(LegacyAPIResponse[R], await func(*args, **kwargs))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/openai/resources/chat/completions/completions.py", line 2678, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
    ...<49 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/openai/_base_client.py", line 1794, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/openai/_base_client.py", line 1594, in request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': "The 'metadata' parameter is only allowed when 'store' is enabled.", 'type': 'invalid_request_error', 'param': 'metadata', 'code': None}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/main.py", line 612, in acompletion
    response = await init_response
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/llms/openai/openai.py", line 983, in acompletion
    raise OpenAIError(
    ...<4 lines>...
    )
litellm.llms.openai.common_utils.OpenAIError: Error code: 400 - {'error': {'message': "The 'metadata' parameter is only allowed when 'store' is enabled.", 'type': 'invalid_request_error', 'param': 'metadata', 'code': None}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/litellm/proxy/proxy_server.py", line 6264, in chat_completion
    result = await base_llm_response_processor.base_process_llm_request(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<16 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/proxy/common_request_processing.py", line 856, in base_process_llm_request
    responses = await llm_responses
                ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1533, in acompletion
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1509, in acompletion
    response = await self.async_function_with_fallbacks(**kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/ddtrace/internal/compat.py", line 162, in func_wrapper
    result = await coro(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5104, in async_function_with_fallbacks
    return await self.async_function_with_fallbacks_common_utils(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5061, in async_function_with_fallbacks_common_utils
    raise original_exception
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5095, in async_function_with_fallbacks
    response = await self.async_function_with_retries(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/ddtrace/internal/compat.py", line 162, in func_wrapper
    result = await coro(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5250, in async_function_with_retries
    self.should_retry_this_error(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        error=e,
        ^^^^^^^^
    ...<4 lines>...
        content_policy_fallbacks=content_policy_fallbacks,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5432, in should_retry_this_error
    raise error
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5201, in async_function_with_retries
    response = await self.make_call(original_function, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 5347, in make_call
    response = await response
               ^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1891, in _acompletion
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/router.py", line 1837, in _acompletion
    response = await _response
               ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/ddtrace/internal/compat.py", line 162, in func_wrapper
    result = await coro(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/utils.py", line 2041, in wrapper_async
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/utils.py", line 1862, in wrapper_async
    result = await original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/litellm/main.py", line 631, in acompletion
    raise exception_type(
          ~~~~~~~~~~~~~~^
        model=model,
        ^^^^^^^^^^^^
    ...<3 lines>...
        extra_kwargs=kwargs,
        ^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2398, in exception_type
    raise e
  File "/usr/lib/python3.13/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 451, in exception_type
    raise BadRequestError(
    ...<6 lines>...
    )
litellm.exceptions.BadRequestError: litellm.BadRequestError: OpenAIException - The 'metadata' parameter is only allowed when 'store' is enabled.. Received Model Group=openai-gpt-5.1

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.81.14-stable

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To fix the issue, we need to ensure that the store parameter is correctly forwarded to the OpenAI API.

  • Update the litellm_params configuration to include the store parameter:
litellm_params:
  model: openai/gpt-5.1
  api_key: xxxxxxxxx
  allowed_openai_params: ["store", "metadata"]
  • Modify the completion API call to include the metadata parameter only when store is enabled:
import requests

def completion_api_call(model, messages, store):
  url = 'https://my-domain/chat/completions'
  headers = {
    'Content-Type': 'application/json',
    'Authorization': 'xxxxx'
  }
  data = {
    'model': model,
    'messages': messages
  }
  if store:
    data['store'] = True
    data['metadata'] = {}  # Add metadata parameter when store is enabled
  response = requests.post(url, headers=headers, json=data)
  return response

model = 'openai-gpt-5.1'
messages = [{'role': 'user', 'content': 'what\'s the latest gold price by today 2am UTC, citation format: simple numbered citations'}]
store = True

response = completion_api_call(model, messages, store)
print(response.json())

Verification

To verify that the fix worked, check the response from the OpenAI API. If the store parameter is correctly forwarded, the response should not contain any errors related to the metadata parameter.

Extra Tips

  • Ensure that the allowed_openai_params configuration includes all the necessary parameters for your use case.
  • If you're using a different version of LiteLLM, check the documentation for any changes to the configuration or API calls.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING