feat(ai): add support for uploading provider skills using the provider references abstraction#12880
feat(ai): add support for uploading provider skills using the provider references abstraction#12880felixarntz merged 35 commits intomainfrom
Conversation
Add SkillsManagerV1 interface to @ai-sdk/provider with create, list, retrieve, update, and delete operations. Implement for both OpenAI and Anthropic providers with file upload support via multipart form data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OpenAI skill responses return stale name/description after updates. Use the version list endpoint (GET /skills/{id}/versions?order=desc&limit=1) to fetch the latest version metadata for create and retrieve operations.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Switch from version list to GET /skills/{id}/versions/{version} using latest_version from the skill response. Enriches create, retrieve, and update with accurate name/description from the version object.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OpenAI's version list and retrieve endpoints are non-functional (list returns empty data, retrieve returns 404 for all versions). Confirmed via real API testing. Only update can enrich using the version CREATE response metadata. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit 545abdd.
Normalize source to user/provider across spec and providers, re-capture Anthropic/OpenAI fixtures from real APIs, add explanatory comments for non-obvious code paths, and fix OpenAI update to promote default_version via POST. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…external API surface
| /** | ||
| * The content of the file, either as a base64 string or binary data. | ||
| */ | ||
| content: string | Uint8Array; |
There was a problem hiding this comment.
For now, this is still using base64 for strings, in alignment with existing types.
However, per the discussion in #12855, this may not be as suitable here, given the content is often Markdown files. A counter-argument would be that skills can still contain binary data, or the entire skill could be a ZIP and no direct Markdown files at all.
But that could still be passed via Uint8Array then. Something to think about further.
There was a problem hiding this comment.
Update: I would suggest, we leave it as is for now, mostly for consistency with present expectations. However, we should probably revise how file parts are being sent anyway: Breaking down the existing file type into distinct file-data, file-url, and file-reference types would clarify the API surface and reduce complexity of having to figure out what the overloaded data field actually contains. This would then also allow us to add e.g. file-text (name TBD), which could be used to pass text file contents in plain text instead of base64-encoded.
I think we should make this change as part of v7, which will then alleviate the concern about base64 vs plain text for skills - we'd allow either.
cc @lgrammel
| /** | ||
| * Optional human-readable title for the uploaded skill. | ||
| */ | ||
| displayTitle?: string; |
There was a problem hiding this comment.
is this needed in the result if we have it as part of the params?
There was a problem hiding this comment.
I think it's good to have data like this in the result as it allows verifying the actual display name applied. Providers may do some minor sanitization, or they may add a default display name if none is provided.
Additionally, I think it makes sense to return comprehensive information about the created entity, so you don't have to patch this together yourself if you want to further process or store it.
lgrammel
left a comment
There was a problem hiding this comment.
Needs to be added to our documentation
|
🚀 Published in:
|
…r references abstraction (#12880) uploaded assets to a provider in a container that supports multi-provider references. In #12995, this was implemented for uploading files (e.g. large media) to a provider for referencing it in inference calls. This PR uses that same approach for uploading skills to a provider with programmatic tool calling. This is currently supported by Anthropic and OpenAI. - Introduces a new `SkillsV4` specification in `@ai-sdk/provider` for uploading remote skills across providers - Adds new core function `uploadSkill` in the `ai` package - Implements `SkillsV4` for both `@ai-sdk/openai` and `@ai-sdk/anthropic`, including provider-specific API handling - Includes comprehensive unit tests for all new code and example scripts demonstrating basic CRUD and skill-referenced inference for both providers Run the new examples included in the PR. - [x] Tests have been added / updated (for bug fixes / features) - [ ] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review) N/A Fixes #12855 Related: #12995 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…Skill` as shorthand (#14242) ## Background `uploadFile` and `uploadSkill` required callers to pass the specific sub-interface (`FilesV4` / `SkillsV4`) directly. Since `ProviderV4` already exposes optional `files()` and `skills()` methods returning those interfaces, it's unnecessarily verbose to call `provider.files()` manually before passing it in. It still makes sense as API primitive, but we can make it easier. ## Summary Both `uploadFile` and `uploadSkill` now accept `ProviderV4` as the `api` argument in addition to `FilesV4` / `SkillsV4` respectively. When a provider instance is passed, the SDK automatically resolves the appropriate sub-interface by calling `.files()` or `.skills()`. If the provider doesn't expose the required method, a clear error is thrown. Also adds a general function doc for `uploadSkill` that was missing from #12880. Also renames `SkillsV4`'s `upload` method to `uploadSkill`, for consistency and clarity - this was an oversight in the original PR. ## Manual Verification You can run the new examples for verify the shorthand works. ## Checklist - [x] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review) ## Future Work N/A ## Related Issues Follow up to #12995 and #12855
Background
#12995 introduced a new concept of provider references for managing uploaded assets to a provider in a container that supports multi-provider references. In #12995, this was implemented for uploading files (e.g. large media) to a provider for referencing it in inference calls.
This PR uses that same approach for uploading skills to a provider with programmatic tool calling. This is currently supported by Anthropic and OpenAI.
Summary
SkillsV4specification in@ai-sdk/providerfor uploading remote skills across providersuploadSkillin theaipackageSkillsV4for both@ai-sdk/openaiand@ai-sdk/anthropic, including provider-specific API handlingManual Verification
Run the new examples included in the PR.
Checklist
pnpm changesetin the project root)Future Work
N/A
Related Issues
Fixes #12855
Related: #12995