Many SQL errors on the API but not on the website - why?

After researching this for a month+, we could not find any solution.
All of the models produce the same 4-5 SQL errors when trying to convert NLP to SQL query.
We tried both the text-davinci-003, and the Turbo 3.5, both makes the same BEGINNERS errors:

  1. “window functions are not allowed in where” SQL error
  2. “must appear in the GROUP BY clause” SQL error
  3. “more than one row returned by a subquery used as an expression” SQL error

The intention of the produced sql is correct, but it always make these errors.
No matter how to try to tell it to stop doing these, it will insist doing them, like someone trained it only on errors.

On the website however, not only it won’t make them, it also knows how to fix them.

Is there ANYTHING we can do to :

  1. Make it listen to us and not do this
  2. Use any other automated library to fix them ? (tried, it is too complex to identify)
  3. Any other model that won’t do this? (why the website does not ? )