feat(plugin): add Microsoft Foundry as a built-in auth provider#28073
Open
pandma wants to merge 2 commits into
Open
feat(plugin): add Microsoft Foundry as a built-in auth provider#28073pandma wants to merge 2 commits into
pandma wants to merge 2 commits into
Conversation
Foundry deployments live behind project-scoped URLs of the form
https://<resource>.services.ai.azure.com/api/projects/<project>/openai/v1
and accept either `Authorization: Bearer <key>` or `api-key: <key>`. They are
not present in the models.dev catalog because deployments are user-defined.
This change adds a FoundryAuthPlugin that:
* Surfaces "foundry" as a selectable provider in `/login`, prompting for
resource hostname, project name and a comma-separated list of deployment
names. The credential is stored under the `foundry` provider id; the user
then references it from their own `opencode.json` provider entry (the
JSDoc shows the minimal config).
* Adds a `chat.params` hook that, when the active model's providerID is
`foundry`, strips `reasoningEffort`, `reasoningSummary`, `textVerbosity`,
`include` and `promptCacheKey`, and clears `maxOutputTokens`. Foundry's
OpenAI-compatible endpoint rejects those params for gpt-5.x deployments
(and the openai-compatible SDK emits `max_tokens` instead of the required
`max_completion_tokens`, with no rename hook available).
Tested end-to-end against a real Foundry project (gpt-5.5 deployment): the
provider loads, `/login` shows the new flow, and a chat completes with the
hook silently dropping the unsupported params.
Refs: anomalyco#14879
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #14879
Type of change
What does this PR do?
It adds Microsoft Foundry as a provider option in
/loginand a smallchat.paramshook so Foundry gpt-5.x deployments don't fail on every request.A note on the CONTRIBUTING rule "new providers should go to models.dev first": Foundry doesn't fit that model. A Foundry "provider" is a user's own Azure resource + project + deployments. There's no fixed model list to put in the catalog — every user has different deployment names. So the catalog can't represent it; the right place is a plugin.
Two things were needed:
The
/loginflow asks the user for their resource hostname, project name and the deployment names they have. The credential is saved under thefoundryprovider id and the user then references it from their ownopencode.json(the JSDoc infoundry.tshas the minimal shape).Foundry's OpenAI-compatible endpoint on gpt-5.x returns 400 for
reasoningSummary,reasoningEffort,textVerbosity, and won't acceptmax_tokens(wantsmax_completion_tokensinstead). The openai-compatible SDK emits all of those. So whenmodel.providerID === "foundry"the hook strips them fromoutput.optionsand clearsmaxOutputTokens. Other providers aren't touched.How did you verify your code works?
Tested against a real Foundry project end to end:
bun run typecheck— clean (also caught a missingclient.auth.getI had to remove before re-running)bun run dev— boots and logsname=FoundryAuthPlugin loading internal pluginbun run dev auth list— shows registered providersopencode.jsonpointing athttps://<resource>.services.ai.azure.com/api/projects/<project>/openai/v1with one modelgpt-5.5, then ran:pong. Before the hook this errored withUnknown parameter: 'reasoningSummary'.Curl probes (before writing the hook, to confirm what Foundry actually rejects):
reasoningSummary/reasoningEffort/textVerbosityUnknown parametermax_tokensuse 'max_completion_tokens'temperature: 0.5Only the default (1) value is supportedScreenshots / recordings
No UI change. The only user-visible surface is the
/loginflow — three text prompts in the same style as the existing Azure plugin (resource hostname, project name, deployments comma-separated).Checklist
Notes
This lands the OpenAI-compatible path on Foundry, which is the common case (gpt-4o-mini, gpt-5.5, etc.). The original reporter on #14879 was hitting
/anthropic/v1/messageson Foundry — Claude on Foundry uses a different SDK (@ai-sdk/anthropic) and URL pattern. Happy to do that as a follow-up if this lands.