Skip to content

Mistral API returns 401 in integration_openai while the same API key works with curl #407

Description

@vertdechat

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions