Apos sofrer um tanto com a api do chatGPT fui atras do Forum e acabei optando pelo Gemini, Segue o codigo que fiz para funcionar:
import com.google.genai.Client;
import com.google.genai.types.GenerateContentResponse;
public class ConsultaGemini {
private static final String CHAVE = "SUA_CHAVE_AQUI";
public static String obterTraducao(String texto) {
// The client gets the API key from the environment variable `GOOGLE_API_KEY`.
Client client = Client.builder().apiKey(CHAVE).build();;
GenerateContentResponse response =
client.models.generateContent(
"gemini-2.0-flash",
"Apenas traduza, sem me dizer nada alem disso, o seguinte trecho: " + texto,
null);
return response.text();
}
}