We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I've sent a request to Create speech API without passing input parameter like below using the openai Node.js library.
input
openai
fetch("https://api.openai.com/v1/audio/speech", { method: "POST", headers: { "Authorization": `Bearer ${process.env.OPENAI_API_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ model: "tts-1", voice: "alloy" }) }) .then(response => { if (!response.ok) { throw new Error(response.statusText); } console.log('Request successful'); }) .catch(error => console.error(error));
The error looks like below:
{ "error": { "message": "[{'type': 'string_too_short', 'loc': ('body', 'input'), 'msg': 'String should have at least 1 character', 'input': '', 'ctx': {'min_length': 1}}, {'type': 'enum', 'loc': ('body', 'voice'), 'msg': \"Input should be 'nova', 'shimmer', 'echo', 'onyx', 'fable' or 'alloy'\", 'input': '', 'ctx': {'expected': \"'nova', 'shimmer', 'echo', 'onyx', 'fable' or 'alloy'\"}}]", "type": "invalid_request_error", "param": null, "code": null } }
error.message
string
pure JS object
JSON
JSON.parse
regex
I think an improvement is needed so the developer can get the error message property.
error message
macOs
Node v21.7.3
openai 4.68.1
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
I've sent a request to Create speech API without passing
input
parameter like below using theopenai
Node.js library.The error looks like below:
error.message
is astring
?pure JS object
and not a string ofJSON
?I tried to parse it with
JSON.parse
but as it's not a valid JSON, I failed to do so.regex
for that?I think an improvement is needed so the developer can get the
error message
property.To Reproduce
Code snippets
OS
macOs
Node version
Node v21.7.3
Library version
openai 4.68.1
The text was updated successfully, but these errors were encountered: