-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(ai): refresh customProvider and createProviderRegistry to support file and skill upload abstractions
#14284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
felixarntz
merged 7 commits into
main
from
fa/refresh-provider-registry-and-custom-provider
Apr 10, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bafd839
add support for files, skills, and missing video model to customProvi…
felixarntz d4037c8
add examples
felixarntz dde1d78
use createProviderRegistry instead of custom map in uploadFile E2E ex…
felixarntz 8843c1a
update docs
felixarntz 0c07931
ensure type safety with files and skills on customProvider
felixarntz 59d4b6e
changeset
felixarntz fe5dab1
Merge branch 'main' into fa/refresh-provider-registry-and-custom-prov…
felixarntz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ai": patch | ||
| --- | ||
|
|
||
| feat(ai): refresh `customProvider` and `createProviderRegistry` to support file and skill upload abstractions |
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
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
24 changes: 24 additions & 0 deletions
24
examples/ai-functions/src/registry/generate-video-custom-provider.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { fal } from '@ai-sdk/fal'; | ||
| import { customProvider, experimental_generateVideo } from 'ai'; | ||
| import { presentVideos } from '../lib/present-video'; | ||
| import { run } from '../lib/run'; | ||
| import { withSpinner } from '../lib/spinner'; | ||
|
|
||
| const myProvider = customProvider({ | ||
| videoModels: { | ||
| 'luma-ray-2': fal.video('luma-dream-machine/ray-2'), | ||
| }, | ||
| }); | ||
|
|
||
| run(async () => { | ||
| const { videos } = await withSpinner('Generating video...', () => | ||
| experimental_generateVideo({ | ||
| model: myProvider.videoModel('luma-ray-2'), | ||
| prompt: 'A cat walking on a beach at sunset', | ||
| aspectRatio: '16:9', | ||
| duration: 5, | ||
| }), | ||
| ); | ||
|
|
||
| await presentVideos(videos); | ||
| }); |
20 changes: 20 additions & 0 deletions
20
examples/ai-functions/src/registry/generate-video-registry.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { fal } from '@ai-sdk/fal'; | ||
| import { createProviderRegistry, experimental_generateVideo } from 'ai'; | ||
| import { presentVideos } from '../lib/present-video'; | ||
| import { run } from '../lib/run'; | ||
| import { withSpinner } from '../lib/spinner'; | ||
|
|
||
| const registry = createProviderRegistry({ fal }); | ||
|
|
||
| run(async () => { | ||
| const { videos } = await withSpinner('Generating video...', () => | ||
| experimental_generateVideo({ | ||
| model: registry.videoModel('fal:luma-dream-machine/ray-2'), | ||
| prompt: 'A cat walking on a beach at sunset', | ||
| aspectRatio: '16:9', | ||
| duration: 5, | ||
| }), | ||
| ); | ||
|
|
||
| await presentVideos(videos); | ||
| }); |
38 changes: 38 additions & 0 deletions
38
examples/ai-functions/src/registry/upload-file-custom-provider.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { openai } from '@ai-sdk/openai'; | ||
| import { customProvider, generateText, uploadFile } from 'ai'; | ||
| import fs from 'node:fs'; | ||
| import { run } from '../lib/run'; | ||
|
|
||
| const myProvider = customProvider({ | ||
| languageModels: { | ||
| 'gpt-4o-mini': openai.responses('gpt-4o-mini'), | ||
| }, | ||
| files: openai.files(), | ||
| }); | ||
|
|
||
| run(async () => { | ||
| const { providerReference, mediaType, filename } = await uploadFile({ | ||
| api: myProvider.files(), | ||
| data: fs.readFileSync('./data/comic-cat.png'), | ||
| filename: 'comic-cat.png', | ||
| }); | ||
|
|
||
| console.log('Provider reference:', providerReference); | ||
| console.log('Media type:', mediaType); | ||
| console.log('Filename:', filename); | ||
|
|
||
| const result = await generateText({ | ||
| model: myProvider.languageModel('gpt-4o-mini'), | ||
| messages: [ | ||
| { | ||
| role: 'user', | ||
| content: [ | ||
| { type: 'text', text: 'Describe what you see in this image.' }, | ||
| { type: 'image', image: providerReference }, | ||
| ], | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| console.log(result.text); | ||
| }); |
43 changes: 43 additions & 0 deletions
43
examples/ai-functions/src/registry/upload-file-registry.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { openai } from '@ai-sdk/openai'; | ||
| import { | ||
| createProviderRegistry, | ||
| customProvider, | ||
| generateText, | ||
| uploadFile, | ||
| } from 'ai'; | ||
| import fs from 'node:fs'; | ||
| import { run } from '../lib/run'; | ||
|
|
||
| const registry = createProviderRegistry({ | ||
| openai: customProvider({ | ||
| languageModels: { 'gpt-4o-mini': openai.responses('gpt-4o-mini') }, | ||
| files: openai.files(), | ||
| }), | ||
| }); | ||
|
|
||
| run(async () => { | ||
| const { providerReference, mediaType, filename } = await uploadFile({ | ||
| api: registry.files('openai'), | ||
| data: fs.readFileSync('./data/comic-cat.png'), | ||
| filename: 'comic-cat.png', | ||
| }); | ||
|
|
||
| console.log('Provider reference:', providerReference); | ||
| console.log('Media type:', mediaType); | ||
| console.log('Filename:', filename); | ||
|
|
||
| const result = await generateText({ | ||
| model: registry.languageModel('openai:gpt-4o-mini'), | ||
| messages: [ | ||
| { | ||
| role: 'user', | ||
| content: [ | ||
| { type: 'text', text: 'Describe what you see in this image.' }, | ||
| { type: 'image', image: providerReference }, | ||
| ], | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| console.log(result.text); | ||
| }); |
39 changes: 39 additions & 0 deletions
39
examples/ai-functions/src/registry/upload-skill-custom-provider.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { anthropic } from '@ai-sdk/anthropic'; | ||
| import { customProvider, uploadSkill } from 'ai'; | ||
| import { readFileSync } from 'fs'; | ||
| import { deleteUploadedAnthropicSkill } from '../lib/delete-uploaded-skill'; | ||
| import { run } from '../lib/run'; | ||
|
|
||
| const myProvider = customProvider({ | ||
| languageModels: { | ||
| sonnet: anthropic('claude-sonnet-4-5'), | ||
| }, | ||
| skills: anthropic.skills(), | ||
| }); | ||
|
|
||
| run(async () => { | ||
| const { providerReference, displayTitle, name, description, latestVersion } = | ||
| await uploadSkill({ | ||
| api: myProvider.skills(), | ||
| files: [ | ||
| { | ||
| path: 'island-rescue/SKILL.md', | ||
| content: readFileSync('data/island-rescue/SKILL.md'), | ||
| }, | ||
| ], | ||
| displayTitle: 'Island Rescue Test', | ||
| }); | ||
|
|
||
| console.log('Provider reference:', providerReference); | ||
| console.log('Display title:', displayTitle); | ||
| console.log('Name:', name); | ||
| console.log('Description:', description); | ||
| console.log('Latest version:', latestVersion); | ||
|
|
||
| try { | ||
| await deleteUploadedAnthropicSkill({ providerReference }); | ||
| console.log('Deleted uploaded Anthropic skill.'); | ||
| } catch (error) { | ||
| console.error('Failed to delete uploaded Anthropic skill:', error); | ||
| } | ||
| }); |
32 changes: 32 additions & 0 deletions
32
examples/ai-functions/src/registry/upload-skill-registry.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { uploadSkill } from 'ai'; | ||
| import { readFileSync } from 'fs'; | ||
| import { deleteUploadedAnthropicSkill } from '../lib/delete-uploaded-skill'; | ||
| import { run } from '../lib/run'; | ||
| import { registry } from './setup-registry'; | ||
|
|
||
| run(async () => { | ||
| const { providerReference, displayTitle, name, description, latestVersion } = | ||
| await uploadSkill({ | ||
| api: registry.skills('anthropic'), | ||
| files: [ | ||
| { | ||
| path: 'island-rescue/SKILL.md', | ||
| content: readFileSync('data/island-rescue/SKILL.md'), | ||
| }, | ||
| ], | ||
| displayTitle: 'Island Rescue Test', | ||
| }); | ||
|
|
||
| console.log('Provider reference:', providerReference); | ||
| console.log('Display title:', displayTitle); | ||
| console.log('Name:', name); | ||
| console.log('Description:', description); | ||
| console.log('Latest version:', latestVersion); | ||
|
|
||
| try { | ||
| await deleteUploadedAnthropicSkill({ providerReference }); | ||
| console.log('Deleted uploaded Anthropic skill.'); | ||
| } catch (error) { | ||
| console.error('Failed to delete uploaded Anthropic skill:', error); | ||
| } | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idea for future work: what if we had a files composite that can upload to several providers at once?