refactor(ai): simplify provider boundaries - #43491
Closed
kitlangton wants to merge 6 commits into
Closed
Conversation
kitlangton
force-pushed
the
ai-doc-cleanup
branch
from
August 19, 2026 18:18
b3bf00f to
f498cf2
Compare
This was referenced Aug 19, 2026
Contributor
Author
|
Split into three focused PRs:
Closing this combined PR in favor of those independently reviewable units. |
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.
What
packages/aidesign/status/call-site documents and make the README, tutorial, and contributor guide describe the current route-based API.LanguageModel<Options>supplies type safety without repeating a provider namespace at runtime.model(modelID, settings)boundary withmodel({ id, settings, credential, defaults }).Before / After
Before
Core had to know that Anthropic OAuth used
authToken, Vertex OAuth usedaccessToken, and most other providers usedapiKey. Legacy Anthropic OAuth could consequently lose its OAuth identity and be sent throughx-api-key.After
The selected model still carries the provider-specific option type. At runtime one selected route decodes one flat option record. Native provider packages receive a neutral
key | oauthcredential and decide whether it becomes bearer auth,x-api-key,x-goog-api-key, Azureapi-key, or another provider-owned scheme.How
packages/ai/src/schema/options.tsmakes canonical request options a flat JSON record while retaining theLanguageModel<Options>phantom type and deep precedence merge.request.providerOptionsdirectly. Namespaced provider metadata remains unchanged for durable replay and multi-layer provenance.packages/ai/src/provider-package.tsdefines the structured package input, neutral credential algebra, and shared route-default projection.packages/core/src/model-resolver.tspasses credentials without package-name switches.packages/core/src/aisdk-native.tsmaps legacy OpenAI, Anthropic, OpenAI-compatible, Azure, Google, Vertex, Bedrock, OpenRouter, and xAI descriptors into the native package contract.packages/core/src/aisdk.tsre-namespaces flat canonical request options only when calling the legacy Vercel AI SDK; message-part provider metadata remains namespaced.Scope
key | oauthmodels credentials selected by OpenCode integrations. AWS SigV4 credentials, service-account configuration, and ambient cloud credential chains remain provider settings.HttpApisurface changes.Testing
bun typecheckinpackages/aibun run buildinpackages/aibun typecheckinpackages/coregit diff --checkThe full AI suite reports 515 passed, 28 skipped, and 7 unrelated existing failures:
/openai/v1/v1/chat/completionsinstead of/openai/v1/chat/completions.usage.includebody field.content: nulland omit explicitundefinedcompatibility fields, while current lowering emitscontent: ""with those fields.Flow