nextcloud / nextcloud/integration_openai
Mistral API returns 401 in integration_openai while the same API key works with curl
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 75
- Forks
- 32
- Avg merge
- 9d 8h
- Merged PRs (30d)
- 4
Description
Which version of integration_openai are you using?
4.5.1
Which version of Nextcloud are you using?
34.0.1
Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.
Firefox
Describe the Bug
I am trying to use Mistral AI with the Nextcloud application OpenAI and LocalAI integration.
The application successfully reaches the Mistral API and retrieves the model list, but chat requests fail with:
OpenAI/LocalAI request failed: API request error:
Invalid API Key/Basic Auth:
Client error: POST https://api.mistral.ai/v1/chat/completions
resulted in a 401 Unauthorized response:
{"detail":"Unauthorized"}
Expected Behavior
The application should authenticate with the Mistral API using:
Authorization: Bearer <MISTRAL_API_KEY>
and successfully call:
https://api.mistral.ai/v1/chat/completions
To Reproduce
API key test
The same API key works correctly from inside the Nextcloud Docker container:
docker exec -it nextcloud-app-1 curl https://api.mistral.ai/v1/models
-H "Authorization: Bearer MISTRAL_API_KEY"
The command returns the Mistral model list successfully.
Network access also works:
docker exec -it nextcloud-app-1 curl -I https://api.mistral.ai
Configuration
API URL: https://api.mistral.ai/v1
Service name: Mistral
Model: mistral-small-latest
Basic authentication: disabled
The API key is entered without the Bearer prefix.
Troubleshooting already performed
Confirmed outbound HTTPS access to api.mistral.ai:443
Confirmed the API key works with curl
Disabled Basic Authentication
Deleted basic_user and basic_password
Deleted and re-entered the API key
Uninstalled and reinstalled integration_openai
Restarted the Nextcloud container
Tried mistral-small-latest
Log extract
A TaskProcessing core:text2text:chat task failed with the following message:
OpenAI/LocalAI request failed:
API request error:
Invalid API Key/Basic Auth:
Client error: POST https://api.mistral.ai/v1/chat/completions
resulted in a 401 Unauthorized response:
{"detail":"Unauthorized"}
Environment
Nextcloud version: 34.0.1.2
Nextcloud installation: Docker
Nextcloud image: nextcloud:apache
integration_openai version: [TO COMPLETE]
PHP version: [TO COMPLETE]
Host OS: Ubuntu
Mistral endpoint: https://api.mistral.ai/v1
Additional information
It looks like the API key used by integration_openai is not sent correctly in the Authorization header, or an old/incorrect credential is still being used internally.
Could you confirm whether Mistral API authentication is currently supported and whether the request header generated by the application is compatible with Mistral?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the POST to https://api.mistral.ai/v1/chat/completions from integration_openai and compare it with the successful curl request from the Nextcloud container. Trace how the application builds its Authorization header and selects credentials, then verify the corrected request with the reported Mistral model. Done means the chat request is accepted instead of returning 401.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100