Skip to content

Sending x-api-key instead of api-key as header for azure hosted anthropic service#11517

Open
sresam89 wants to merge 2 commits intocontinuedev:mainfrom
sresam89:fix/authHeaderName
Open

Sending x-api-key instead of api-key as header for azure hosted anthropic service#11517
sresam89 wants to merge 2 commits intocontinuedev:mainfrom
sresam89:fix/authHeaderName

Conversation

@sresam89
Copy link

@sresam89 sresam89 commented Mar 16, 2026

Sending x-api-key instead of api-key as header for azure hosted anthropic service

Description

Sending x-api-key instead of api-key as header for azure hosted anthropic service

C:/continue/packages/openai-adapters/src/apis/AnthropicUtils.ts
 const authHeaderName = isAzure && apiBase?.includes("cognitiveservices.azure.com")  ? "api-key"  : "x-api-key"; 

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [yes] I've read the contributing guide

  • [yes] The relevant docs, if any, have been updated or created

  • [yes] The relevant tests, if any, have been updated or created

Screen recording or screenshot

image

Tests

compiled the plugin and ran the changes using android studio


Summary by cubic

Send x-api-key by default for Azure-hosted Anthropic; use api-key only when apiBase contains cognitiveservices.azure.com (case-insensitive) to prevent auth failures on newer Azure deployments.

  • Bug Fixes
    • Case-insensitive domain check via apiBase?.toLowerCase().includes("cognitiveservices.azure.com") to choose between api-key and x-api-key.

Written for commit 9178f87. Summary will update on new commits.

@sresam89 sresam89 requested a review from a team as a code owner March 16, 2026 21:00
@sresam89 sresam89 requested review from sestinj and removed request for a team March 16, 2026 21:00
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 16, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/openai-adapters/src/apis/AnthropicUtils.ts">

<violation number="1" location="packages/openai-adapters/src/apis/AnthropicUtils.ts:82">
P2: Case-sensitive `apiBase.includes` check can cause Azure Cognitive Services URLs with mixed-case hostnames to fall back to `x-api-key`, despite `isAzure` being true, leading to incorrect auth header selection.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@sresam89
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

sresam89 and others added 2 commits March 17, 2026 08:15
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@sresam89 sresam89 force-pushed the fix/authHeaderName branch from d70661c to 9178f87 Compare March 17, 2026 13:17
@sresam89
Copy link
Author

sresam89 commented Mar 18, 2026

@sestinj awaiting your inputs

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sresam89 is there a more deterministic way to check if it's an anthropic endpoint? Right now anything not cognitive... will now do x-api-key, which might break other azure endpoints. Any way to specifically set x-api-key if anthropic?

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Mar 19, 2026
@sresam89
Copy link
Author

sresam89 commented Mar 20, 2026

@sresam89 is there a more deterministic way to check if it's an anthropic endpoint? Right now anything not cognitive... will now do x-api-key, which might break other azure endpoints. Any way to specifically set x-api-key if anthropic?

this change is focused only on anthropic end points, when the provider selection is anthropic, does not affect other providers, to the extent of my testing knowledge
The cognitive check was to provide backward compatibility since it was the only publicly documented anthropic endpoint still accepting api-key instead of x-api-key header, newer endpoints (self hosted or anthropic supported) are likely supporting/accepting only x-api-key over api-key header.
open to change it otherwise, with findings other contributors have

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes sense, I somehow missed that this is within AnthropicUtils.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 21, 2026
@sresam89
Copy link
Author

@sestinj awaiting for your review

@sresam89
Copy link
Author

Ah that makes sense, I somehow missed that this is within AnthropicUtils.

Thanks for your approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants