#2423·BERTopic

BadRequestError: Error code: 400 - {'error': {'message': "Unsupported parameter: 'stop' is not supported with this model.", 'type': 'invalid_request_error', 'param': 'stop', 'code': 'unsupported_parameter'}}

Author: yourlogarithmCreated Sep 12, 2025Updated Aug 12, 2026
Labelsbug

Have you searched existing issues?

  • I have searched and found no existing issues

Describe the bug

Using openai.AzureOpenAI with BERTopic for fine-tuning topic representations crashes due to an unsupported stop parameter being inserted.

Reproduction

python
from bertopic import BERTopic
from bertopic.representation import OpenAI
from openai import AzureOpenAI

client = AzureOpenAI(
    azure_endpoint="https://super-secret.openai.azure.com/",
    azure_deployment="deployment",
    api_key="api_key",
    api_version="2024-12-01-preview",
)

representation_model = OpenAI(client=client)
labels, _ = BERTopic().fit(docs)

This results in an HTTP 400 error from Azure:

BadRequestError: Error code: 400 - {
  'error': {
    'message': "Unsupported parameter: 'stop' is not supported with this model.",
    'type': 'invalid_request_error',
    'param': 'stop',
    'code': 'unsupported_parameter'
  }
}

Workaround

I resolved the issue by monkey-patching bertopic/representation/_openai.py#L220 to remove the parameter:

python
kwargs.pop("stop", None)

BERTopic Version

0.17.3