completion-messages api got error
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
official version
Cloud or Self Hosted
Cloud
Steps to reproduce
curl -X POST 'https://api.dify.ai/v1/completion-messages' \
--header 'Authorization: Bearer app-xxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"inputs": {
"query": "Hello, world!"
},
"response_mode": "streaming",
"user": "abc-123"
}'
Then got below
{"code": "app_unavailable", "message": "App unavailable, please check your app configurations.", "status": 400}
and post man also get the same error
✔️ Expected Behavior
should show response
❌ Actual Behavior
400 error
I found a similar closed issue that might help. The issue 访问API返回: {"code": "invalid_param", "message": "not enough....."} was resolved by ensuring the Authorization header includes Bearer before the API key [1].
To resolve the "App unavailable, please check your app configurations" error when making a POST request to the https://api.dify.ai/v1/completion-messages endpoint, follow these steps:
-
Check API Access Configuration:
- Navigate to your application in the Dify dashboard.
- Go to API Access in the left-side navigation.
- Ensure that your application is properly configured and that you have the correct API key.
-
Verify API Key:
- Make sure you are using the correct API key in your request. The API key should be included in the
Authorizationheader as shown in the example below:
- Make sure you are using the correct API key in your request. The API key should be included in the
curl -X POST 'https://api.dify.ai/v1/completion-messages' \
--header 'Authorization: Bearer app-xxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"inputs": {
"query": "Hello, world!"
},
"response_mode": "streaming",
"user": "abc-123"
}'
-
Ensure Application is Active:
- Verify that your application is active and not in a disabled or inactive state.
-
Check for Correct Endpoint Usage:
- Ensure you are using the correct endpoint and that the request payload is properly formatted. The
inputsparameter should contain thequerykey with the input text, and theresponse_modeshould be eitherstreamingorblocking.
- Ensure you are using the correct endpoint and that the request payload is properly formatted. The
-
Check for Common Errors:
- Ensure that your request does not trigger common errors such as
invalid_param,provider_not_initialize,provider_quota_exceeded,model_currently_not_support, orcompletion_request_error.
- Ensure that your request does not trigger common errors such as
By following these steps, you should be able to resolve the error and successfully make a POST request to the https://api.dify.ai/v1/completion-messages endpoint [2][3].
To continue talking to Dosu, mention @dosu.
the two endpoint apis have some different, https://github.com/langgenius/dify-docs/blob/main/jp/guides/application-publishing/developing-with-apis.md and https://github.com/langgenius/dify/blob/main/web/app/components/develop/template/template.en.mdx
data = {
"inputs": {"text": 'Hello, how are you?'},
"response_mode": "streaming",
"user": "abc-123"
}
parameter text or query?
but both got error
For the completion-messages API endpoint, the correct parameter to use in the inputs field is text. Here is the correct usage:
{
"inputs": {
"text": "Hello, world!"
},
"response_mode": "streaming",
"user": "abc-123"
}
If you are encountering errors with both text and query, ensure that you are using the correct endpoint and that your request body adheres to the required structure. The query parameter is used for the chat-messages endpoint, not completion-messages [1][2][3].
For the chat-messages endpoint, the correct parameter is query:
{
"inputs": {},
"query": "Hello, how are you?",
"response_mode": "streaming",
"conversation_id": "1c7e55fb-1ba2-4e10-81b5-30addcea2276",
"user": "abc-123"
}
Ensure you are using the correct endpoint and corresponding parameters to avoid errors.
To continue talking to Dosu, mention @dosu.
As your guide above,Im sure got error
{
"inputs": {
"text": "Hello, world!"
},
"response_mode": "streaming",
"user": "abc-123"
}
response
{
"code": "app_unavailable",
"message": "App unavailable, please check your app configurations.",
"status": 400
}
Should be a bug.
And also the doc should be clarified about query and text
This error AppUnavailableError is raised 4 times in our code repo.
if app_model.mode != "completion":
raise AppUnavailableError()
# And this one
except services.errors.app_model_config.AppModelConfigBrokenError:
logging.exception("App model config broken.")
raise AppUnavailableError()
So either you have chosen the wrong type of application, or the configuration is broken.
This error
AppUnavailableErroris raised 4 times in our code repo.``` if app_model.mode != "completion": raise AppUnavailableError()
And this one
except services.errors.app_model_config.AppModelConfigBrokenError: logging.exception("App model config broken.") raise AppUnavailableError()
So either you have chosen the wrong type of application, or the configuration is broken.
I use officail https://cloud.dify.ai/ service,form postman test it,what do you mean wrong type of application?also the configuration is working,because the chat api goes well
```
if app_model.mode != "completion":
raise AppUnavailableError()