Playground writes correct HTML markup while the API call in e. g. Google Sheet does not

Why is there a difference between the output betweend calling the API in Google Sheet (AppScripts) and in the Playyground?

The Playyground writes correct HTML while the API call messes up the markup.

Any ideas?

There is no difference between the two systems other than the code used to make the calls, which may include settings such as temperature, assuming they are the same can you please post your API calling code and the response you get from that and the reply back from the playground as a comparison.