nextcloud / nextcloud/integration_openai

401 error returned when using OpenRouter API and Key unless personal API Key is provided.

Open
#401 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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?

v34.0.1

Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.

Safari 26.5.2

Describe the Bug

Using OpenRouter endpoints with an API key results in a 401 unauthorized error, specifying a missing authentication header, unless a valid API key is also provided by the user rather than the admin. This results in the integration using the selected OpenRouter model by the admin, while utilizing the users specified key. However, requests to OpenRouter fail unless the user provides one.

Specifically, in the logs:

Warning
integration_openai
ClientException
Client error: `POST https://openrouter.ai/api/v1/chat/completions` resulted in a `401 Unauthorized` response: {"error":{"message":"Missing Authentication header","code":401}}
API request error : Client error: `POST https://openrouter.ai/api/v1/chat/completions` resulted in a `401 Unauthorized` response: {"error":{"message":"Missing Authentication header","code":401}}
Expected Behavior

A response should be returned, properly authenticated by the admin provided API key. Without returning an authentication error.

To Reproduce

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with integration_openai 4.5.1, Nextcloud v34.0.1, the OpenRouter service URL, and the openrouter/auto model. Start by tracing how the admin-provided API key is selected for the chat-completions request and compare that request with one made using a user-provided key. Done means the admin key supplies the authentication header and OpenRouter returns a response without requiring a personal key.

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
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.