genetic-orange
genetic-orange2y ago

I'm connecting voiceflow to an OpenAI assistant and keep getting a 400 error.

Anyone know what I'm doing wrong? I've configured it to send application/json, but VoiceFlow seems to be sending multipart/form-data. This is the error I'm getting: { "error": { "message": "Unsupported content type: 'multipart/form-data'. This API method only accepts 'application/json' requests, but you specified the header 'Content-Type: multipart/form-data'. Please try again with a supported content type.", "type": "invalid_request_error", "param": null, "code": "unsupported_content_type" }, "VF_STATUS_CODE": 400, "VF_HEADERS": { "alt-svc": "h3=":443"; ma=86400", "cf-cache-status": "DYNAMIC", "cf-ray": "87139ac93e0405a0-IAD", "connection": "keep-alive", "content-length": "354", "content-type": "application/json", "date": "Mon, 08 Apr 2024 16:23:55 GMT", "openai-organization": "[REMOVED FOR PRIVACY]", "openai-processing-ms": "87", "openai-version": "2020-10-01", "server": "cloudflare", "set-cookie": "__cf_bm=KoRE3fyY_kVaMJrNAg02PUSrWHA8AcfCE3vgQ3jcJaw-1712593435-1.0.1.1-Lajw.33VxXgd89VvEX81M4sB_cAiQ06.q7XdBgCTHNrEpHHeywYvK34ij.7njz2MAELWauKxHirI62k0hfpn_g; path=/; expires=Mon, 08-Apr-24 16:53:55 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None, _cfuvid=FDK3kLtCkqw.YGwdbaFqTdPjxUvQEZw2QtsiPVz.Wzo-1712593435240-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None", "strict-transport-security": "max-age=15724800; includeSubDomains", "x-request-id": "req_f92acce30e11360862e53ec1b0b24c99" } }
9 Replies
Tico | Voiceflow Assistant
It seems like the issue you're encountering with the 400 error when connecting Voiceflow to an OpenAI assistant is due to a mismatch in the content type expected by the API. While you've configured it to send application/json, the error message indicates that the API received a request with a Content-Type of multipart/form-data, which it does not support. Here are a few steps you can take to troubleshoot and resolve this issue: - Ensure that the header in your API request from Voiceflow explicitly sets Content-Type to application/json. This tells the API that you're sending JSON data. - Double-check the configuration of your API request in Voiceflow to make sure it matches the expected format and specifications required by the OpenAI API documentation. - Review the API block in your Voiceflow project to confirm that you're not inadvertently sending file data, which could trigger the multipart/form-data content type. - Validate the JSON format of your request body using an online JSON formatter or validator to ensure it's correctly structured. If you're still facing issues after these steps, it might be helpful to review the API documentation for both Voiceflow and OpenAI to ensure compatibility and correct request formatting. For more detailed guidance on API requests and handling responses in Voiceflow, you can refer to the following resources: - Voiceflow API Reference - Voiceflow Knowledge Base Documentation
genetic-orange
genetic-orangeOP2y ago
It is correctly configured
No description
W. Williams (SFT)
Are you using the Raw for the body JSON? You can't pass parameters.
genetic-orange
genetic-orangeOP2y ago
I'm not. Do you have an example of what that would look like?
W. Williams (SFT)
You need to have a look at the API docs from open ai. Look at the CURL request. Everything within the -d is the body:
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'
-H = Headers So you would enter the following in the body:
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}
{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}
genetic-orange
genetic-orangeOP2y ago
This is what worked: { "messages": [ { "role": "assistant", "content": "Provide a joke for every message" }, { "role": "user", "content": "{last_utterance}" } ] } But I'm still having issues making the whole flow work 😩
W. Williams (SFT)
What is the issue
genetic-orange
genetic-orangeOP2y ago
I have a step here where I want to extract the status from the API call and apply it to a variable {runstatus}. It doesn't seem like I have the right path
No description
W. Williams (SFT)
you can't access the VF header data Send me a DM I can take a look

Did you find this page helpful?