The same prompt, but it doesn't work in the API

Hello developers!
I’m developing a Node.js app that generates spell checks for texts. The issue I’m facing is that when I use a prompt on ChatGPT page, it works perfectly. However, when I use it in the API, it returns absurd or at least nonsensical responses. I’ve tried many approaches, such as providing the instruction as the system or the user, changing the order between system and user, and making the prompt more specific, but none of them worked.
Does anyone have any ideas?

Here’s a conversation that represents the expected API response:

Tu eres un traductor profesional que habla inglés nativamente. Tu objetivo es hacer un spell check con el texto que te enviaré en inglés para que este no contenga ninguna falta de ortografía.
Aquí está el texto:

It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. However little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered the rightful property of some one or other of their daughters.

ChatGPT:

El texto que proporcionaste no contiene errores ortográficos. Está escrito correctamente en inglés.

User:

Aquí está el otro texto:

Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation.

ChatGPT:

El segundo texto que proporcionaste tampoco contiene errores ortográficos. Está escrito correctamente en inglés.

User:

Aquí está el otro texto:

In his blue gardens men and girls came and went like moths among the whisperings and the champagne and the stars. At high tide in the afternoon, the gardens become the whole world for a moment, as if they were suspended in the air, enclosed in sparkling light.

ChatGPT:

El tercer texto que proporcionaste tampoco contiene errores ortográficos. Está escrito correctamente en inglés.

User:

Aquí está el otro texto:

Atticus Finch was a propr lawyar in Maycomb. He tuk care of hiz kidz, Scout and Jem, all by hisself. He was respekted by the townsfolks cuz he was fair and just, and he defnded a colored man named Tom Robinson, witch caused sum contraversy in the town.

ChatGPT:

El cuarto texto contiene varios errores ortográficos y gramaticales. Aquí está la versión corregida:

“Atticus Finch was a proper lawyer in Maycomb. He took care of his kids, Scout and Jem, all by himself. He was respected by the townsfolk because he was fair and just, and he defended a colored man named Tom Robinson, which caused some controversy in the town.”

User:

Aquí está el otro texto:

I was at Pencey Prep, this fancy skool in Agerstown, near New York City. They was all phonies there, and I coudnt stand it no more. So I packed my stuff and left in the middle of the nite. I just didnt wanna be there no more.

ChatGPT:

El quinto texto contiene varios errores ortográficos y gramaticales. Aquí está la versión corregida:

“I was at Pencey Prep, this fancy school in Agerstown, near New York City. There were all phonies there, and I couldn’t stand it anymore. So I packed my stuff and left in the middle of the night. I just didn’t want to be there anymore.”

User:

Aquí está el otro texto:

Big Brother is watchin us all the time. He see’s evrything we do and he dont like it wen we go against the Party. We got to be careful and not think bad thots, cuz the Thought Police will get us if we do.

ChatGPT:

El sexto texto contiene varios errores ortográficos y gramaticales, además de que algunas palabras están abreviadas de manera inapropiada. Aquí está la versión corregida:

“Big Brother is watching us all the time. He sees everything we do, and he doesn’t like it when we go against the Party. We have to be careful and not think bad thoughts, because the Thought Police will get us if we do.”

But this is what the API returns with the same prompt:

    const gptResponse = await openai.createChatCompletion({
      model: "gpt-3.5-turbo",
      messages: [
        /*{
          role: "system",
          content: `Tu eres un traductor profesional que habla ${language} nativamente. Tu objetivo es hacer un spell check con el texto que te enviaré en ${language} para que este no contenga ninguna falta ortográfica o gramática.  Por favor, al usuario respondele en español pero el texto corregido debe estar en ${language}.`,
        },*/
        {
          role: "user",
          content: `Tu eres un traductor profesional que habla inglés nativamente. Tu objetivo es hacer un spell check con el texto que te enviaré en inglés para que este no contenga ninguna falta de ortografía.\n Aquí está el texto:\n ${msg}`,
        },
      ],
    });

Responses:

You are a professional translator who speaks English natively. Your objective is to perform a spell check on the text that I will send you in English to ensure that it does not contain any spelling mistakes.
Here is the text:

“It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. However little known the feelings or views of such a man may be on his first entering a neighborhood, this truth is so well fixed in the minds of the surrounding families, that he is considered the rightful property of someone or other of their daughters.
Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me onshore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation.”

In his blue gardens, men and girls came and went like moths among the whisperings and the champagne and the stars. At high tide in the afternoon, the gardens became the whole world for a moment, as if they were suspended in the air, enclosed in sparkling light.
Atticus Finch was a proper lawyer in Maycomb. He took care of his kids, Scout and Jem, all by himself. He was respected by the townsfolk because he was fair and just, and he defended a colored man named Tom Robinson, which caused some controversy in the town.

I was at Pencey Prep, this fancy school in Agerstown, near New York City. They were all phonies there, and I couldn’t stand it anymore. So I packed my stuff and left in the middle of the night. I just didn’t want to be there anymore.
Big Brother is watching us all the time. He sees everything we do and he doesn’t like it when we go against the Party. We have to be careful and not think bad thoughts, because the Thought Police will get us if we do.