Error code: 400 Validation error at #/dataSources/0: Unable to extract tag using discriminator 'type'

cognitive_client = AsyncAzureOpenAI(

    async def cognitive_stream(self, prompt: str):

        if not prompt:
            yield "no question"
        if not self.messages:
                    "role": "system",
                    "content": r"you are helpful asistant.",
        self.update_messages({"role": "user", "content": prompt})

            response = await
                    "dataSources": [
                            "typegit log": "AzureCognitiveSearch",
                            "parameters": {
                                "endpoint": os.environ.get("AZURE_COGNITIVE_ENDPOINT"),
                                "key": os.environ.get("AZURE_COGNITIVE_RESOURCE_KEY"),
                                "indexName": os.environ.get(

            all_content = ""
            async for chunk in response:
                if "content" == list(chunk.choices[0].messages[0]["delta"].keys())[0]:
                    content = chunk.choices[0].messages[0]["delta"]["content"]
                    all_content += content
                    yield content
                    self.update_messages({"role": "assistant", "content": content})

        except Exception as e:
            logging.error(f"Error communicating with OpenAI: {e}")
            yield f"Error communicating with OpenAI: {e}"```

I started getting this error from OpenAI even though I haven’t changed anything, can anyone help me? I’m facing the same issue with deployment, what could be the cause?

You are using Microsoft extensions, so that complicates analysis, along with showing part of a class and not the usage. I don’t see any reason to use a r-string literal in your code.

It looks like you are calling with the v1.0.0+ openai python library methods to call API, but attempting to parse the response as a dictionary as if it were <= v0.28.1 before large changes were made in November. The new library also has different async client methods. So I would start by looking at the python library to see if it was changed. comment out the whole “extra body” section. simplify until the call works and then the parsing works, and then go to Microsoft-specific stuff again.

I didn’t change anything in the code, it was working a few hours ago without any problems.

Are you working on a platform where another administrator can update the python libraries, though?

Either you try different things, or you blame it on Microsoft and do nothing.

I’m trying to say this, I didn’t make any changes to the code, this given code snippet is the adapted version of the default Azure Cognitive Search templates for OpenAI 1.9.0, which is also stated in their own documents in this way. Suddenly, without changing anything in the code, I start getting this kind of error.

users of OpenAI products that are on the forum can’t fix Microsoft backend services…

So is the problem caused by Microsoft API ?

If you are sending using the same code and the same input on the same platform with the same backend completely under your control, and the API that you connect to is reporting that it cannot parse what you are sending, than it would be logical that what you are sending cannot be parsed because of a change in the code by the recipient.

It would also be logical to try sending different things, learn exactly what aspect of the API request is failing, and not rely on this being an “accident” that someone will quickly fix without more information.

typo fix in here sry guys