├── .changeset
├── README.md
├── afraid-trains-shout.md
├── big-monkeys-breathe.md
├── breezy-mayflies-promise.md
├── calm-emus-roll.md
├── chilled-llamas-sin.md
├── clean-bats-applaud.md
├── clean-squids-marry.md
├── clever-horses-love.md
├── clever-pigs-sin.md
├── cold-ducks-change.md
├── config.json
├── cuddly-kings-give.md
├── cuddly-snails-give.md
├── curvy-pets-fry.md
├── curvy-rabbits-run.md
├── dull-books-pull.md
├── dull-zoos-suffer.md
├── early-needles-speak.md
├── eight-donkeys-battle.md
├── few-apples-glow.md
├── flat-wolves-lick.md
├── friendly-ads-care.md
├── friendly-berries-refuse.md
├── giant-goats-fetch.md
├── good-dots-hear.md
├── gorgeous-guests-rescue.md
├── gorgeous-otters-sniff.md
├── gorgeous-pumas-sparkle.md
├── green-fans-draw.md
├── green-geckos-argue.md
├── happy-guests-chew.md
├── healthy-squids-hear.md
├── honest-sheep-divide.md
├── hot-sheep-pump.md
├── kind-peaches-begin.md
├── late-fishes-press.md
├── lazy-jobs-sell.md
├── light-phones-develop.md
├── little-goats-sit.md
├── lovely-hairs-help.md
├── lucky-rings-behave.md
├── modern-suns-give.md
├── moody-kiwis-jog.md
├── moody-pens-sort.md
├── new-houses-perform.md
├── new-peaches-peel.md
├── nice-lobsters-learn.md
├── nine-experts-play.md
├── olive-pets-remember.md
├── orange-cameras-serve.md
├── perfect-trees-wait.md
├── plenty-buses-pump.md
├── poor-ants-prove.md
├── poor-beds-reflect.md
├── poor-melons-camp.md
├── poor-needles-double.md
├── pre.json
├── pretty-lemons-enjoy.md
├── proud-yaks-taste.md
├── quiet-beans-poke.md
├── rare-singers-greet.md
├── shaggy-humans-agree.md
├── shiny-numbers-tie.md
├── shy-ties-lie.md
├── silent-walls-bow.md
├── sixty-keys-rhyme.md
├── slimy-zoos-double.md
├── small-jars-yawn.md
├── smart-pumas-flow.md
├── soft-geckos-rescue.md
├── spotty-wombats-pay.md
├── stale-kings-move.md
├── swift-kids-jam.md
├── tasty-dots-burn.md
├── tasty-waves-hug.md
├── thick-foxes-judge.md
├── three-lamps-cheat.md
├── tiny-points-grin.md
├── tough-geese-applaud.md
├── tough-trees-rhyme.md
├── unlucky-hats-explain.md
├── warm-insects-smoke.md
├── warm-nails-itch.md
├── wise-geese-rule.md
├── wise-wasps-work.md
└── yellow-books-develop.md
├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE
│ ├── 1.bug_report.yml
│ ├── 2.feature_request.yml
│ └── config.yml
├── SECURITY.md
├── dependabot.yml
├── scripts
│ └── cleanup-examples-changesets.mjs
└── workflows
│ ├── ci.yml
│ ├── quality.yml
│ ├── release-snapshot.yml
│ └── release.yml
├── .gitignore
├── .kodiak.toml
├── .npmrc
├── .prettierignore
├── .vscode
└── settings.json
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── assets
└── hero.gif
├── content
├── docs
│ ├── 01-introduction
│ │ └── index.mdx
│ ├── 02-foundations
│ │ ├── 01-overview.mdx
│ │ ├── 02-providers-and-models.mdx
│ │ ├── 03-prompts.mdx
│ │ ├── 04-tools.mdx
│ │ ├── 05-streaming.mdx
│ │ └── index.mdx
│ ├── 02-getting-started
│ │ ├── 01-navigating-the-library.mdx
│ │ ├── 02-nextjs-app-router.mdx
│ │ ├── 03-nextjs-pages-router.mdx
│ │ ├── 04-svelte.mdx
│ │ ├── 05-nuxt.mdx
│ │ ├── 06-nodejs.mdx
│ │ └── index.mdx
│ ├── 02-guides
│ │ ├── 01-rag-chatbot.mdx
│ │ ├── 02-multi-modal-chatbot.mdx
│ │ ├── 03-llama-3_1.mdx
│ │ ├── 04-o1.mdx
│ │ ├── 05-computer-use.mdx
│ │ ├── 06-natural-language-postgres.mdx
│ │ └── index.mdx
│ ├── 03-ai-sdk-core
│ │ ├── 01-overview.mdx
│ │ ├── 05-generating-text.mdx
│ │ ├── 10-generating-structured-data.mdx
│ │ ├── 15-tools-and-tool-calling.mdx
│ │ ├── 17-agents.mdx
│ │ ├── 20-prompt-engineering.mdx
│ │ ├── 25-settings.mdx
│ │ ├── 30-embeddings.mdx
│ │ ├── 40-provider-management.mdx
│ │ ├── 45-middleware.mdx
│ │ ├── 50-error-handling.mdx
│ │ ├── 55-testing.mdx
│ │ ├── 60-telemetry.mdx
│ │ └── index.mdx
│ ├── 04-ai-sdk-ui
│ │ ├── 01-overview.mdx
│ │ ├── 02-chatbot.mdx
│ │ ├── 03-chatbot-with-tool-calling.mdx
│ │ ├── 04-generative-user-interfaces.mdx
│ │ ├── 05-completion.mdx
│ │ ├── 08-object-generation.mdx
│ │ ├── 10-openai-assistants.mdx
│ │ ├── 15-storing-messages.mdx
│ │ ├── 20-streaming-data.mdx
│ │ ├── 21-error-handling.mdx
│ │ ├── 50-stream-protocol.mdx
│ │ └── index.mdx
│ ├── 05-ai-sdk-rsc
│ │ ├── 01-overview.mdx
│ │ ├── 02-streaming-react-components.mdx
│ │ ├── 03-generative-ui-state.mdx
│ │ ├── 03-saving-and-restoring-states.mdx
│ │ ├── 04-multistep-interfaces.mdx
│ │ ├── 05-streaming-values.mdx
│ │ ├── 06-loading-state.mdx
│ │ ├── 08-error-handling.mdx
│ │ ├── 09-authentication.mdx
│ │ ├── 10-migrating-to-ui.mdx
│ │ └── index.mdx
│ ├── 06-advanced
│ │ ├── 01-prompt-engineering.mdx
│ │ ├── 02-stopping-streams.mdx
│ │ ├── 03-backpressure.mdx
│ │ ├── 04-caching.mdx
│ │ ├── 05-multiple-streamables.mdx
│ │ ├── 06-rate-limiting.mdx
│ │ ├── 07-rendering-ui-with-language-models.mdx
│ │ ├── 08-model-as-router.mdx
│ │ ├── 09-multistep-interfaces.mdx
│ │ ├── 09-sequential-generations.mdx
│ │ ├── 10-vercel-deployment-guide.mdx
│ │ └── index.mdx
│ ├── 07-reference
│ │ ├── 01-ai-sdk-core
│ │ │ ├── 01-generate-text.mdx
│ │ │ ├── 02-stream-text.mdx
│ │ │ ├── 03-generate-object.mdx
│ │ │ ├── 04-stream-object.mdx
│ │ │ ├── 05-embed.mdx
│ │ │ ├── 06-embed-many.mdx
│ │ │ ├── 20-tool.mdx
│ │ │ ├── 25-json-schema.mdx
│ │ │ ├── 30-core-message.mdx
│ │ │ ├── 40-provider-registry.mdx
│ │ │ ├── 42-custom-provider.mdx
│ │ │ ├── 50-cosine-similarity.mdx
│ │ │ ├── 60-wrap-language-model.mdx
│ │ │ ├── 65-language-model-v1-middleware.mdx
│ │ │ └── index.mdx
│ │ ├── 02-ai-sdk-ui
│ │ │ ├── 01-use-chat.mdx
│ │ │ ├── 02-use-completion.mdx
│ │ │ ├── 03-use-object.mdx
│ │ │ ├── 20-use-assistant.mdx
│ │ │ ├── 21-assistant-response.mdx
│ │ │ ├── 31-convert-to-core-messages.mdx
│ │ │ ├── 40-stream-data.mdx
│ │ │ └── index.mdx
│ │ ├── 03-ai-sdk-rsc
│ │ │ ├── 01-stream-ui.mdx
│ │ │ ├── 02-create-ai.mdx
│ │ │ ├── 03-create-streamable-ui.mdx
│ │ │ ├── 04-create-streamable-value.mdx
│ │ │ ├── 05-read-streamable-value.mdx
│ │ │ ├── 06-get-ai-state.mdx
│ │ │ ├── 07-get-mutable-ai-state.mdx
│ │ │ ├── 08-use-ai-state.mdx
│ │ │ ├── 09-use-actions.mdx
│ │ │ ├── 10-use-ui-state.mdx
│ │ │ ├── 11-use-streamable-value.mdx
│ │ │ ├── 20-render.mdx
│ │ │ └── index.mdx
│ │ ├── 04-stream-helpers
│ │ │ ├── 01-ai-stream.mdx
│ │ │ ├── 02-streaming-text-response.mdx
│ │ │ ├── 05-stream-to-response.mdx
│ │ │ ├── 07-openai-stream.mdx
│ │ │ ├── 08-anthropic-stream.mdx
│ │ │ ├── 09-aws-bedrock-stream.mdx
│ │ │ ├── 10-aws-bedrock-anthropic-stream.mdx
│ │ │ ├── 10-aws-bedrock-messages-stream.mdx
│ │ │ ├── 11-aws-bedrock-cohere-stream.mdx
│ │ │ ├── 12-aws-bedrock-llama-2-stream.mdx
│ │ │ ├── 13-cohere-stream.mdx
│ │ │ ├── 14-google-generative-ai-stream.mdx
│ │ │ ├── 15-hugging-face-stream.mdx
│ │ │ ├── 16-langchain-adapter.mdx
│ │ │ ├── 16-langchain-stream.mdx
│ │ │ ├── 16-llamaindex-adapter.mdx
│ │ │ ├── 17-mistral-stream.mdx
│ │ │ ├── 18-replicate-stream.mdx
│ │ │ ├── 19-inkeep-stream.mdx
│ │ │ ├── 50-generate-id.mdx
│ │ │ └── index.mdx
│ │ ├── 05-ai-sdk-errors
│ │ │ ├── ai-api-call-error.mdx
│ │ │ ├── ai-download-error.mdx
│ │ │ ├── ai-empty-response-body-error.mdx
│ │ │ ├── ai-invalid-argument-error.mdx
│ │ │ ├── ai-invalid-data-content-error.mdx
│ │ │ ├── ai-invalid-data-content.mdx
│ │ │ ├── ai-invalid-message-role-error.mdx
│ │ │ ├── ai-invalid-prompt-error.mdx
│ │ │ ├── ai-invalid-response-data-error.mdx
│ │ │ ├── ai-invalid-tool-arguments-error.mdx
│ │ │ ├── ai-json-parse-error.mdx
│ │ │ ├── ai-load-api-key-error.mdx
│ │ │ ├── ai-load-setting-error.mdx
│ │ │ ├── ai-message-conversion-error.mdx
│ │ │ ├── ai-no-content-generated-error.mdx
│ │ │ ├── ai-no-object-generated-error.mdx
│ │ │ ├── ai-no-such-model-error.mdx
│ │ │ ├── ai-no-such-provider-error.mdx
│ │ │ ├── ai-no-such-tool-error.mdx
│ │ │ ├── ai-retry-error.mdx
│ │ │ ├── ai-too-many-embedding-values-for-call-error.mdx
│ │ │ ├── ai-type-validation-error.mdx
│ │ │ ├── ai-unsupported-functionality-error.mdx
│ │ │ └── index.mdx
│ │ └── index.mdx
│ └── 08-troubleshooting
│ │ ├── 01-migration-guide
│ │ ├── 01-migration-guide-4-0.mdx
│ │ ├── 22-migration-guide-3-4.mdx
│ │ ├── 23-migration-guide-3-3.mdx
│ │ ├── 24-migration-guide-3-2.mdx
│ │ ├── 25-migration-guide-3-1.mdx
│ │ └── index.mdx
│ │ ├── 03-common-issues
│ │ ├── 01-azure-stream-slow.mdx
│ │ ├── 02-client-side-function-calls-not-invoked.mdx
│ │ ├── 03-server-actions-in-client-components.mdx
│ │ ├── 04-strange-stream-output.mdx
│ │ ├── 05-streamable-ui-errors.mdx
│ │ ├── 06-streaming-not-working-on-vercel-pages-router.mdx
│ │ ├── 06-streaming-not-working-on-vercel.mdx
│ │ ├── 06-timeout-on-vercel.mdx
│ │ ├── 07-unclosed-streams.mdx
│ │ ├── 08-use-chat-failed-to-parse-stream.mdx
│ │ ├── 09-client-stream-error.mdx
│ │ ├── 10-use-chat-tools-no-response.mdx
│ │ ├── 20-nan-token-counts-openai-streaming.mdx
│ │ ├── 30-model-is-not-assignable-to-type.mdx
│ │ ├── 40-typescript-cannot-find-namespace-jsx.mdx
│ │ ├── 50-react-maximum-update-depth-exceeded.mdx
│ │ └── index.mdx
│ │ └── index.mdx
├── examples
│ ├── 01-next
│ │ ├── 01-basics
│ │ │ ├── 01-generating-text.mdx
│ │ │ ├── 02-streaming-text-generation.mdx
│ │ │ ├── 03-generating-object.mdx
│ │ │ ├── 04-streaming-object-generation.mdx
│ │ │ └── index.mdx
│ │ ├── 05-chat
│ │ │ ├── 01-generate-chat-completion.mdx
│ │ │ ├── 02-stream-chat-completion.mdx
│ │ │ ├── 10-use-chat-image-input.mdx
│ │ │ ├── 15-use-chat-custom-body.mdx
│ │ │ └── index.mdx
│ │ ├── 10-tools
│ │ │ ├── 01-call-tool.mdx
│ │ │ ├── 05-call-tools-in-parallel.mdx
│ │ │ ├── 10-render-interface-during-tool-call.mdx
│ │ │ └── index.mdx
│ │ ├── 11-state-management
│ │ │ ├── 01-save-messages.mdx
│ │ │ ├── 02-restore-messages.mdx
│ │ │ └── index.mdx
│ │ ├── 12-interface
│ │ │ ├── 01-route-components.mdx
│ │ │ └── index.mdx
│ │ ├── 15-assistants
│ │ │ ├── 01-stream-assistant-responses.mdx
│ │ │ ├── 05-stream-assistant-responses-with-tools.mdx
│ │ │ └── index.mdx
│ │ └── index.mdx
│ ├── 03-node
│ │ ├── 01-generating-text
│ │ │ ├── 01-generate-text.mdx
│ │ │ ├── 02-stream-text.mdx
│ │ │ ├── 03-generate-text-with-chat-prompt.mdx
│ │ │ ├── 04-stream-text-with-chat-prompt.mdx
│ │ │ ├── 05-generate-text-with-image-prompt.mdx
│ │ │ ├── 06-rag.mdx
│ │ │ └── index.mdx
│ │ ├── 02-generating-structured-data
│ │ │ ├── 01-generate-object.mdx
│ │ │ ├── 03-add-images-to-prompt.mdx
│ │ │ └── index.mdx
│ │ ├── 02-streaming-structured-data
│ │ │ ├── 01-stream-object.mdx
│ │ │ ├── 10-token-usage.mdx
│ │ │ ├── 12-object.mdx
│ │ │ └── index.mdx
│ │ ├── 03-tools
│ │ │ ├── 01-call-tool.mdx
│ │ │ ├── 02-call-tool-with-image-prompt.mdx
│ │ │ ├── 03-call-tools-in-parallel.mdx
│ │ │ ├── 05-call-tools-with-automatic-roundtrips.mdx
│ │ │ └── index.mdx
│ │ └── index.mdx
│ ├── 05-rsc
│ │ ├── 01-basics
│ │ │ ├── 01-generating-text.mdx
│ │ │ ├── 02-streaming-text-generation.mdx
│ │ │ ├── 03-generating-object.mdx
│ │ │ ├── 04-streaming-object-generation.mdx
│ │ │ └── index.mdx
│ │ ├── 02-chat
│ │ │ ├── 01-generate-chat-completion.mdx
│ │ │ ├── 02-stream-chat-completion.mdx
│ │ │ └── index.mdx
│ │ ├── 03-tools
│ │ │ ├── 01-call-tool.mdx
│ │ │ ├── 02-call-tools-in-parallel.mdx
│ │ │ ├── 03-render-interface-during-tool-call.mdx
│ │ │ └── index.mdx
│ │ ├── 04-state-management
│ │ │ ├── 01-ai-ui-states.mdx
│ │ │ ├── 02-save-and-restore-states.mdx
│ │ │ └── index.mdx
│ │ ├── 05-interface
│ │ │ ├── 01-route-components.mdx
│ │ │ ├── 02-stream-component-updates.mdx
│ │ │ ├── 03-token-usage.mdx
│ │ │ └── index.mdx
│ │ ├── 06-assistants
│ │ │ ├── 01-stream-assistant-responses.mdx
│ │ │ ├── 02-stream-assistant-responses-with-tools.mdx
│ │ │ └── index.mdx
│ │ └── index.mdx
│ ├── 15-api-servers
│ │ ├── 10-node-js-http-server.mdx
│ │ ├── 15-express.mdx
│ │ ├── 20-hono.mdx
│ │ ├── 30-fastify.mdx
│ │ ├── 40-nest.mdx
│ │ └── index.mdx
│ ├── 20-providers
│ │ ├── 10-intercepting-fetch-requests.mdx
│ │ └── index.mdx
│ └── index.mdx
└── providers
│ ├── 01-ai-sdk-providers
│ ├── 01-openai.mdx
│ ├── 02-azure.mdx
│ ├── 05-anthropic.mdx
│ ├── 08-amazon-bedrock.mdx
│ ├── 10-google-generative-ai.mdx
│ ├── 11-google-vertex.mdx
│ ├── 20-mistral.mdx
│ ├── 25-cohere.mdx
│ ├── 50-groq.mdx
│ └── index.mdx
│ ├── 02-openai-compatible-providers
│ ├── 05-xai.mdx
│ ├── 10-perplexity.mdx
│ ├── 20-fireworks.mdx
│ ├── 25-togetherai.mdx
│ ├── 30-lmstudio.mdx
│ ├── 40-baseten.mdx
│ └── index.mdx
│ ├── 03-community-providers
│ ├── 01-custom-providers.mdx
│ ├── 03-ollama.mdx
│ ├── 04-chrome-ai.mdx
│ ├── 05-anthropic-vertex-ai.mdx
│ ├── 08-friendliai.mdx
│ ├── 10-portkey.mdx
│ ├── 11-cloudflare-workers-ai.mdx
│ ├── 21-crosshatch.mdx
│ ├── 90-llama-cpp.mdx
│ └── index.mdx
│ ├── 04-adapters
│ ├── 01-langchain.mdx
│ ├── 02-llamaindex.mdx
│ └── index.mdx
│ └── 05-observability
│ └── index.mdx
├── examples
├── ai-core
│ ├── .env.example
│ ├── README.md
│ ├── data
│ │ ├── ai.pdf
│ │ ├── comic-cat.png
│ │ ├── error-message.txt
│ │ ├── galileo.mp3
│ │ └── screenshot-editor.png
│ ├── package.json
│ ├── src
│ │ ├── complex
│ │ │ ├── math-agent
│ │ │ │ ├── agent-required-tool-choice.ts
│ │ │ │ └── agent.ts
│ │ │ └── semantic-router
│ │ │ │ ├── main.ts
│ │ │ │ └── semantic-router.ts
│ │ ├── embed-many
│ │ │ ├── amazon-bedrock.ts
│ │ │ ├── azure.ts
│ │ │ ├── cohere.ts
│ │ │ ├── google-vertex.ts
│ │ │ ├── google.ts
│ │ │ ├── mistral.ts
│ │ │ ├── openai-cosine-similarity.ts
│ │ │ └── openai.ts
│ │ ├── embed
│ │ │ ├── amazon-bedrock.ts
│ │ │ ├── azure.ts
│ │ │ ├── cohere.ts
│ │ │ ├── google-vertex.ts
│ │ │ ├── google.ts
│ │ │ ├── mistral.ts
│ │ │ └── openai.ts
│ │ ├── generate-object
│ │ │ ├── amazon-bedrock.ts
│ │ │ ├── anthropic.ts
│ │ │ ├── azure.ts
│ │ │ ├── fireworks.ts
│ │ │ ├── google-enum.ts
│ │ │ ├── google-gemini-files.ts
│ │ │ ├── google-no-structured-output.ts
│ │ │ ├── google-pdf-url.ts
│ │ │ ├── google-vertex-tool.ts
│ │ │ ├── google-vertex.ts
│ │ │ ├── google.ts
│ │ │ ├── groq.ts
│ │ │ ├── mistral-json.ts
│ │ │ ├── mistral-tool.ts
│ │ │ ├── mistral.ts
│ │ │ ├── mock.ts
│ │ │ ├── openai-array.ts
│ │ │ ├── openai-date-parsing.ts
│ │ │ ├── openai-enum.ts
│ │ │ ├── openai-full-result.ts
│ │ │ ├── openai-json.ts
│ │ │ ├── openai-multimodal.ts
│ │ │ ├── openai-no-schema.ts
│ │ │ ├── openai-raw-json-schema.ts
│ │ │ ├── openai-request-body.ts
│ │ │ ├── openai-store-generation.ts
│ │ │ ├── openai-structured-outputs-name-description.ts
│ │ │ ├── openai-tool.ts
│ │ │ └── openai.ts
│ │ ├── generate-text
│ │ │ ├── amazon-bedrock-chatbot.ts
│ │ │ ├── amazon-bedrock-guardrails.ts
│ │ │ ├── amazon-bedrock-image-url.ts
│ │ │ ├── amazon-bedrock-image.ts
│ │ │ ├── amazon-bedrock-prefilled-assistant-message.ts
│ │ │ ├── amazon-bedrock-tool-call.ts
│ │ │ ├── amazon-bedrock-tool-choice.ts
│ │ │ ├── amazon-bedrock.ts
│ │ │ ├── anthropic-cache-control.ts
│ │ │ ├── anthropic-chatbot.ts
│ │ │ ├── anthropic-computer-use-bash.ts
│ │ │ ├── anthropic-computer-use-computer.ts
│ │ │ ├── anthropic-computer-use-editor-cache-control.ts
│ │ │ ├── anthropic-computer-use-editor.ts
│ │ │ ├── anthropic-custom-fetch.ts
│ │ │ ├── anthropic-full-result.ts
│ │ │ ├── anthropic-image-url.ts
│ │ │ ├── anthropic-image.ts
│ │ │ ├── anthropic-multi-step-continue.ts
│ │ │ ├── anthropic-pdf.ts
│ │ │ ├── anthropic-tool-call.ts
│ │ │ ├── anthropic-tool-choice.ts
│ │ │ ├── anthropic.ts
│ │ │ ├── azure-custom-fetch.ts
│ │ │ ├── azure.ts
│ │ │ ├── cohere-chatbot.ts
│ │ │ ├── cohere-tool-call.ts
│ │ │ ├── cohere.ts
│ │ │ ├── deepseek.ts
│ │ │ ├── google-audio.ts
│ │ │ ├── google-custom-fetch.ts
│ │ │ ├── google-image-url.ts
│ │ │ ├── google-image.ts
│ │ │ ├── google-multi-step.ts
│ │ │ ├── google-pdf.ts
│ │ │ ├── google-tool-call.ts
│ │ │ ├── google-tool-choice.ts
│ │ │ ├── google-vertex-grounding.ts
│ │ │ ├── google-vertex-image-base64.ts
│ │ │ ├── google-vertex-image-url.ts
│ │ │ ├── google-vertex-multi-step.ts
│ │ │ ├── google-vertex-pdf-url.ts
│ │ │ ├── google-vertex-pdf.ts
│ │ │ ├── google-vertex-safety.ts
│ │ │ ├── google-vertex-tool-call.ts
│ │ │ ├── google-vertex.ts
│ │ │ ├── google.ts
│ │ │ ├── groq.ts
│ │ │ ├── mistral-chatbot.ts
│ │ │ ├── mistral-custom-fetch.ts
│ │ │ ├── mistral-full-result.ts
│ │ │ ├── mistral-image-base64.ts
│ │ │ ├── mistral-image-url.ts
│ │ │ ├── mistral-multi-step-continue.ts
│ │ │ ├── mistral-tool-call.ts
│ │ │ ├── mistral-tool-choice.ts
│ │ │ ├── mistral.ts
│ │ │ ├── mock.ts
│ │ │ ├── openai-active-tools.ts
│ │ │ ├── openai-audio.ts
│ │ │ ├── openai-cached-prompt-tokens.ts
│ │ │ ├── openai-completion-chat.ts
│ │ │ ├── openai-completion.ts
│ │ │ ├── openai-custom-fetch.ts
│ │ │ ├── openai-custom-headers.ts
│ │ │ ├── openai-full-result.ts
│ │ │ ├── openai-image-base64.ts
│ │ │ ├── openai-image-url-download.ts
│ │ │ ├── openai-image-url.ts
│ │ │ ├── openai-image.ts
│ │ │ ├── openai-log-metadata-middleware.ts
│ │ │ ├── openai-logprobs.ts
│ │ │ ├── openai-multi-step-continue.ts
│ │ │ ├── openai-multi-step.ts
│ │ │ ├── openai-reasoning-model.ts
│ │ │ ├── openai-request-body.ts
│ │ │ ├── openai-store-generation.ts
│ │ │ ├── openai-system-message-a.ts
│ │ │ ├── openai-system-message-b.ts
│ │ │ ├── openai-timeout.ts
│ │ │ ├── openai-tool-call-raw-json-schema.ts
│ │ │ ├── openai-tool-call.ts
│ │ │ ├── openai-tool-choice.ts
│ │ │ ├── openai.ts
│ │ │ └── togetherai.ts
│ │ ├── middleware
│ │ │ ├── add-to-last-user-message.ts
│ │ │ ├── generate-text-cache-middleware.ts
│ │ │ ├── generate-text-log-middleware.ts
│ │ │ ├── get-last-user-message-text.ts
│ │ │ ├── stream-text-log-middleware.ts
│ │ │ ├── stream-text-rag-middleware.ts
│ │ │ ├── your-cache-middleware.ts
│ │ │ ├── your-guardrail-middleware.ts
│ │ │ ├── your-log-middleware.ts
│ │ │ └── your-rag-middleware.ts
│ │ ├── registry
│ │ │ ├── embed-openai.ts
│ │ │ ├── setup-registry.ts
│ │ │ ├── stream-text-anthropic.ts
│ │ │ ├── stream-text-groq.ts
│ │ │ └── stream-text-openai.ts
│ │ ├── stream-object
│ │ │ ├── amazon-bedrock.ts
│ │ │ ├── anthropic.ts
│ │ │ ├── azure.ts
│ │ │ ├── fireworks.ts
│ │ │ ├── google-vertex.ts
│ │ │ ├── google.ts
│ │ │ ├── groq.ts
│ │ │ ├── mistral-json.ts
│ │ │ ├── mistral-tool.ts
│ │ │ ├── mistral.ts
│ │ │ ├── mock.ts
│ │ │ ├── openai-array.ts
│ │ │ ├── openai-fullstream.ts
│ │ │ ├── openai-json.ts
│ │ │ ├── openai-no-schema.ts
│ │ │ ├── openai-object.ts
│ │ │ ├── openai-on-finish.ts
│ │ │ ├── openai-raw-json-schema.ts
│ │ │ ├── openai-request-body.ts
│ │ │ ├── openai-store-generation.ts
│ │ │ ├── openai-structured-outputs-name-description.ts
│ │ │ ├── openai-structured-outputs.ts
│ │ │ ├── openai-token-usage.ts
│ │ │ ├── openai-tool.ts
│ │ │ └── openai.ts
│ │ ├── stream-text
│ │ │ ├── amazon-bedrock-chatbot.ts
│ │ │ ├── amazon-bedrock-fullstream.ts
│ │ │ ├── amazon-bedrock-image.ts
│ │ │ ├── amazon-bedrock-multi-step-continue.ts
│ │ │ ├── amazon-bedrock-pdf.ts
│ │ │ ├── amazon-bedrock.ts
│ │ │ ├── anthropic-cache-control.ts
│ │ │ ├── anthropic-chatbot.ts
│ │ │ ├── anthropic-fullstream.ts
│ │ │ ├── anthropic-image.ts
│ │ │ ├── anthropic-multi-step-continue.ts
│ │ │ ├── anthropic-pdf.ts
│ │ │ ├── anthropic.ts
│ │ │ ├── azure-completion.ts
│ │ │ ├── azure-fullstream-logprobs.ts
│ │ │ ├── azure-fullstream.ts
│ │ │ ├── azure.ts
│ │ │ ├── baseten.ts
│ │ │ ├── cohere-chatbot.ts
│ │ │ ├── cohere-response.ts
│ │ │ ├── cohere-tool-call.ts
│ │ │ ├── cohere.ts
│ │ │ ├── fireworks.ts
│ │ │ ├── google-chatbot-with-tools.ts
│ │ │ ├── google-chatbot.ts
│ │ │ ├── google-fullstream.ts
│ │ │ ├── google-vertex-fullstream.ts
│ │ │ ├── google-vertex-grounding.ts
│ │ │ ├── google-vertex-pdf-url.ts
│ │ │ ├── google-vertex.ts
│ │ │ ├── google.ts
│ │ │ ├── groq.ts
│ │ │ ├── lmstudio.ts
│ │ │ ├── mistral-chatbot-with-tools.ts
│ │ │ ├── mistral-chatbot.ts
│ │ │ ├── mistral-fullstream.ts
│ │ │ ├── mistral-multi-step-continue.ts
│ │ │ ├── mistral.ts
│ │ │ ├── mock.ts
│ │ │ ├── openai-abort.ts
│ │ │ ├── openai-audio.ts
│ │ │ ├── openai-cached-prompt-tokens.ts
│ │ │ ├── openai-chatbot.ts
│ │ │ ├── openai-completion-chat.ts
│ │ │ ├── openai-completion.ts
│ │ │ ├── openai-custom-fetch-inject-error.ts
│ │ │ ├── openai-fullstream-logprobs.ts
│ │ │ ├── openai-fullstream-raw.ts
│ │ │ ├── openai-fullstream.ts
│ │ │ ├── openai-multi-step-continue.ts
│ │ │ ├── openai-multi-step.ts
│ │ │ ├── openai-on-chunk-tool-call-streaming.ts
│ │ │ ├── openai-on-chunk.ts
│ │ │ ├── openai-on-finish-response-messages.ts
│ │ │ ├── openai-on-finish-steps.ts
│ │ │ ├── openai-on-finish.ts
│ │ │ ├── openai-on-step-finish.ts
│ │ │ ├── openai-predicted-output.ts
│ │ │ ├── openai-reader.ts
│ │ │ ├── openai-reasoning-model.ts
│ │ │ ├── openai-request-body.ts
│ │ │ ├── openai-response.ts
│ │ │ ├── openai-store-generation.ts
│ │ │ ├── openai-tool-abort.ts
│ │ │ ├── openai-tool-call-raw-json-schema.ts
│ │ │ ├── openai-tool-call.ts
│ │ │ ├── openai.ts
│ │ │ ├── perplexity.ts
│ │ │ ├── togetherai.ts
│ │ │ └── xai.ts
│ │ ├── telemetry
│ │ │ ├── generate-object.ts
│ │ │ ├── generate-text-tool-call.ts
│ │ │ ├── generate-text.ts
│ │ │ ├── stream-object.ts
│ │ │ └── stream-text.ts
│ │ ├── test
│ │ │ └── response-format.ts
│ │ ├── tools
│ │ │ └── weather-tool.ts
│ │ └── types
│ │ │ └── tool-set.ts
│ └── tsconfig.json
├── express
│ ├── .env.example
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── server.ts
│ └── tsconfig.json
├── fastify
│ ├── .env.example
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── server.ts
│ └── tsconfig.json
├── hono
│ ├── .env.example
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── server.ts
│ └── tsconfig.json
├── nest
│ ├── .env.example
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── .prettierrc
│ ├── README.md
│ ├── nest-cli.json
│ ├── package.json
│ ├── src
│ │ ├── app.controller.ts
│ │ ├── app.module.ts
│ │ └── main.ts
│ ├── tsconfig.build.json
│ └── tsconfig.json
├── next-fastapi
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── api
│ │ ├── index.py
│ │ └── utils
│ │ │ ├── __init__.py
│ │ │ ├── prompt.py
│ │ │ ├── tools.py
│ │ │ └── types.py
│ ├── app
│ │ ├── (examples)
│ │ │ ├── 01-chat-text
│ │ │ │ ├── layout.tsx
│ │ │ │ └── page.tsx
│ │ │ ├── 02-chat-data
│ │ │ │ ├── layout.tsx
│ │ │ │ └── page.tsx
│ │ │ └── 03-chat-attachments
│ │ │ │ ├── layout.tsx
│ │ │ │ └── page.tsx
│ │ ├── components.tsx
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── icons.tsx
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── public
│ │ ├── next.svg
│ │ └── vercel.svg
│ ├── requirements.txt
│ ├── tailwind.config.js
│ └── tsconfig.json
├── next-langchain
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ ├── api
│ │ │ ├── chat
│ │ │ │ └── route.ts
│ │ │ ├── completion-stream-data
│ │ │ │ └── route.ts
│ │ │ ├── completion-string-output-parser
│ │ │ │ └── route.ts
│ │ │ └── completion
│ │ │ │ └── route.ts
│ │ ├── completion-stream-data
│ │ │ └── page.tsx
│ │ ├── completion-string-output-parser
│ │ │ └── page.tsx
│ │ ├── completion
│ │ │ └── page.tsx
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── tailwind.config.js
│ └── tsconfig.json
├── next-openai-kasada-bot-protection
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ ├── 149e9513-01fa-4fb0-aad4-566afd725d1b
│ │ │ └── 2d206a39-8ed7-437e-a3be-862e0f06eea3
│ │ │ │ └── [[...restpath]]
│ │ │ │ └── route.ts
│ │ ├── api
│ │ │ └── chat
│ │ │ │ └── route.ts
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ └── toaster.tsx
│ ├── kasada
│ │ ├── kasada-client.tsx
│ │ └── kasada-server.tsx
│ ├── middleware.ts
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── tailwind.config.js
│ └── tsconfig.json
├── next-openai-pages
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ └── api
│ │ │ ├── assistant-tools
│ │ │ └── route.ts
│ │ │ ├── assistant
│ │ │ └── route.ts
│ │ │ ├── call-tool
│ │ │ └── route.ts
│ │ │ ├── call-tools-in-parallel
│ │ │ └── route.ts
│ │ │ ├── generate-chat
│ │ │ └── route.ts
│ │ │ ├── generate-object
│ │ │ └── route.ts
│ │ │ ├── generate-text
│ │ │ └── route.ts
│ │ │ ├── generative-ui-route
│ │ │ └── route.ts
│ │ │ ├── stream-chat
│ │ │ └── route.ts
│ │ │ ├── stream-object
│ │ │ └── route.ts
│ │ │ └── stream-text
│ │ │ └── route.ts
│ ├── next.config.js
│ ├── package.json
│ ├── pages
│ │ ├── _app.tsx
│ │ ├── _document.tsx
│ │ ├── api
│ │ │ ├── chat-api-route.ts
│ │ │ └── chat-edge.ts
│ │ ├── assistants
│ │ │ ├── stream-assistant-response-with-tools
│ │ │ │ └── index.tsx
│ │ │ ├── stream-assistant-response
│ │ │ │ └── index.tsx
│ │ │ └── stream-assistant-switch-threads
│ │ │ │ └── index.tsx
│ │ ├── basics
│ │ │ ├── generate-object
│ │ │ │ └── index.tsx
│ │ │ ├── generate-text
│ │ │ │ └── index.tsx
│ │ │ ├── stream-object
│ │ │ │ └── index.tsx
│ │ │ └── stream-text
│ │ │ │ └── index.tsx
│ │ ├── chat
│ │ │ ├── generate-chat
│ │ │ │ └── index.tsx
│ │ │ ├── stream-chat-api-route
│ │ │ │ └── index.tsx
│ │ │ ├── stream-chat-edge
│ │ │ │ └── index.tsx
│ │ │ └── stream-chat
│ │ │ │ └── index.tsx
│ │ ├── generative-user-interface
│ │ │ └── route-components
│ │ │ │ └── index.tsx
│ │ ├── index.tsx
│ │ └── tools
│ │ │ ├── call-tool
│ │ │ └── index.tsx
│ │ │ └── call-tools-in-parallel
│ │ │ └── index.tsx
│ ├── postcss.config.js
│ ├── styles
│ │ └── globals.css
│ ├── tailwind.config.js
│ └── tsconfig.json
├── next-openai-telemetry-sentry
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ ├── api
│ │ │ └── text
│ │ │ │ └── route.ts
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── instrumentation.ts
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── sentry.client.config.js
│ ├── sentry.edge.config.js
│ ├── sentry.server.config.js
│ ├── tailwind.config.js
│ └── tsconfig.json
├── next-openai-telemetry
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ ├── README.md
│ │ ├── api
│ │ │ └── text
│ │ │ │ └── route.ts
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ └── page.tsx
│ ├── instrumentation.ts
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── tailwind.config.js
│ └── tsconfig.json
├── next-openai-upstash-rate-limits
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ ├── api
│ │ │ └── chat
│ │ │ │ └── route.ts
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ └── toaster.tsx
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── tailwind.config.js
│ └── tsconfig.json
├── next-openai
│ ├── .env.local.example
│ ├── .gitignore
│ ├── README.md
│ ├── app
│ │ ├── api
│ │ │ ├── assistant
│ │ │ │ ├── assistant-setup.md
│ │ │ │ └── route.ts
│ │ │ ├── chat
│ │ │ │ └── route.ts
│ │ │ ├── completion
│ │ │ │ └── route.ts
│ │ │ ├── files
│ │ │ │ └── route.ts
│ │ │ ├── use-chat-cache
│ │ │ │ └── route.ts
│ │ │ ├── use-chat-continue
│ │ │ │ └── route.ts
│ │ │ ├── use-chat-streamdata
│ │ │ │ └── route.ts
│ │ │ ├── use-chat-streaming-tool-calls
│ │ │ │ └── route.ts
│ │ │ ├── use-chat-throttle
│ │ │ │ └── route.ts
│ │ │ ├── use-chat-tools
│ │ │ │ └── route.ts
│ │ │ ├── use-chat-vision
│ │ │ │ └── route.ts
│ │ │ ├── use-completion-long-response
│ │ │ │ └── route.ts
│ │ │ ├── use-completion-server-side-multi-step
│ │ │ │ └── route.ts
│ │ │ ├── use-completion-throttle
│ │ │ │ └── route.ts
│ │ │ ├── use-object-expense-tracker
│ │ │ │ ├── route.ts
│ │ │ │ └── schema.ts
│ │ │ └── use-object
│ │ │ │ ├── route.ts
│ │ │ │ └── schema.ts
│ │ ├── assistant
│ │ │ └── page.tsx
│ │ ├── completion-rsc
│ │ │ ├── generate-completion.ts
│ │ │ └── page.tsx
│ │ ├── completion
│ │ │ └── page.tsx
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ ├── page.tsx
│ │ ├── stream-assistant-responses-with-tools
│ │ │ ├── actions.tsx
│ │ │ ├── ai.ts
│ │ │ ├── function.ts
│ │ │ ├── layout.tsx
│ │ │ ├── message.tsx
│ │ │ └── page.tsx
│ │ ├── stream-assistant-responses
│ │ │ ├── actions.tsx
│ │ │ ├── ai.ts
│ │ │ ├── functions.tsx
│ │ │ ├── layout.tsx
│ │ │ ├── message.tsx
│ │ │ └── page.tsx
│ │ ├── stream-object
│ │ │ ├── actions.ts
│ │ │ ├── page.tsx
│ │ │ └── schema.ts
│ │ ├── stream-ui
│ │ │ ├── actions.tsx
│ │ │ ├── ai.ts
│ │ │ ├── layout.tsx
│ │ │ ├── message.tsx
│ │ │ └── page.tsx
│ │ ├── use-chat-attachments-append
│ │ │ └── page.tsx
│ │ ├── use-chat-attachments-url
│ │ │ └── page.tsx
│ │ ├── use-chat-attachments
│ │ │ └── page.tsx
│ │ ├── use-chat-continue
│ │ │ └── page.tsx
│ │ ├── use-chat-streamdata
│ │ │ └── page.tsx
│ │ ├── use-chat-streaming-tool-calls
│ │ │ └── page.tsx
│ │ ├── use-chat-throttle
│ │ │ └── page.tsx
│ │ ├── use-chat-tools
│ │ │ └── page.tsx
│ │ ├── use-chat-vision
│ │ │ └── page.tsx
│ │ ├── use-completion-long-response
│ │ │ └── page.tsx
│ │ ├── use-completion-server-side-multi-step
│ │ │ └── page.tsx
│ │ ├── use-completion-throttle
│ │ │ └── page.tsx
│ │ ├── use-object-expense-tracker
│ │ │ └── page.tsx
│ │ └── use-object
│ │ │ └── page.tsx
│ ├── next.config.js
│ ├── package.json
│ ├── postcss.config.js
│ ├── tailwind.config.js
│ └── tsconfig.json
├── node-http-server
│ ├── .env.example
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ └── server.ts
│ └── tsconfig.json
├── nuxt-openai
│ ├── .env.example
│ ├── .gitignore
│ ├── README.md
│ ├── nuxt.config.ts
│ ├── package.json
│ ├── pages
│ │ ├── assistant
│ │ │ └── index.vue
│ │ ├── completion
│ │ │ └── index.vue
│ │ ├── index.vue
│ │ ├── use-chat-streamdata
│ │ │ └── index.vue
│ │ ├── use-chat-tools
│ │ │ └── index.vue
│ │ └── vision
│ │ │ └── index.vue
│ ├── server
│ │ ├── api
│ │ │ ├── assistant.ts
│ │ │ ├── chat-with-vision.ts
│ │ │ ├── chat.ts
│ │ │ ├── completion.ts
│ │ │ ├── use-chat-streamdata.ts
│ │ │ └── use-chat-tools.ts
│ │ └── tsconfig.json
│ └── tsconfig.json
├── solidstart-openai
│ ├── .env.example
│ ├── .gitignore
│ ├── README.md
│ ├── app.config.ts
│ ├── package.json
│ ├── postcss.config.cjs
│ ├── public
│ │ └── favicon.ico
│ ├── src
│ │ ├── app.css
│ │ ├── app.tsx
│ │ ├── entry-client.tsx
│ │ ├── entry-server.tsx
│ │ ├── global.d.ts
│ │ └── routes
│ │ │ ├── api
│ │ │ ├── chat
│ │ │ │ └── index.ts
│ │ │ ├── completion
│ │ │ │ └── index.ts
│ │ │ ├── use-chat-streamdata
│ │ │ │ └── index.ts
│ │ │ ├── use-chat-tools
│ │ │ │ └── index.ts
│ │ │ └── use-chat-vision
│ │ │ │ └── index.ts
│ │ │ ├── completion
│ │ │ └── index.tsx
│ │ │ ├── index.tsx
│ │ │ ├── use-chat-streamdata
│ │ │ └── index.tsx
│ │ │ ├── use-chat-tools
│ │ │ └── index.tsx
│ │ │ └── use-chat-vision
│ │ │ └── index.tsx
│ ├── tailwind.config.cjs
│ └── tsconfig.json
├── sveltekit-openai
│ ├── .env.example
│ ├── .gitignore
│ ├── .npmrc
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── app.d.ts
│ │ ├── app.html
│ │ └── routes
│ │ │ ├── +layout.svelte
│ │ │ ├── +page.svelte
│ │ │ ├── +page.ts
│ │ │ ├── api
│ │ │ ├── assistant
│ │ │ │ ├── +server.ts
│ │ │ │ └── assistant-setup.md
│ │ │ ├── chat
│ │ │ │ └── +server.ts
│ │ │ ├── completion
│ │ │ │ └── +server.ts
│ │ │ ├── use-chat-streamdata
│ │ │ │ └── +server.ts
│ │ │ └── use-chat-tools
│ │ │ │ └── +server.ts
│ │ │ ├── assistant
│ │ │ └── +page.svelte
│ │ │ ├── completion
│ │ │ └── +page.svelte
│ │ │ ├── styles.css
│ │ │ ├── use-chat-streamdata
│ │ │ └── +page.svelte
│ │ │ └── use-chat-tools
│ │ │ └── +page.svelte
│ ├── static
│ │ ├── favicon.png
│ │ └── robots.txt
│ ├── svelte.config.js
│ ├── tsconfig.json
│ └── vite.config.ts
└── swarm
│ ├── .env.example
│ ├── README.md
│ ├── data
│ └── 2024-world-series.txt
│ ├── package.json
│ ├── src
│ ├── basic.ts
│ └── repl.ts
│ └── tsconfig.json
├── package.json
├── packages
├── ai
│ ├── .eslintrc.js
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── core
│ │ ├── embed
│ │ │ ├── __snapshots__
│ │ │ │ ├── embed-many.test.ts.snap
│ │ │ │ └── embed.test.ts.snap
│ │ │ ├── embed-many-result.ts
│ │ │ ├── embed-many.test.ts
│ │ │ ├── embed-many.ts
│ │ │ ├── embed-result.ts
│ │ │ ├── embed.test.ts
│ │ │ ├── embed.ts
│ │ │ └── index.ts
│ │ ├── generate-object
│ │ │ ├── __snapshots__
│ │ │ │ ├── generate-object.test.ts.snap
│ │ │ │ └── stream-object.test.ts.snap
│ │ │ ├── generate-object-result.ts
│ │ │ ├── generate-object.test.ts
│ │ │ ├── generate-object.ts
│ │ │ ├── index.ts
│ │ │ ├── inject-json-instruction.test.ts
│ │ │ ├── inject-json-instruction.ts
│ │ │ ├── no-object-generated-error.ts
│ │ │ ├── output-strategy.ts
│ │ │ ├── stream-object-result.ts
│ │ │ ├── stream-object.test.ts
│ │ │ ├── stream-object.ts
│ │ │ └── validate-object-generation-input.ts
│ │ ├── generate-text
│ │ │ ├── __snapshots__
│ │ │ │ ├── generate-text.test.ts.snap
│ │ │ │ └── stream-text.test.ts.snap
│ │ │ ├── generate-text-result.ts
│ │ │ ├── generate-text.test.ts
│ │ │ ├── generate-text.ts
│ │ │ ├── index.ts
│ │ │ ├── parse-tool-call.test.ts
│ │ │ ├── parse-tool-call.ts
│ │ │ ├── run-tools-transformation.test.ts
│ │ │ ├── run-tools-transformation.ts
│ │ │ ├── step-result.ts
│ │ │ ├── stream-text-result.ts
│ │ │ ├── stream-text.test.ts
│ │ │ ├── stream-text.ts
│ │ │ ├── to-response-messages.test.ts
│ │ │ ├── to-response-messages.ts
│ │ │ ├── tool-call.ts
│ │ │ └── tool-result.ts
│ │ ├── index.ts
│ │ ├── middleware
│ │ │ ├── index.ts
│ │ │ ├── language-model-v1-middleware.ts
│ │ │ ├── wrap-language-model.test.ts
│ │ │ └── wrap-language-model.ts
│ │ ├── prompt
│ │ │ ├── attachments-to-parts.ts
│ │ │ ├── call-settings.ts
│ │ │ ├── content-part.ts
│ │ │ ├── convert-to-core-messages.test.ts
│ │ │ ├── convert-to-core-messages.ts
│ │ │ ├── convert-to-language-model-prompt.test.ts
│ │ │ ├── convert-to-language-model-prompt.ts
│ │ │ ├── data-content.test.ts
│ │ │ ├── data-content.ts
│ │ │ ├── detect-prompt-type.test.ts
│ │ │ ├── detect-prompt-type.ts
│ │ │ ├── index.ts
│ │ │ ├── invalid-data-content-error.ts
│ │ │ ├── invalid-message-role-error.ts
│ │ │ ├── message-conversion-error.ts
│ │ │ ├── message.ts
│ │ │ ├── prepare-call-settings.test.ts
│ │ │ ├── prepare-call-settings.ts
│ │ │ ├── prepare-tools-and-tool-choice.test.ts
│ │ │ ├── prepare-tools-and-tool-choice.ts
│ │ │ ├── prompt.ts
│ │ │ ├── split-data-url.ts
│ │ │ ├── standardize-prompt.test.ts
│ │ │ ├── standardize-prompt.ts
│ │ │ ├── tool-result-content.ts
│ │ │ └── ui-message.ts
│ │ ├── registry
│ │ │ ├── custom-provider.test.ts
│ │ │ ├── custom-provider.ts
│ │ │ ├── index.ts
│ │ │ ├── no-such-provider-error.ts
│ │ │ ├── provider-registry.test.ts
│ │ │ └── provider-registry.ts
│ │ ├── telemetry
│ │ │ ├── assemble-operation-name.ts
│ │ │ ├── get-base-telemetry-attributes.ts
│ │ │ ├── get-tracer.ts
│ │ │ ├── noop-tracer.ts
│ │ │ ├── record-span.ts
│ │ │ ├── select-telemetry-attributes.ts
│ │ │ ├── select-temetry-attributes.test.ts
│ │ │ └── telemetry-settings.ts
│ │ ├── test
│ │ │ ├── mock-embedding-model-v1.ts
│ │ │ ├── mock-id.ts
│ │ │ ├── mock-language-model-v1.ts
│ │ │ ├── mock-server-response.ts
│ │ │ ├── mock-tracer.ts
│ │ │ ├── mock-values.ts
│ │ │ ├── simulate-readable-stream.test.ts
│ │ │ └── simulate-readable-stream.ts
│ │ ├── tool
│ │ │ ├── index.ts
│ │ │ └── tool.ts
│ │ ├── types
│ │ │ ├── embedding-model.ts
│ │ │ ├── index.ts
│ │ │ ├── json-value.ts
│ │ │ ├── language-model-request-metadata.ts
│ │ │ ├── language-model-response-metadata.ts
│ │ │ ├── language-model.ts
│ │ │ ├── provider-metadata.ts
│ │ │ ├── provider.ts
│ │ │ └── usage.ts
│ │ └── util
│ │ │ ├── async-iterable-stream.ts
│ │ │ ├── cosine-similarity.test.ts
│ │ │ ├── cosine-similarity.ts
│ │ │ ├── create-stitchable-stream.test.ts
│ │ │ ├── create-stitchable-stream.ts
│ │ │ ├── detect-image-mimetype.ts
│ │ │ ├── is-non-empty-object.ts
│ │ │ ├── merge-streams.test.ts
│ │ │ ├── merge-streams.ts
│ │ │ ├── now.ts
│ │ │ ├── prepare-outgoing-http-headers.test.ts
│ │ │ ├── prepare-outgoing-http-headers.ts
│ │ │ ├── prepare-response-headers.test.ts
│ │ │ ├── prepare-response-headers.ts
│ │ │ ├── remove-text-after-last-whitespace.test.ts
│ │ │ ├── remove-text-after-last-whitespace.ts
│ │ │ ├── split-array.test.ts
│ │ │ ├── split-array.ts
│ │ │ ├── split-on-last-whitespace.test.ts
│ │ │ ├── split-on-last-whitespace.ts
│ │ │ ├── value-of.ts
│ │ │ └── write-to-server-response.ts
│ ├── errors
│ │ ├── index.ts
│ │ ├── invalid-argument-error.ts
│ │ ├── invalid-tool-arguments-error.ts
│ │ └── no-such-tool-error.ts
│ ├── package.json
│ ├── playwright.config.ts
│ ├── react
│ │ ├── index.ts
│ │ └── package.json
│ ├── rsc
│ │ ├── ai-state.test.ts
│ │ ├── ai-state.tsx
│ │ ├── index.ts
│ │ ├── package.json
│ │ ├── provider.tsx
│ │ ├── rsc-client.ts
│ │ ├── rsc-server.ts
│ │ ├── rsc-shared.mts
│ │ ├── shared-client
│ │ │ ├── context.tsx
│ │ │ └── index.ts
│ │ ├── stream-ui
│ │ │ ├── __snapshots__
│ │ │ │ ├── render.ui.test.tsx.snap
│ │ │ │ └── stream-ui.ui.test.tsx.snap
│ │ │ ├── index.tsx
│ │ │ ├── stream-ui.tsx
│ │ │ └── stream-ui.ui.test.tsx
│ │ ├── streamable-ui
│ │ │ ├── create-streamable-ui.tsx
│ │ │ ├── create-streamable-ui.ui.test.tsx
│ │ │ └── create-suspended-chunk.tsx
│ │ ├── streamable-value
│ │ │ ├── create-streamable-value.test.tsx
│ │ │ ├── create-streamable-value.ts
│ │ │ ├── is-streamable-value.ts
│ │ │ ├── read-streamable-value.tsx
│ │ │ ├── read-streamable-value.ui.test.tsx
│ │ │ ├── streamable-value.ts
│ │ │ └── use-streamable-value.tsx
│ │ ├── types.test-d.ts
│ │ └── types.ts
│ ├── streams
│ │ ├── assistant-response.ts
│ │ ├── index.ts
│ │ ├── langchain-adapter.test.ts
│ │ ├── langchain-adapter.ts
│ │ ├── llamaindex-adapter.test.ts
│ │ ├── llamaindex-adapter.ts
│ │ ├── stream-callbacks.ts
│ │ └── stream-data.ts
│ ├── test
│ │ └── index.ts
│ ├── tests
│ │ └── e2e
│ │ │ ├── next-server
│ │ │ ├── CHANGELOG.md
│ │ │ ├── app
│ │ │ │ ├── layout.js
│ │ │ │ ├── page.js
│ │ │ │ └── rsc
│ │ │ │ │ ├── actions.jsx
│ │ │ │ │ ├── client-utils.js
│ │ │ │ │ ├── client.js
│ │ │ │ │ └── page.js
│ │ │ └── package.json
│ │ │ └── spec
│ │ │ └── streamable.e2e.test.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── util
│ │ ├── constants.ts
│ │ ├── consume-stream.ts
│ │ ├── create-resolvable-promise.ts
│ │ ├── delay.ts
│ │ ├── delayed-promise.test.ts
│ │ ├── delayed-promise.ts
│ │ ├── download-error.ts
│ │ ├── download.test.ts
│ │ ├── download.ts
│ │ ├── is-async-generator.ts
│ │ ├── is-function.ts
│ │ ├── is-generator.ts
│ │ ├── retry-error.ts
│ │ └── retry-with-exponential-backoff.ts
│ ├── vitest.edge.config.js
│ ├── vitest.node.config.js
│ └── vitest.ui.react.config.js
├── amazon-bedrock
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── bedrock-chat-language-model.test.ts
│ │ ├── bedrock-chat-language-model.ts
│ │ ├── bedrock-chat-prompt.ts
│ │ ├── bedrock-chat-settings.ts
│ │ ├── bedrock-embedding-model.test.ts
│ │ ├── bedrock-embedding-model.ts
│ │ ├── bedrock-embedding-settings.ts
│ │ ├── bedrock-prepare-tools.ts
│ │ ├── bedrock-provider.ts
│ │ ├── convert-to-bedrock-chat-messages.test.ts
│ │ ├── convert-to-bedrock-chat-messages.ts
│ │ ├── index.ts
│ │ └── map-bedrock-finish-reason.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── anthropic
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── anthropic-api-types.ts
│ │ ├── anthropic-error.ts
│ │ ├── anthropic-messages-language-model.test.ts
│ │ ├── anthropic-messages-language-model.ts
│ │ ├── anthropic-messages-settings.ts
│ │ ├── anthropic-prepare-tools.test.ts
│ │ ├── anthropic-prepare-tools.ts
│ │ ├── anthropic-provider.ts
│ │ ├── anthropic-tools.ts
│ │ ├── convert-to-anthropic-messages-prompt.test.ts
│ │ ├── convert-to-anthropic-messages-prompt.ts
│ │ ├── index.ts
│ │ └── map-anthropic-stop-reason.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── azure
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── azure-openai-provider.test.ts
│ │ ├── azure-openai-provider.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── codemod
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── scripts
│ │ └── scaffold-codemod.ts
│ ├── src
│ │ ├── bin
│ │ │ └── codemod.ts
│ │ ├── codemods
│ │ │ ├── lib
│ │ │ │ └── remove-facade.ts
│ │ │ ├── remove-ai-stream-methods-from-stream-text-result.ts
│ │ │ ├── remove-anthropic-facade.ts
│ │ │ ├── remove-deprecated-provider-registry-exports.ts
│ │ │ ├── remove-experimental-ai-fn-exports.ts
│ │ │ ├── remove-experimental-message-types.ts
│ │ │ ├── remove-experimental-streamdata.ts
│ │ │ ├── remove-experimental-tool.ts
│ │ │ ├── remove-experimental-useassistant.ts
│ │ │ ├── remove-google-facade.ts
│ │ │ ├── remove-isxxxerror.ts
│ │ │ ├── remove-metadata-with-headers.ts
│ │ │ ├── remove-mistral-facade.ts
│ │ │ ├── remove-openai-facade.ts
│ │ │ ├── rename-format-stream-part.ts
│ │ │ ├── rename-parse-stream-part.ts
│ │ │ ├── replace-baseurl.ts
│ │ │ ├── replace-continuation-steps.ts
│ │ │ ├── replace-langchain-toaistream.ts
│ │ │ ├── replace-nanoid.ts
│ │ │ ├── replace-roundtrips-with-maxsteps.ts
│ │ │ ├── replace-token-usage-types.ts
│ │ │ └── rewrite-framework-imports.ts
│ │ ├── lib
│ │ │ ├── transform-options.ts
│ │ │ ├── transform.ts
│ │ │ └── upgrade.ts
│ │ └── test
│ │ │ ├── __testfixtures__
│ │ │ ├── remove-ai-stream-methods-from-stream-text-result.input.ts
│ │ │ ├── remove-ai-stream-methods-from-stream-text-result.output.ts
│ │ │ ├── remove-anthropic-facade.input.ts
│ │ │ ├── remove-anthropic-facade.output.ts
│ │ │ ├── remove-deprecated-provider-registry-exports.input.ts
│ │ │ ├── remove-deprecated-provider-registry-exports.output.ts
│ │ │ ├── remove-experimental-ai-fn-exports.input.ts
│ │ │ ├── remove-experimental-ai-fn-exports.output.ts
│ │ │ ├── remove-experimental-message-types.input.ts
│ │ │ ├── remove-experimental-message-types.output.ts
│ │ │ ├── remove-experimental-streamdata.input.ts
│ │ │ ├── remove-experimental-streamdata.output.ts
│ │ │ ├── remove-experimental-tool-not-ai.input.ts
│ │ │ ├── remove-experimental-tool-not-ai.output.ts
│ │ │ ├── remove-experimental-tool.input.ts
│ │ │ ├── remove-experimental-tool.output.ts
│ │ │ ├── remove-experimental-useassistant.input.tsx
│ │ │ ├── remove-experimental-useassistant.output.tsx
│ │ │ ├── remove-google-facade.input.ts
│ │ │ ├── remove-google-facade.output.ts
│ │ │ ├── remove-isxxxerror.input.ts
│ │ │ ├── remove-isxxxerror.output.ts
│ │ │ ├── remove-metadata-with-headers.input.ts
│ │ │ ├── remove-metadata-with-headers.output.ts
│ │ │ ├── remove-mistral-facade.input.ts
│ │ │ ├── remove-mistral-facade.output.ts
│ │ │ ├── remove-openai-facade-as.input.ts
│ │ │ ├── remove-openai-facade-as.output.ts
│ │ │ ├── remove-openai-facade-corp.input.ts
│ │ │ ├── remove-openai-facade-corp.output.ts
│ │ │ ├── remove-openai-facade.input.ts
│ │ │ ├── remove-openai-facade.output.ts
│ │ │ ├── rename-format-stream-part-not-ai.input.ts
│ │ │ ├── rename-format-stream-part-not-ai.output.ts
│ │ │ ├── rename-format-stream-part.input.ts
│ │ │ ├── rename-format-stream-part.output.ts
│ │ │ ├── rename-parse-stream-part-not-ai.input.ts
│ │ │ ├── rename-parse-stream-part-not-ai.output.ts
│ │ │ ├── rename-parse-stream-part.input.ts
│ │ │ ├── rename-parse-stream-part.output.ts
│ │ │ ├── replace-baseurl.input.ts
│ │ │ ├── replace-baseurl.output.ts
│ │ │ ├── replace-continuation-steps.input.ts
│ │ │ ├── replace-continuation-steps.output.ts
│ │ │ ├── replace-langchain-toaistream.input.ts
│ │ │ ├── replace-langchain-toaistream.output.ts
│ │ │ ├── replace-nanoid.input.ts
│ │ │ ├── replace-nanoid.output.ts
│ │ │ ├── replace-roundtrips-with-maxsteps.input.ts
│ │ │ ├── replace-roundtrips-with-maxsteps.output.ts
│ │ │ ├── replace-token-usage-types.input.ts
│ │ │ ├── replace-token-usage-types.output.ts
│ │ │ ├── rewrite-framework-imports-solid.input.ts
│ │ │ ├── rewrite-framework-imports-solid.output.ts
│ │ │ ├── rewrite-framework-imports-svelte.input.ts
│ │ │ ├── rewrite-framework-imports-svelte.output.ts
│ │ │ ├── rewrite-framework-imports-vue.input.ts
│ │ │ └── rewrite-framework-imports-vue.output.ts
│ │ │ ├── jscodeshift-testUtils.d.ts
│ │ │ ├── remove-ai-stream-methods-from-stream-text-result.test.ts
│ │ │ ├── remove-anthropic-facade.test.ts
│ │ │ ├── remove-deprecated-provider-registry-exports.test.ts
│ │ │ ├── remove-experimental-ai-fn-exports.test.ts
│ │ │ ├── remove-experimental-message-types.test.ts
│ │ │ ├── remove-experimental-streamdata.test.ts
│ │ │ ├── remove-experimental-tool.test.ts
│ │ │ ├── remove-experimental-useassistant.test.ts
│ │ │ ├── remove-google-facade.test.ts
│ │ │ ├── remove-isxxxerror.test.ts
│ │ │ ├── remove-metadata-with-headers.test.ts
│ │ │ ├── remove-mistral-facade.test.ts
│ │ │ ├── remove-openai-facade.test.ts
│ │ │ ├── rename-format-stream-part.test.ts
│ │ │ ├── rename-parse-stream-part.test.ts
│ │ │ ├── replace-baseurl.test.ts
│ │ │ ├── replace-continuation-steps.test.ts
│ │ │ ├── replace-langchain-toaistream.test.ts
│ │ │ ├── replace-nanoid.test.ts
│ │ │ ├── replace-roundtrips-with-maxsteps.test.ts
│ │ │ ├── replace-token-usage-types.test.ts
│ │ │ ├── rewrite-framework-imports.test.ts
│ │ │ └── test-utils.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ └── vitest.config.ts
├── cohere
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── cohere-chat-language-model.test.ts
│ │ ├── cohere-chat-language-model.ts
│ │ ├── cohere-chat-prompt.ts
│ │ ├── cohere-chat-settings.ts
│ │ ├── cohere-embedding-model.test.ts
│ │ ├── cohere-embedding-model.ts
│ │ ├── cohere-embedding-settings.ts
│ │ ├── cohere-error.ts
│ │ ├── cohere-prepare-tools.test.ts
│ │ ├── cohere-prepare-tools.ts
│ │ ├── cohere-provider.ts
│ │ ├── convert-to-cohere-chat-prompt.test.ts
│ │ ├── convert-to-cohere-chat-prompt.ts
│ │ ├── index.ts
│ │ └── map-cohere-finish-reason.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── google-vertex
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── convert-json-schema-to-openapi-schema.test.ts
│ │ ├── convert-json-schema-to-openapi-schema.ts
│ │ ├── convert-to-google-vertex-content-request.test.ts
│ │ ├── convert-to-google-vertex-content-request.ts
│ │ ├── google-error.ts
│ │ ├── google-vertex-embedding-model.test.ts
│ │ ├── google-vertex-embedding-model.ts
│ │ ├── google-vertex-embedding-settings.ts
│ │ ├── google-vertex-language-model.test.ts
│ │ ├── google-vertex-language-model.ts
│ │ ├── google-vertex-prepare-tools.ts
│ │ ├── google-vertex-provider.ts
│ │ ├── google-vertex-settings.ts
│ │ ├── index.ts
│ │ ├── map-google-vertex-finish-reason.ts
│ │ └── mock-vertex-ai.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── google
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── convert-json-schema-to-openapi-schema.test.ts
│ │ ├── convert-json-schema-to-openapi-schema.ts
│ │ ├── convert-to-google-generative-ai-messages.test.ts
│ │ ├── convert-to-google-generative-ai-messages.ts
│ │ ├── get-model-path.test.ts
│ │ ├── get-model-path.ts
│ │ ├── google-error.ts
│ │ ├── google-generative-ai-embedding-model.test.ts
│ │ ├── google-generative-ai-embedding-model.ts
│ │ ├── google-generative-ai-embedding-settings.ts
│ │ ├── google-generative-ai-language-model.test.ts
│ │ ├── google-generative-ai-language-model.ts
│ │ ├── google-generative-ai-prompt.ts
│ │ ├── google-generative-ai-settings.ts
│ │ ├── google-prepare-tools.ts
│ │ ├── google-provider.ts
│ │ ├── index.ts
│ │ └── map-google-generative-ai-finish-reason.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── groq
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── convert-to-groq-chat-messages.test.ts
│ │ ├── convert-to-groq-chat-messages.ts
│ │ ├── get-response-metadata.ts
│ │ ├── groq-api-types.ts
│ │ ├── groq-chat-language-model.test.ts
│ │ ├── groq-chat-language-model.ts
│ │ ├── groq-chat-settings.ts
│ │ ├── groq-error.ts
│ │ ├── groq-prepare-tools.ts
│ │ ├── groq-provider.ts
│ │ ├── index.ts
│ │ └── map-groq-finish-reason.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── mistral
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── __snapshots__
│ │ │ └── convert-to-mistral-chat-messages.test.ts.snap
│ │ ├── convert-to-mistral-chat-messages.test.ts
│ │ ├── convert-to-mistral-chat-messages.ts
│ │ ├── get-response-metadata.ts
│ │ ├── index.ts
│ │ ├── map-mistral-finish-reason.ts
│ │ ├── mistral-chat-language-model.test.ts
│ │ ├── mistral-chat-language-model.ts
│ │ ├── mistral-chat-prompt.ts
│ │ ├── mistral-chat-settings.ts
│ │ ├── mistral-embedding-model.test.ts
│ │ ├── mistral-embedding-model.ts
│ │ ├── mistral-embedding-settings.ts
│ │ ├── mistral-error.ts
│ │ ├── mistral-prepare-tools.ts
│ │ └── mistral-provider.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── openai
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── convert-to-openai-chat-messages.test.ts
│ │ ├── convert-to-openai-chat-messages.ts
│ │ ├── convert-to-openai-completion-prompt.ts
│ │ ├── get-response-metadata.ts
│ │ ├── index.ts
│ │ ├── internal
│ │ │ └── index.ts
│ │ ├── map-openai-chat-logprobs.ts
│ │ ├── map-openai-completion-logprobs.ts
│ │ ├── map-openai-finish-reason.ts
│ │ ├── openai-chat-language-model.test.ts
│ │ ├── openai-chat-language-model.ts
│ │ ├── openai-chat-prompt.ts
│ │ ├── openai-chat-settings.ts
│ │ ├── openai-completion-language-model.test.ts
│ │ ├── openai-completion-language-model.ts
│ │ ├── openai-completion-settings.ts
│ │ ├── openai-embedding-model.test.ts
│ │ ├── openai-embedding-model.ts
│ │ ├── openai-embedding-settings.ts
│ │ ├── openai-error.test.ts
│ │ ├── openai-error.ts
│ │ ├── openai-prepare-tools.ts
│ │ └── openai-provider.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── provider-utils
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── combine-headers.ts
│ │ ├── convert-async-iterator-to-readable-stream.ts
│ │ ├── extract-response-headers.ts
│ │ ├── fetch-function.ts
│ │ ├── generate-id.test.ts
│ │ ├── generate-id.ts
│ │ ├── get-error-message.ts
│ │ ├── index.ts
│ │ ├── is-abort-error.ts
│ │ ├── load-api-key.ts
│ │ ├── load-optional-setting.ts
│ │ ├── load-setting.ts
│ │ ├── parse-json.ts
│ │ ├── post-to-api.ts
│ │ ├── remove-undefined-entries.ts
│ │ ├── response-handler.test.ts
│ │ ├── response-handler.ts
│ │ ├── test
│ │ │ ├── convert-array-to-async-iterable.ts
│ │ │ ├── convert-array-to-readable-stream.ts
│ │ │ ├── convert-async-iterable-to-array.ts
│ │ │ ├── convert-readable-stream-to-array.ts
│ │ │ ├── convert-response-stream-to-array.ts
│ │ │ ├── index.ts
│ │ │ ├── json-test-server.ts
│ │ │ ├── streaming-test-server.ts
│ │ │ └── test-server.ts
│ │ ├── types
│ │ │ ├── tool-call.ts
│ │ │ └── tool-result.ts
│ │ ├── uint8-utils.ts
│ │ ├── validate-types.test.ts
│ │ ├── validate-types.ts
│ │ ├── validator.ts
│ │ └── without-trailing-slash.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
├── provider
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── embedding-model
│ │ │ ├── index.ts
│ │ │ └── v1
│ │ │ │ ├── embedding-model-v1-embedding.ts
│ │ │ │ ├── embedding-model-v1.ts
│ │ │ │ └── index.ts
│ │ ├── errors
│ │ │ ├── ai-sdk-error.ts
│ │ │ ├── api-call-error.ts
│ │ │ ├── empty-response-body-error.ts
│ │ │ ├── get-error-message.ts
│ │ │ ├── index.ts
│ │ │ ├── invalid-argument-error.ts
│ │ │ ├── invalid-prompt-error.ts
│ │ │ ├── invalid-response-data-error.ts
│ │ │ ├── json-parse-error.ts
│ │ │ ├── load-api-key-error.ts
│ │ │ ├── load-setting-error.ts
│ │ │ ├── no-content-generated-error.ts
│ │ │ ├── no-such-model-error.ts
│ │ │ ├── too-many-embedding-values-for-call-error.ts
│ │ │ ├── type-validation-error.ts
│ │ │ └── unsupported-functionality-error.ts
│ │ ├── index.ts
│ │ ├── json-value
│ │ │ ├── index.ts
│ │ │ ├── is-json.ts
│ │ │ └── json-value.ts
│ │ ├── language-model
│ │ │ ├── index.ts
│ │ │ └── v1
│ │ │ │ ├── index.ts
│ │ │ │ ├── language-model-v1-call-options.ts
│ │ │ │ ├── language-model-v1-call-settings.ts
│ │ │ │ ├── language-model-v1-call-warning.ts
│ │ │ │ ├── language-model-v1-finish-reason.ts
│ │ │ │ ├── language-model-v1-function-tool-call.ts
│ │ │ │ ├── language-model-v1-function-tool.ts
│ │ │ │ ├── language-model-v1-logprobs.ts
│ │ │ │ ├── language-model-v1-prompt.ts
│ │ │ │ ├── language-model-v1-provider-defined-tool.ts
│ │ │ │ ├── language-model-v1-provider-metadata.ts
│ │ │ │ ├── language-model-v1-tool-choice.ts
│ │ │ │ └── language-model-v1.ts
│ │ └── provider
│ │ │ ├── index.ts
│ │ │ └── v1
│ │ │ ├── index.ts
│ │ │ └── provider-v1.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ └── turbo.json
├── react
│ ├── .eslintrc.js
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.ts
│ │ ├── throttle.ts
│ │ ├── use-assistant.ts
│ │ ├── use-assistant.ui.test.tsx
│ │ ├── use-chat.ts
│ │ ├── use-chat.ui.test.tsx
│ │ ├── use-completion.ts
│ │ ├── use-completion.ui.test.tsx
│ │ ├── use-object.ts
│ │ └── use-object.ui.test.tsx
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ └── vitest.config.js
├── solid
│ ├── .eslintrc.js
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.ts
│ │ ├── package.json
│ │ ├── use-chat.ts
│ │ ├── use-chat.ui.test.tsx
│ │ ├── use-completion.ts
│ │ └── use-completion.ui.test.tsx
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ └── vitest.config.js
├── svelte
│ ├── .eslintrc.js
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── index.ts
│ │ ├── package.json
│ │ ├── use-assistant.ts
│ │ ├── use-chat.ts
│ │ └── use-completion.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ └── turbo.json
├── swarm
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── agent.ts
│ │ ├── index.ts
│ │ └── run-swarm.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ └── turbo.json
├── ui-utils
│ ├── .eslintrc.js
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ │ ├── assistant-stream-parts.test.ts
│ │ ├── assistant-stream-parts.ts
│ │ ├── call-chat-api.ts
│ │ ├── call-completion-api.ts
│ │ ├── data-stream-parts.test.ts
│ │ ├── data-stream-parts.ts
│ │ ├── data-url.ts
│ │ ├── deep-partial.ts
│ │ ├── duplicated
│ │ │ └── usage.ts
│ │ ├── fix-json.test.ts
│ │ ├── fix-json.ts
│ │ ├── index.ts
│ │ ├── is-deep-equal-data.test.ts
│ │ ├── is-deep-equal-data.ts
│ │ ├── parse-partial-json.test.ts
│ │ ├── parse-partial-json.ts
│ │ ├── process-assistant-stream.test.ts
│ │ ├── process-assistant-stream.ts
│ │ ├── process-chat-response.test.ts
│ │ ├── process-chat-response.ts
│ │ ├── process-data-stream.test.ts
│ │ ├── process-data-stream.ts
│ │ ├── process-text-stream.test.ts
│ │ ├── process-text-stream.ts
│ │ ├── schema.ts
│ │ ├── test
│ │ │ ├── create-data-protocol-stream.ts
│ │ │ ├── index.ts
│ │ │ └── mock-fetch.ts
│ │ ├── types.ts
│ │ └── use-assistant-types.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ ├── vitest.edge.config.js
│ └── vitest.node.config.js
└── vue
│ ├── .eslintrc.js
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── package.json
│ ├── src
│ ├── TestChatAssistantStreamComponent.vue
│ ├── TestChatAssistantThreadChangeComponent.vue
│ ├── TestChatComponent.vue
│ ├── TestChatCustomMetadataComponent.vue
│ ├── TestChatFormComponent.vue
│ ├── TestChatFormOptionsComponent.vue
│ ├── TestChatReloadComponent.vue
│ ├── TestChatTextStreamComponent.vue
│ ├── TestCompletionComponent.vue
│ ├── TestCompletionTextStreamComponent.vue
│ ├── index.ts
│ ├── package.json
│ ├── shims-vue.d.ts
│ ├── use-assistant.ts
│ ├── use-assistant.ui.test.tsx
│ ├── use-chat.ts
│ ├── use-chat.ui.test.tsx
│ ├── use-completion.ts
│ └── use-completion.ui.test.ts
│ ├── tsconfig.json
│ ├── tsup.config.ts
│ ├── turbo.json
│ └── vitest.config.js
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── socket.yaml
├── tools
├── eslint-config
│ ├── index.js
│ └── package.json
└── tsconfig
│ ├── base.json
│ ├── nextjs.json
│ ├── node14.json
│ ├── package.json
│ └── react-library.json
└── turbo.json
/.changeset/README.md:
--------------------------------------------------------------------------------
1 | # Changesets
2 |
3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4 | with multi-package repos, or single-package repos to help you version and publish your code. You can
5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6 |
7 | We have a quick list of common questions to get you started engaging with this project in
8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
9 |
--------------------------------------------------------------------------------
/.changeset/afraid-trains-shout.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/svelte': major
3 | '@ai-sdk/react': major
4 | '@ai-sdk/solid': major
5 | ---
6 |
7 | chore (ui): remove deprecated useChat roundtrip options
8 |
--------------------------------------------------------------------------------
/.changeset/big-monkeys-breathe.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to replace continuation steps.
6 |
--------------------------------------------------------------------------------
/.changeset/breezy-mayflies-promise.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove LanguageModelResponseMetadataWithHeaders type
6 |
--------------------------------------------------------------------------------
/.changeset/calm-emus-roll.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/ui-utils': major
3 | '@ai-sdk/svelte': major
4 | '@ai-sdk/react': major
5 | '@ai-sdk/solid': major
6 | '@ai-sdk/vue': major
7 | 'ai': major
8 | ---
9 |
10 | chore: remove legacy function/tool calling
11 |
--------------------------------------------------------------------------------
/.changeset/chilled-llamas-sin.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai/core): remove experimental function exports
6 |
--------------------------------------------------------------------------------
/.changeset/clean-bats-applaud.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove Tokens RSC helper
6 |
--------------------------------------------------------------------------------
/.changeset/clean-squids-marry.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove ExperimentalXXXMessage types
6 |
--------------------------------------------------------------------------------
/.changeset/clever-horses-love.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/provider-utils': major
3 | '@ai-sdk/provider': major
4 | 'ai': major
5 | ---
6 |
7 | chore: remove isXXXError methods
8 |
--------------------------------------------------------------------------------
/.changeset/clever-pigs-sin.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove experimental_StreamData export
6 |
--------------------------------------------------------------------------------
/.changeset/cold-ducks-change.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Added codemod to rm metadata w/ headers.
6 |
--------------------------------------------------------------------------------
/.changeset/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json",
3 | "changelog": "@changesets/cli/changelog",
4 | "commit": false,
5 | "fixed": [],
6 | "linked": [],
7 | "access": "public",
8 | "baseBranch": "main",
9 | "updateInternalDependencies": "patch"
10 | }
11 |
--------------------------------------------------------------------------------
/.changeset/cuddly-kings-give.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Set up package for automated migrations.
6 |
--------------------------------------------------------------------------------
/.changeset/cuddly-snails-give.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/amazon-bedrock': major
3 | '@ai-sdk/anthropic': major
4 | '@ai-sdk/azure': major
5 | '@ai-sdk/cohere': major
6 | '@ai-sdk/google': major
7 | '@ai-sdk/google-vertex': major
8 | '@ai-sdk/groq': major
9 | '@ai-sdk/mistral': major
10 | '@ai-sdk/openai': major
11 | ---
12 |
13 | chore (release): bump major version to 4.0
14 |
--------------------------------------------------------------------------------
/.changeset/curvy-pets-fry.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove streamToResponse and streamingTextResponse
6 |
--------------------------------------------------------------------------------
/.changeset/curvy-rabbits-run.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/svelte': patch
3 | '@ai-sdk/react': patch
4 | '@ai-sdk/solid': patch
5 | '@ai-sdk/vue': patch
6 | ---
7 |
8 | fix (ui): remove unnecessary calls to mutateStreamData in useChat
9 |
--------------------------------------------------------------------------------
/.changeset/dull-books-pull.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove ExperimentalTool export
6 |
--------------------------------------------------------------------------------
/.changeset/dull-zoos-suffer.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to rename formatStreamPart.
6 |
--------------------------------------------------------------------------------
/.changeset/early-needles-speak.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai/core): rename simulateReadableStream values parameter to chunks
6 |
--------------------------------------------------------------------------------
/.changeset/eight-donkeys-battle.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/google-vertex': major
3 | ---
4 |
5 | chore (provider/vertex): remove topK model setting
6 |
--------------------------------------------------------------------------------
/.changeset/few-apples-glow.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/ui-utils': patch
3 | ---
4 |
5 | chore (ui-utils): remove unnecessary dependencies
6 |
--------------------------------------------------------------------------------
/.changeset/flat-wolves-lick.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to rm isXXXError methods.
6 |
--------------------------------------------------------------------------------
/.changeset/friendly-ads-care.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to rename parseStreamPart.
6 |
--------------------------------------------------------------------------------
/.changeset/friendly-berries-refuse.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai/core): remove ai-stream related methods from streamText
6 |
--------------------------------------------------------------------------------
/.changeset/giant-goats-fetch.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/ui-utils': patch
3 | ---
4 |
5 | chore (ui-utils): mark vitest as external to reduce bundle size of /test
6 |
--------------------------------------------------------------------------------
/.changeset/good-dots-hear.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | fix (packages/codemod): Only rename baseUrl in create-provider calls.
6 |
--------------------------------------------------------------------------------
/.changeset/gorgeous-guests-rescue.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): AssistantResponse cleanups
6 |
--------------------------------------------------------------------------------
/.changeset/gorgeous-otters-sniff.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Improve codemod CLI logging.
6 |
--------------------------------------------------------------------------------
/.changeset/gorgeous-pumas-sparkle.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/provider-utils': patch
3 | 'ai': patch
4 | ---
5 |
6 | chore (dependencies): update eventsource-parser to 3.0.0
7 |
--------------------------------------------------------------------------------
/.changeset/green-fans-draw.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/react': major
3 | 'ai': major
4 | ---
5 |
6 | chore (ui/react): remove useObject setInput helper
7 |
--------------------------------------------------------------------------------
/.changeset/green-geckos-argue.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (package/codemod): Add upgrade command to run codemod bundle.
6 |
--------------------------------------------------------------------------------
/.changeset/happy-guests-chew.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/react': major
3 | ---
4 |
5 | chore (ui/react): remove experimental_addToolResult
6 |
--------------------------------------------------------------------------------
/.changeset/healthy-squids-hear.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to remove provider facades.
6 |
--------------------------------------------------------------------------------
/.changeset/honest-sheep-divide.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/openai': major
3 | ---
4 |
5 | chore (provider/openai): remove OpenAI facade
6 |
--------------------------------------------------------------------------------
/.changeset/hot-sheep-pump.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove responseMessages property from streamText/generateText result
6 |
--------------------------------------------------------------------------------
/.changeset/kind-peaches-begin.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/cohere': patch
3 | ---
4 |
5 | feat (provider/cohere): Pass along tool-plan response content.
6 |
--------------------------------------------------------------------------------
/.changeset/late-fishes-press.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to replace token usage types.
6 |
--------------------------------------------------------------------------------
/.changeset/lazy-jobs-sell.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to remove experimental msg types.
6 |
--------------------------------------------------------------------------------
/.changeset/light-phones-develop.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to replace langchain toAIStream.
6 |
--------------------------------------------------------------------------------
/.changeset/little-goats-sit.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai/core): remove init option from streamText result methods
6 |
--------------------------------------------------------------------------------
/.changeset/lovely-hairs-help.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to rm experimental_StreamData.
6 |
--------------------------------------------------------------------------------
/.changeset/lucky-rings-behave.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai/core): streamObject returns result immediately (no Promise)
6 |
--------------------------------------------------------------------------------
/.changeset/modern-suns-give.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/anthropic': major
3 | '@ai-sdk/mistral': major
4 | '@ai-sdk/google': major
5 | '@ai-sdk/openai': major
6 | ---
7 |
8 | chore (providers): remove baseUrl option
9 |
--------------------------------------------------------------------------------
/.changeset/moody-kiwis-jog.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/ui-utils': major
3 | '@ai-sdk/svelte': major
4 | '@ai-sdk/react': major
5 | '@ai-sdk/solid': major
6 | '@ai-sdk/vue': major
7 | ---
8 |
9 | chore (ui): remove streamMode setting from useChat & useCompletion
10 |
--------------------------------------------------------------------------------
/.changeset/moody-pens-sort.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/anthropic': major
3 | ---
4 |
5 | chore (provider/anthropic): remove Anthropic facade
6 |
--------------------------------------------------------------------------------
/.changeset/new-houses-perform.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove rawResponse from generate/stream result objects
6 |
--------------------------------------------------------------------------------
/.changeset/new-peaches-peel.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/google': major
3 | ---
4 |
5 | chore (provider/google): remove topK model setting
6 |
--------------------------------------------------------------------------------
/.changeset/nice-lobsters-learn.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add more automated transformations for 4.0.
6 |
--------------------------------------------------------------------------------
/.changeset/nine-experts-play.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': patch
3 | ---
4 |
5 | chore (ai): remove openai peer dependency
6 |
--------------------------------------------------------------------------------
/.changeset/olive-pets-remember.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove AIStream and related exports
6 |
--------------------------------------------------------------------------------
/.changeset/orange-cameras-serve.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/google': major
3 | ---
4 |
5 | chore (provider/google): remove facade
6 |
--------------------------------------------------------------------------------
/.changeset/perfect-trees-wait.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove 2.x prompt helpers
6 |
--------------------------------------------------------------------------------
/.changeset/plenty-buses-pump.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/mistral': major
3 | ---
4 |
5 | chore (provider/mistral): remove Mistral facade
6 |
--------------------------------------------------------------------------------
/.changeset/poor-ants-prove.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai/ui): remove vue, svelte, solid re-export and dependency
6 |
--------------------------------------------------------------------------------
/.changeset/poor-beds-reflect.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/react': major
3 | '@ai-sdk/vue': major
4 | ---
5 |
6 | chore (ui): remove experimental_useAssistant export
7 |
--------------------------------------------------------------------------------
/.changeset/poor-melons-camp.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore: remove legacy providers & rsc render
6 |
--------------------------------------------------------------------------------
/.changeset/poor-needles-double.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/provider': major
3 | 'ai': major
4 | ---
5 |
6 | chore (ai): remove toJSON method from AI SDK errors
7 |
--------------------------------------------------------------------------------
/.changeset/pretty-lemons-enjoy.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/ui-utils': major
3 | '@ai-sdk/svelte': major
4 | '@ai-sdk/react': major
5 | '@ai-sdk/solid': major
6 | '@ai-sdk/vue': major
7 | ---
8 |
9 | chore (ui): set default value of useChat keepLastMessageOnError to true
10 |
--------------------------------------------------------------------------------
/.changeset/proud-yaks-taste.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add script to scaffold new codemod.
6 |
--------------------------------------------------------------------------------
/.changeset/quiet-beans-poke.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): change `streamText` warnings result to Promise
6 |
--------------------------------------------------------------------------------
/.changeset/rare-singers-greet.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove responseMessage from streamText onFinish callback
6 |
--------------------------------------------------------------------------------
/.changeset/shaggy-humans-agree.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to remove ExperimentalTool.
6 |
--------------------------------------------------------------------------------
/.changeset/shiny-numbers-tie.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove deprecated roundtrip settings from streamText / generateText
6 |
--------------------------------------------------------------------------------
/.changeset/shy-ties-lie.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/react': major
3 | '@ai-sdk/solid': major
4 | '@ai-sdk/svelte': major
5 | '@ai-sdk/vue': major
6 | ---
7 |
8 | chore (release): bump ui package versions for 4.0 release
9 |
--------------------------------------------------------------------------------
/.changeset/silent-walls-bow.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/google': patch
3 | ---
4 |
5 | fix (provider/google): allow empty candidates array when streaming
6 |
--------------------------------------------------------------------------------
/.changeset/sixty-keys-rhyme.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | fix (packages/codemod): Only replace ai-sdk provider ctors.
6 |
--------------------------------------------------------------------------------
/.changeset/slimy-zoos-double.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (providers/codemod): Add codemod to remove deprecated prov reg exports.
6 |
--------------------------------------------------------------------------------
/.changeset/small-jars-yawn.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/provider-utils': major
3 | ---
4 |
5 | chore (provider-utils): remove convertStreamToArray
6 |
--------------------------------------------------------------------------------
/.changeset/smart-pumas-flow.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/ui-utils': patch
3 | '@ai-sdk/svelte': patch
4 | '@ai-sdk/react': patch
5 | '@ai-sdk/vue': patch
6 | ---
7 |
8 | chore (ui-utils): restructure processAssistantMessage
9 |
--------------------------------------------------------------------------------
/.changeset/soft-geckos-rescue.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': major
3 | ---
4 |
5 | chore (release): bump major version to 1.0 in prep for 4.0 release
6 |
--------------------------------------------------------------------------------
/.changeset/spotty-wombats-pay.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/provider-utils': patch
3 | ---
4 |
5 | chore (dependencies): update nanoid to 5.0.8
6 |
--------------------------------------------------------------------------------
/.changeset/stale-kings-move.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/ui-utils': major
3 | 'ai': major
4 | ---
5 |
6 | chore: remove nanoid export
7 |
--------------------------------------------------------------------------------
/.changeset/swift-kids-jam.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/provider-utils': major
3 | ---
4 |
5 | chore (ai):increase id generator default size from 7 to 16.
6 |
--------------------------------------------------------------------------------
/.changeset/tasty-dots-burn.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai/core): streamText returns result immediately (no Promise)
6 |
--------------------------------------------------------------------------------
/.changeset/tasty-waves-hug.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': patch
3 | ---
4 |
5 | chore (ai): remove unnecessary dev dependencies
6 |
--------------------------------------------------------------------------------
/.changeset/thick-foxes-judge.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (package/codemod): Add codemod to replace roundtrips.
6 |
--------------------------------------------------------------------------------
/.changeset/three-lamps-cheat.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove TokenUsage, CompletionTokenUsage, and EmbeddingTokenUsage types
6 |
--------------------------------------------------------------------------------
/.changeset/tiny-points-grin.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove deprecated provider registry exports
6 |
--------------------------------------------------------------------------------
/.changeset/tough-geese-applaud.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove experimental_continuationSteps option
6 |
--------------------------------------------------------------------------------
/.changeset/tough-trees-rhyme.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/provider-utils': major
3 | ---
4 |
5 | chore (provider-utils): remove isParseableJson export
6 |
--------------------------------------------------------------------------------
/.changeset/unlucky-hats-explain.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/codemod': patch
3 | ---
4 |
5 | feat (packages/codemod): Add codemod to rm experimental useAssistant.
6 |
--------------------------------------------------------------------------------
/.changeset/warm-insects-smoke.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove deprecated telemetry data
6 |
--------------------------------------------------------------------------------
/.changeset/warm-nails-itch.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/anthropic': major
3 | ---
4 |
5 | chore (provider/anthropic): remove topK model setting
6 |
--------------------------------------------------------------------------------
/.changeset/wise-geese-rule.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': patch
3 | '@ai-sdk/ui-utils': patch
4 | ---
5 |
6 | chore (ui): refactorings & README update
7 |
--------------------------------------------------------------------------------
/.changeset/wise-wasps-work.md:
--------------------------------------------------------------------------------
1 | ---
2 | 'ai': major
3 | ---
4 |
5 | chore (ai): remove LangChain adapter `toAIStream` method
6 |
--------------------------------------------------------------------------------
/.changeset/yellow-books-develop.md:
--------------------------------------------------------------------------------
1 | ---
2 | '@ai-sdk/google': patch
3 | ---
4 |
5 | fix (provider/google): add name/content details to tool responses
6 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | // This tells ESLint to load the config from the package `eslint-config-vercel-ai`
4 | extends: ['vercel-ai'],
5 | settings: {
6 | next: {
7 | rootDir: ['apps/*/'],
8 | },
9 | },
10 | };
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Ask a question
4 | url: https://github.com/vercel/ai/discussions
5 | about: Please ask questions in our discussions forum.
6 |
--------------------------------------------------------------------------------
/.github/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Reporting Security Issues
2 |
3 | If you believe you have found a security vulnerability in the AI SDK, we encourage you to let us know right away.
4 |
5 | We will investigate all legitimate reports and do our best to quickly fix the problem.
6 |
7 | Email `security@vercel.com` to disclose any security vulnerabilities.
8 |
9 | https://vercel.com/security
10 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: 'npm'
4 | directory: '/'
5 | schedule:
6 | interval: 'daily'
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | .turbo
4 | *.log
5 | .next
6 | dist
7 | dist-ssr
8 | *.local
9 | .env
10 | .cache
11 | server/dist
12 | public/dist
13 | .turbo
14 | test-results
--------------------------------------------------------------------------------
/.kodiak.toml:
--------------------------------------------------------------------------------
1 | # .kodiak.toml
2 | version = 1
3 |
4 | [merge]
5 | automerge_label = "automerge"
6 | require_automerge_label = false
7 | method = "squash"
8 | delete_branch_on_merge = true
9 | optimistic_updates = false
10 | prioritize_ready_to_merge = true
11 | notify_on_conflict = false
12 |
13 | [merge.message]
14 | title = "pull_request_title"
15 | body = "pull_request_body"
16 | include_pr_number = true
17 | body_type = "markdown"
18 | strip_html_comments = true
19 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | auto-install-peers = true
2 | link-workspace-packages = true
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | .next
2 | .nuxt
3 | node_modules
4 | dist
5 | .svelte-kit
6 | .solid
7 | _nuxt
8 | __testfixtures__
9 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "typescript.tsdk": "node_modules/typescript/lib"
3 | }
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | packages/ai/README.md
--------------------------------------------------------------------------------
/assets/hero.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/assets/hero.gif
--------------------------------------------------------------------------------
/content/docs/06-advanced/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Advanced
3 | description: Learn how to use advanced functionality within the AI SDK and RSC API.
4 | ---
5 |
6 | # Advanced
7 |
8 | This section covers advanced topics and concepts for the AI SDK and RSC API. Working with LLMs often requires a different mental model compared to traditional software development.
9 |
10 | After these concepts, you should have a better understanding of the paradigms behind the AI SDK and RSC API, and how to use them to build more AI applications.
11 |
--------------------------------------------------------------------------------
/content/docs/08-troubleshooting/01-migration-guide/22-migration-guide-3-4.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Migrate AI SDK 3.3 to 3.4
3 | description: Learn how to upgrade AI SDK 3.3 to 3.4.
4 | ---
5 |
6 | # Migrate AI SDK 3.3 to 3.4
7 |
8 | No breaking changes in this release.
9 |
--------------------------------------------------------------------------------
/content/docs/08-troubleshooting/03-common-issues/05-streamable-ui-errors.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Streamable UI Errors
3 | description: Troubleshooting errors related to streamable UI.
4 | ---
5 |
6 | # Streamable UI Component Error
7 |
8 | ## Issue
9 |
10 | - Variable Not Found
11 | - Cannot find `div`
12 | - `Component` refers to a value, but is being used as a type
13 |
14 | ## Solution
15 |
16 | If you encounter these errors when working with streamable UIs within server actions, it is likely because the file ends in `.ts` instead of `.tsx`.
17 |
--------------------------------------------------------------------------------
/content/docs/08-troubleshooting/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Troubleshooting
3 | description: Learn about the legacy providers that are no longer recommended for use in your app.
4 | ---
5 |
6 | # Troubleshooting
7 |
8 | This section is designed to help you quickly identify and resolve common issues encountered with the AI SDK, ensuring a smoother and more efficient development experience.
9 |
10 |
11 |
--------------------------------------------------------------------------------
/content/examples/01-next/11-state-management/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: State Management
3 | description: Learn to manage state in your Next.js application using the AI SDK
4 | ---
5 |
6 | # State Management
7 |
8 | In this section you will learn to manage state in your Next.js application using the AI SDK.
9 |
--------------------------------------------------------------------------------
/content/examples/01-next/12-interface/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Generative User Interfaces
3 | description: Learn to build generative user interfaces using the AI SDK in your Next.js application
4 | ---
5 |
6 | # Generative User Interfaces
7 |
8 | In this section you will learn to use the tool calling ability of language models to integrate more than just text responses to your application.
9 |
--------------------------------------------------------------------------------
/content/examples/01-next/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Next.js
3 | description: Explore examples of how to use the AI SDK in a Next.js Application.
4 | ---
5 |
6 | # Next.js
7 |
8 | The following examples demonstrate how to achieve different use cases while integrating AI into your Next.js application.
9 |
--------------------------------------------------------------------------------
/content/examples/05-rsc/01-basics/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Basics
3 | description: Learn the basics of using the AI SDK in your Next.js App Router application.
4 | ---
5 |
6 | # Basics
7 |
8 | One of the most basic things you can do with language models is to generate text. In this section, you will learn to generate text, and also stream it to the client.
9 |
10 | Beyond text, you will also learn to generate structured data by providing a schema of your choice, and also stream it to the client.
11 |
--------------------------------------------------------------------------------
/content/examples/05-rsc/02-chat/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Chat
3 | description: Learn how to generate chat completions using the AI SDK in your Next.js application
4 | ---
5 |
6 | # Chat
7 |
8 | So far we've learned how to generate text and structured data using single prompts. In this section, we will learn to use `messages` to add a sequence of messages to the language model and generate the response based on the context of the conversation – called chat completion.
9 |
--------------------------------------------------------------------------------
/content/examples/05-rsc/05-interface/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Generative User Interface
3 | description: Learn to build generative user interfaces using the AI SDK in your Next.js App Router application
4 | ---
5 |
6 | # Generative User Interface
7 |
8 | In this section you will learn to use the `streamUI` function to stream generative user interfaces to the client based on the response from the language model.
9 |
--------------------------------------------------------------------------------
/content/examples/05-rsc/06-assistants/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: OpenAI Assistants
3 | description: Learn to use the OpenAI Assistant API using the AI SDK in your Next.js App Router application
4 | ---
5 |
6 | # Assistants
7 |
8 | In this section, you will learn to use OpenAI's Assistant API along with `ai/rsc` functions.
9 |
--------------------------------------------------------------------------------
/content/providers/03-community-providers/90-llama-cpp.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: LLamaCpp
3 | description: Learn how to use Llama CPP.
4 | ---
5 |
6 | # LLamaCpp Provider
7 |
8 |
9 | The LlamaCpp provider is a prototype that is currently unmaintained.
10 |
11 |
12 | [nnance/llamacpp-ai-provider](https://github.com/nnance/llamacpp-ai-provider) is a community provider that uses [Llama.cpp](https://github.com/ggerganov/llama.cpp) to provide language model support for the AI SDK.
13 |
--------------------------------------------------------------------------------
/content/providers/04-adapters/index.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Adapters
3 | description: Learn how to use AI SDK Adapters.
4 | ---
5 |
6 | # Adapters
7 |
8 | Adapters are lightweight integrations that enable you to use
9 | the AI SDK UI functions (`useChat` and `useCompletion`)
10 | with 3rd party libraries.
11 |
12 | The following adapters are currently available:
13 |
14 | - [LangChain](/providers/adapters/langchain)
15 | - [LlamaIndex](/providers/adapters/llamaindex)
16 |
--------------------------------------------------------------------------------
/examples/ai-core/.env.example:
--------------------------------------------------------------------------------
1 | ANTHROPIC_API_KEY=""
2 | AWS_ACCESS_KEY_ID=""
3 | AWS_SECRET_ACCESS_KEY=""
4 | AWS_REGION=""
5 | AZURE_API_KEY=""
6 | AZURE_RESOURCE_NAME=""
7 | COHERE_API_KEY=""
8 | FIREWORKS_API_KEY=""
9 | GOOGLE_GENERATIVE_AI_API_KEY=""
10 | GOOGLE_VERTEX_LOCATION=""
11 | GOOGLE_VERTEX_PROJECT=""
12 | GROQ_API_KEY=""
13 | MISTRAL_API_KEY=""
14 | OPENAI_API_KEY=""
15 | PERPLEXITY_API_KEY=""
16 | TOGETHER_AI_API_KEY=""
17 | XAI_API_KEY=""
--------------------------------------------------------------------------------
/examples/ai-core/data/ai.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/ai-core/data/ai.pdf
--------------------------------------------------------------------------------
/examples/ai-core/data/comic-cat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/ai-core/data/comic-cat.png
--------------------------------------------------------------------------------
/examples/ai-core/data/galileo.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/ai-core/data/galileo.mp3
--------------------------------------------------------------------------------
/examples/ai-core/data/screenshot-editor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/ai-core/data/screenshot-editor.png
--------------------------------------------------------------------------------
/examples/ai-core/src/embed-many/azure.ts:
--------------------------------------------------------------------------------
1 | import { azure } from '@ai-sdk/azure';
2 | import { embedMany } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embeddings, usage } = await embedMany({
7 | model: azure.embedding('my-embedding-deployment'),
8 | values: [
9 | 'sunny day at the beach',
10 | 'rainy afternoon in the city',
11 | 'snowy night in the mountains',
12 | ],
13 | });
14 |
15 | console.log(embeddings);
16 | console.log(usage);
17 | }
18 |
19 | main().catch(console.error);
20 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed-many/cohere.ts:
--------------------------------------------------------------------------------
1 | import { cohere } from '@ai-sdk/cohere';
2 | import { embedMany } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embeddings, usage } = await embedMany({
7 | model: cohere.embedding('embed-multilingual-v3.0'),
8 | values: [
9 | 'sunny day at the beach',
10 | 'rainy afternoon in the city',
11 | 'snowy night in the mountains',
12 | ],
13 | });
14 |
15 | console.log(embeddings);
16 | console.log(usage);
17 | }
18 |
19 | main().catch(console.error);
20 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed-many/google.ts:
--------------------------------------------------------------------------------
1 | import { google } from '@ai-sdk/google';
2 | import { embedMany } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embeddings, usage } = await embedMany({
7 | model: google.textEmbeddingModel('text-embedding-004'),
8 | values: [
9 | 'sunny day at the beach',
10 | 'rainy afternoon in the city',
11 | 'snowy night in the mountains',
12 | ],
13 | });
14 |
15 | console.log(embeddings);
16 | console.log(usage);
17 | }
18 |
19 | main().catch(console.error);
20 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed-many/mistral.ts:
--------------------------------------------------------------------------------
1 | import { mistral } from '@ai-sdk/mistral';
2 | import { embedMany } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embeddings, usage } = await embedMany({
7 | model: mistral.embedding('mistral-embed'),
8 | values: [
9 | 'sunny day at the beach',
10 | 'rainy afternoon in the city',
11 | 'snowy night in the mountains',
12 | ],
13 | });
14 |
15 | console.log(embeddings);
16 | console.log(usage);
17 | }
18 |
19 | main().catch(console.error);
20 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed-many/openai-cosine-similarity.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { cosineSimilarity, embedMany } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embeddings } = await embedMany({
7 | model: openai.embedding('text-embedding-3-small'),
8 | values: ['sunny day at the beach', 'rainy afternoon in the city'],
9 | });
10 |
11 | console.log(
12 | `cosine similarity: ${cosineSimilarity(embeddings[0], embeddings[1])}`,
13 | );
14 | }
15 |
16 | main().catch(console.error);
17 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed-many/openai.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { embedMany } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embeddings, usage } = await embedMany({
7 | model: openai.embedding('text-embedding-3-small'),
8 | values: [
9 | 'sunny day at the beach',
10 | 'rainy afternoon in the city',
11 | 'snowy night in the mountains',
12 | ],
13 | });
14 |
15 | console.log(embeddings);
16 | console.log(usage);
17 | }
18 |
19 | main().catch(console.error);
20 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed/amazon-bedrock.ts:
--------------------------------------------------------------------------------
1 | import { bedrock } from '@ai-sdk/amazon-bedrock';
2 | import { embed } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embedding, usage } = await embed({
7 | model: bedrock.embedding('amazon.titan-embed-text-v2:0'),
8 | value: 'sunny day at the beach',
9 | });
10 |
11 | console.log(embedding);
12 | console.log(usage);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed/azure.ts:
--------------------------------------------------------------------------------
1 | import { azure } from '@ai-sdk/azure';
2 | import { embed } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embedding, usage } = await embed({
7 | model: azure.embedding('my-embedding-deployment'),
8 | value: 'sunny day at the beach',
9 | });
10 |
11 | console.log(embedding);
12 | console.log(usage);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed/cohere.ts:
--------------------------------------------------------------------------------
1 | import { cohere } from '@ai-sdk/cohere';
2 | import { embed } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embedding, usage } = await embed({
7 | model: cohere.embedding('embed-multilingual-v3.0'),
8 | value: 'sunny day at the beach',
9 | });
10 |
11 | console.log(embedding);
12 | console.log(usage);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed/google-vertex.ts:
--------------------------------------------------------------------------------
1 | import { vertex } from '@ai-sdk/google-vertex';
2 | import { embed } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embedding, usage } = await embed({
7 | model: vertex.textEmbeddingModel('text-embedding-004'),
8 | value: 'sunny day at the beach',
9 | });
10 |
11 | console.log(embedding);
12 | console.log(usage);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed/google.ts:
--------------------------------------------------------------------------------
1 | import { google } from '@ai-sdk/google';
2 | import { embed } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embedding, usage } = await embed({
7 | model: google.textEmbeddingModel('text-embedding-004'),
8 | value: 'sunny day at the beach',
9 | });
10 |
11 | console.log(embedding);
12 | console.log(usage);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed/mistral.ts:
--------------------------------------------------------------------------------
1 | import { mistral } from '@ai-sdk/mistral';
2 | import { embed } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embedding, usage } = await embed({
7 | model: mistral.embedding('mistral-embed'),
8 | value: 'sunny day at the beach',
9 | });
10 |
11 | console.log(embedding);
12 | console.log(usage);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/embed/openai.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { embed } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { embedding, usage } = await embed({
7 | model: openai.embedding('text-embedding-3-small'),
8 | value: 'sunny day at the beach',
9 | });
10 |
11 | console.log(embedding);
12 | console.log(usage);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/anthropic-full-result.ts:
--------------------------------------------------------------------------------
1 | import { anthropic } from '@ai-sdk/anthropic';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: anthropic('claude-3-5-sonnet-20240620'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(JSON.stringify(result, null, 2));
12 | }
13 |
14 | main().catch(console.error);
15 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/azure.ts:
--------------------------------------------------------------------------------
1 | import { azure } from '@ai-sdk/azure';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { text, usage } = await generateText({
7 | model: azure('v0-gpt-35-turbo'), // use your own deployment
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(text);
12 | console.log();
13 | console.log('Usage:', usage);
14 | }
15 |
16 | main().catch(console.error);
17 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/cohere.ts:
--------------------------------------------------------------------------------
1 | import { cohere } from '@ai-sdk/cohere';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { text, usage } = await generateText({
7 | model: cohere('command-r-plus'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(text);
12 | console.log();
13 | console.log('Usage:', usage);
14 | }
15 |
16 | main().catch(console.error);
17 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/google.ts:
--------------------------------------------------------------------------------
1 | import { google } from '@ai-sdk/google';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: google('gemini-1.5-flash-002'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(result.text);
12 | console.log();
13 | console.log('Token usage:', result.usage);
14 | console.log('Finish reason:', result.finishReason);
15 | }
16 |
17 | main().catch(console.error);
18 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/groq.ts:
--------------------------------------------------------------------------------
1 | import { groq } from '@ai-sdk/groq';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: groq('gemma2-9b-it'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(result.text);
12 | console.log();
13 | console.log('Token usage:', result.usage);
14 | console.log('Finish reason:', result.finishReason);
15 | }
16 |
17 | main().catch(console.error);
18 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/mistral-full-result.ts:
--------------------------------------------------------------------------------
1 | import { mistral } from '@ai-sdk/mistral';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: mistral('open-mistral-7b'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(JSON.stringify(result, null, 2));
12 | }
13 |
14 | main().catch(console.error);
15 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/mistral.ts:
--------------------------------------------------------------------------------
1 | import { mistral } from '@ai-sdk/mistral';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: mistral('open-mistral-7b'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(result.text);
12 | console.log();
13 | console.log('Token usage:', result.usage);
14 | console.log('Finish reason:', result.finishReason);
15 | }
16 |
17 | main().catch(console.error);
18 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai-completion.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: openai('gpt-3.5-turbo-instruct'),
8 | maxTokens: 1024,
9 | prompt: 'Invent a new holiday and describe its traditions.',
10 | });
11 |
12 | console.log(result.text);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai-full-result.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: openai('gpt-4o-mini'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(JSON.stringify(result, null, 2));
12 | }
13 |
14 | main().catch(console.error);
15 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai-logprobs.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: openai('gpt-3.5-turbo', { logprobs: 2 }),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(result.logprobs);
12 | }
13 |
14 | main().catch(console.error);
15 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai-request-body.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { request } = await generateText({
7 | model: openai('gpt-4o-mini'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log('REQUEST BODY');
12 | console.log(request.body);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai-system-message-a.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: openai('gpt-3.5-turbo'),
8 | messages: [
9 | { role: 'system', content: 'You are a helpful assistant.' },
10 | { role: 'user', content: 'What is the capital of France?' },
11 | ],
12 | });
13 |
14 | console.log(result.text);
15 | }
16 |
17 | main().catch(console.error);
18 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai-system-message-b.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = await generateText({
7 | model: openai('gpt-3.5-turbo'),
8 | system: 'You are a helpful assistant.',
9 | messages: [{ role: 'user', content: 'What is the capital of France?' }],
10 | });
11 |
12 | console.log(result.text);
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai-timeout.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { text, usage } = await generateText({
7 | model: openai('gpt-3.5-turbo'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | abortSignal: AbortSignal.timeout(1000),
10 | });
11 |
12 | console.log(text);
13 | console.log();
14 | console.log('Usage:', usage);
15 | }
16 |
17 | main().catch(console.error);
18 |
--------------------------------------------------------------------------------
/examples/ai-core/src/generate-text/openai.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { generateText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const { text, usage } = await generateText({
7 | model: openai('gpt-3.5-turbo'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | console.log(text);
12 | console.log();
13 | console.log('Usage:', usage);
14 | }
15 |
16 | main().catch(console.error);
17 |
--------------------------------------------------------------------------------
/examples/ai-core/src/middleware/get-last-user-message-text.ts:
--------------------------------------------------------------------------------
1 | import { LanguageModelV1Prompt } from 'ai';
2 |
3 | export function getLastUserMessageText({
4 | prompt,
5 | }: {
6 | prompt: LanguageModelV1Prompt;
7 | }): string | undefined {
8 | const lastMessage = prompt.at(-1);
9 |
10 | if (lastMessage?.role !== 'user') {
11 | return undefined;
12 | }
13 |
14 | return lastMessage.content.length === 0
15 | ? undefined
16 | : lastMessage.content.filter(c => c.type === 'text').join('\n');
17 | }
18 |
--------------------------------------------------------------------------------
/examples/ai-core/src/registry/embed-openai.ts:
--------------------------------------------------------------------------------
1 | import { embed } from 'ai';
2 | import { registry } from './setup-registry';
3 |
4 | async function main() {
5 | const { embedding } = await embed({
6 | model: registry.textEmbeddingModel('openai:text-embedding-3-small'),
7 | value: 'sunny day at the beach',
8 | });
9 |
10 | console.log(embedding);
11 | }
12 |
13 | main().catch(console.error);
14 |
--------------------------------------------------------------------------------
/examples/ai-core/src/registry/stream-text-anthropic.ts:
--------------------------------------------------------------------------------
1 | import { streamText } from 'ai';
2 | import { registry } from './setup-registry';
3 |
4 | async function main() {
5 | const result = streamText({
6 | model: registry.languageModel('anthropic:haiku'),
7 | prompt: 'Invent a new holiday and describe its traditions.',
8 | });
9 |
10 | for await (const textPart of result.textStream) {
11 | process.stdout.write(textPart);
12 | }
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/registry/stream-text-groq.ts:
--------------------------------------------------------------------------------
1 | import { streamText } from 'ai';
2 | import { registry } from './setup-registry';
3 |
4 | async function main() {
5 | const result = streamText({
6 | model: registry.languageModel('groq:gemma2-9b-it'),
7 | prompt: 'Invent a new holiday and describe its traditions.',
8 | });
9 |
10 | for await (const textPart of result.textStream) {
11 | process.stdout.write(textPart);
12 | }
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/registry/stream-text-openai.ts:
--------------------------------------------------------------------------------
1 | import { streamText } from 'ai';
2 | import { registry } from './setup-registry';
3 |
4 | async function main() {
5 | const result = streamText({
6 | model: registry.languageModel('openai:gpt-4-turbo'),
7 | prompt: 'Invent a new holiday and describe its traditions.',
8 | });
9 |
10 | for await (const textPart of result.textStream) {
11 | process.stdout.write(textPart);
12 | }
13 | }
14 |
15 | main().catch(console.error);
16 |
--------------------------------------------------------------------------------
/examples/ai-core/src/stream-text/azure-completion.ts:
--------------------------------------------------------------------------------
1 | import { azure } from '@ai-sdk/azure';
2 | import { streamText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = streamText({
7 | model: azure.completion('my-gpt-35-turbo-instruct-deployment'), // use your own deployment
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | for await (const textPart of result.textStream) {
12 | process.stdout.write(textPart);
13 | }
14 | }
15 |
16 | main().catch(console.error);
17 |
--------------------------------------------------------------------------------
/examples/ai-core/src/stream-text/openai-fullstream-raw.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { streamText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = streamText({
7 | model: openai('gpt-4o-mini'),
8 | prompt: 'Invent a new holiday and describe its traditions.',
9 | });
10 |
11 | for await (const part of result.fullStream) {
12 | console.log(JSON.stringify(part));
13 | }
14 | }
15 |
16 | main().catch(console.error);
17 |
--------------------------------------------------------------------------------
/examples/ai-core/src/stream-text/openai-on-chunk.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { streamText } from 'ai';
3 | import 'dotenv/config';
4 |
5 | async function main() {
6 | const result = streamText({
7 | model: openai('gpt-3.5-turbo'),
8 | onChunk({ chunk }) {
9 | console.log('onChunk', chunk);
10 | },
11 | prompt: 'Invent a new holiday and describe its traditions.',
12 | });
13 |
14 | // consume stream:
15 | for await (const textPart of result.textStream) {
16 | }
17 | }
18 |
19 | main().catch(console.error);
20 |
--------------------------------------------------------------------------------
/examples/ai-core/src/tools/weather-tool.ts:
--------------------------------------------------------------------------------
1 | import { tool } from 'ai';
2 | import { z } from 'zod';
3 |
4 | export const weatherTool = tool({
5 | description: 'Get the weather in a location',
6 | parameters: z.object({
7 | location: z.string().describe('The location to get the weather for'),
8 | }),
9 | // location below is inferred to be a string:
10 | execute: async ({ location }) => ({
11 | location,
12 | temperature: 72 + Math.floor(Math.random() * 21) - 10,
13 | }),
14 | });
15 |
--------------------------------------------------------------------------------
/examples/ai-core/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "declaration": true,
5 | "sourceMap": true,
6 | "target": "es2022",
7 | "lib": ["es2022", "dom"],
8 | "module": "esnext",
9 | "types": ["node"],
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "moduleResolution": "node",
13 | "rootDir": "./src",
14 | "outDir": "./build",
15 | "skipLibCheck": true
16 | },
17 | "include": ["src/**/*.ts"]
18 | }
19 |
--------------------------------------------------------------------------------
/examples/express/.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=""
--------------------------------------------------------------------------------
/examples/express/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ai-sdk-express-example",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "tsx src/server.ts",
7 | "type-check": "tsc --noEmit"
8 | },
9 | "dependencies": {
10 | "@ai-sdk/openai": "1.0.0-canary.3",
11 | "ai": "4.0.0-canary.13",
12 | "dotenv": "16.4.5",
13 | "express": "5.0.1"
14 | },
15 | "devDependencies": {
16 | "@types/express": "5.0.0",
17 | "@types/node": "20.11.20",
18 | "tsx": "4.7.1",
19 | "typescript": "5.6.3"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/express/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "declaration": true,
5 | "sourceMap": true,
6 | "target": "es2022",
7 | "lib": ["es2022", "dom"],
8 | "module": "esnext",
9 | "types": ["node"],
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "moduleResolution": "node",
13 | "rootDir": "./src",
14 | "outDir": "./build",
15 | "skipLibCheck": true
16 | },
17 | "include": ["src/**/*.ts"]
18 | }
19 |
--------------------------------------------------------------------------------
/examples/fastify/.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=""
--------------------------------------------------------------------------------
/examples/fastify/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ai-sdk-fastify-example",
3 | "version": "0.0.0",
4 | "private": true,
5 | "dependencies": {
6 | "@ai-sdk/openai": "1.0.0-canary.3",
7 | "ai": "4.0.0-canary.13",
8 | "dotenv": "16.4.5",
9 | "fastify": "5.1.0"
10 | },
11 | "scripts": {
12 | "type-check": "tsc --noEmit"
13 | },
14 | "devDependencies": {
15 | "@types/node": "20.11.20",
16 | "tsx": "4.7.1",
17 | "typescript": "5.6.3"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/fastify/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "declaration": true,
5 | "sourceMap": true,
6 | "target": "es2022",
7 | "lib": ["es2022", "dom"],
8 | "module": "esnext",
9 | "types": ["node"],
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "moduleResolution": "node",
13 | "rootDir": "./src",
14 | "outDir": "./build",
15 | "skipLibCheck": true
16 | },
17 | "include": ["src/**/*.ts"]
18 | }
19 |
--------------------------------------------------------------------------------
/examples/hono/.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=""
--------------------------------------------------------------------------------
/examples/hono/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ai-sdk-hono-example",
3 | "version": "0.0.0",
4 | "private": true,
5 | "dependencies": {
6 | "@ai-sdk/openai": "1.0.0-canary.3",
7 | "@hono/node-server": "1.12.2",
8 | "ai": "4.0.0-canary.13",
9 | "dotenv": "16.4.5",
10 | "hono": "4.6.9"
11 | },
12 | "scripts": {
13 | "type-check": "tsc --noEmit"
14 | },
15 | "devDependencies": {
16 | "@types/node": "20.11.20",
17 | "tsx": "4.7.1",
18 | "typescript": "5.6.3"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/hono/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "declaration": true,
5 | "sourceMap": true,
6 | "target": "es2022",
7 | "lib": ["es2022", "dom"],
8 | "module": "esnext",
9 | "types": ["node"],
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "moduleResolution": "node",
13 | "rootDir": "./src",
14 | "outDir": "./build",
15 | "skipLibCheck": true
16 | },
17 | "include": ["src/**/*.ts"]
18 | }
19 |
--------------------------------------------------------------------------------
/examples/nest/.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=""
2 |
--------------------------------------------------------------------------------
/examples/nest/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "all"
4 | }
--------------------------------------------------------------------------------
/examples/nest/nest-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/nest-cli",
3 | "collection": "@nestjs/schematics",
4 | "sourceRoot": "src",
5 | "compilerOptions": {
6 | "deleteOutDir": true
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/examples/nest/src/app.module.ts:
--------------------------------------------------------------------------------
1 | import { Module } from '@nestjs/common';
2 | import { AppController } from './app.controller';
3 |
4 | @Module({
5 | imports: [],
6 | controllers: [AppController],
7 | providers: [],
8 | })
9 | export class AppModule {}
10 |
--------------------------------------------------------------------------------
/examples/nest/src/main.ts:
--------------------------------------------------------------------------------
1 | import { NestFactory } from '@nestjs/core';
2 | import { AppModule } from './app.module';
3 | import 'dotenv/config';
4 |
5 | async function bootstrap() {
6 | const app = await NestFactory.create(AppModule);
7 | await app.listen(8080);
8 | }
9 |
10 | bootstrap();
11 |
--------------------------------------------------------------------------------
/examples/nest/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4 | }
5 |
--------------------------------------------------------------------------------
/examples/next-fastapi/.env.local.example:
--------------------------------------------------------------------------------
1 | # You must first activate a Billing Account here: https://platform.openai.com/account/billing/overview
2 | # Then get your OpenAI API Key here: https://platform.openai.com/account/api-keys
3 | OPENAI_API_KEY=xxxxxxx
4 |
--------------------------------------------------------------------------------
/examples/next-fastapi/api/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-fastapi/api/utils/__init__.py
--------------------------------------------------------------------------------
/examples/next-fastapi/api/utils/tools.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 |
4 | def get_current_weather(location, unit="fahrenheit"):
5 | if unit == "celsius":
6 | temperature = random.randint(-34, 43)
7 | else:
8 | temperature = random.randint(-30, 110)
9 |
10 | return {
11 | "temperature": temperature,
12 | "unit": unit,
13 | "location": location,
14 | }
15 |
--------------------------------------------------------------------------------
/examples/next-fastapi/api/utils/types.py:
--------------------------------------------------------------------------------
1 | from pydantic import BaseModel
2 |
3 |
4 | class ClientAttachment(BaseModel):
5 | name: str
6 | contentType: str
7 | url: str
8 |
9 |
10 | class ToolInvocation(BaseModel):
11 | toolCallId: str
12 | toolName: str
13 | args: dict
14 | result: dict
15 |
--------------------------------------------------------------------------------
/examples/next-fastapi/app/(examples)/01-chat-text/layout.tsx:
--------------------------------------------------------------------------------
1 | import { Metadata } from 'next';
2 |
3 | export const metadata: Metadata = {
4 | title: 'useChat',
5 | };
6 |
7 | export default function Layout({ children }: { children: React.ReactNode }) {
8 | return <>{children}>;
9 | }
10 |
--------------------------------------------------------------------------------
/examples/next-fastapi/app/(examples)/02-chat-data/layout.tsx:
--------------------------------------------------------------------------------
1 | import { Metadata } from 'next';
2 |
3 | export const metadata: Metadata = {
4 | title: 'useChat',
5 | };
6 |
7 | export default function Layout({ children }: { children: React.ReactNode }) {
8 | return <>{children}>;
9 | }
10 |
--------------------------------------------------------------------------------
/examples/next-fastapi/app/(examples)/03-chat-attachments/layout.tsx:
--------------------------------------------------------------------------------
1 | import { Metadata } from 'next';
2 |
3 | export const metadata: Metadata = {
4 | title: 'useChat with attachments',
5 | };
6 |
7 | export default function Layout({ children }: { children: React.ReactNode }) {
8 | return <>{children}>;
9 | }
10 |
--------------------------------------------------------------------------------
/examples/next-fastapi/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-fastapi/app/favicon.ico
--------------------------------------------------------------------------------
/examples/next-fastapi/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | :root {
6 | --foreground-rgb: 0, 0, 0;
7 | --background-start-rgb: 214, 219, 220;
8 | --background-end-rgb: 255, 255, 255;
9 | }
10 |
--------------------------------------------------------------------------------
/examples/next-fastapi/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/next-langchain/.env.local.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
--------------------------------------------------------------------------------
/examples/next-langchain/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env*.local
29 |
30 | # vercel
31 | .vercel
32 |
33 | # typescript
34 | *.tsbuildinfo
35 | next-env.d.ts
36 |
--------------------------------------------------------------------------------
/examples/next-langchain/app/api/completion/route.ts:
--------------------------------------------------------------------------------
1 | import { ChatOpenAI } from '@langchain/openai';
2 | import { LangChainAdapter } from 'ai';
3 |
4 | // Allow streaming responses up to 30 seconds
5 | export const maxDuration = 30;
6 |
7 | export async function POST(req: Request) {
8 | const { prompt } = await req.json();
9 |
10 | const model = new ChatOpenAI({
11 | model: 'gpt-3.5-turbo-0125',
12 | temperature: 0,
13 | });
14 |
15 | const stream = await model.stream(prompt);
16 |
17 | return LangChainAdapter.toDataStreamResponse(stream);
18 | }
19 |
--------------------------------------------------------------------------------
/examples/next-langchain/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-langchain/app/favicon.ico
--------------------------------------------------------------------------------
/examples/next-langchain/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/examples/next-langchain/app/layout.tsx:
--------------------------------------------------------------------------------
1 | import './globals.css';
2 | import { Inter } from 'next/font/google';
3 |
4 | const inter = Inter({ subsets: ['latin'] });
5 |
6 | export const metadata = {
7 | title: 'Create Next App',
8 | description: 'Generated by create next app',
9 | };
10 |
11 | export default function RootLayout({
12 | children,
13 | }: {
14 | children: React.ReactNode;
15 | }) {
16 | return (
17 |
18 |
{children}
19 |
20 | );
21 | }
22 |
--------------------------------------------------------------------------------
/examples/next-langchain/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {};
3 |
4 | module.exports = nextConfig;
5 |
--------------------------------------------------------------------------------
/examples/next-langchain/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/next-openai-kasada-bot-protection/.env.local.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
2 | KV_REST_API_URL=xxxxxxx
3 | KV_REST_API_TOKEN=xxxxxxx
--------------------------------------------------------------------------------
/examples/next-openai-kasada-bot-protection/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-openai-kasada-bot-protection/app/favicon.ico
--------------------------------------------------------------------------------
/examples/next-openai-kasada-bot-protection/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/examples/next-openai-kasada-bot-protection/app/toaster.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | export { Toaster as default } from 'sonner';
4 |
--------------------------------------------------------------------------------
/examples/next-openai-kasada-bot-protection/middleware.ts:
--------------------------------------------------------------------------------
1 | import type { NextFetchEvent, NextRequest } from 'next/server';
2 | import { kasadaHandler } from './kasada/kasada-server';
3 |
4 | export async function middleware(req: NextRequest, ev: NextFetchEvent) {
5 | if (req.method === 'POST') {
6 | if (process.env.NODE_ENV === 'development') {
7 | return undefined;
8 | }
9 | return kasadaHandler(req, ev);
10 | }
11 | }
12 |
13 | export const config = { matcher: ['/api/chat'] };
14 |
--------------------------------------------------------------------------------
/examples/next-openai-kasada-bot-protection/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {};
3 |
4 | module.exports = nextConfig;
5 |
--------------------------------------------------------------------------------
/examples/next-openai-kasada-bot-protection/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/.env.local.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
2 | ASSISTANT_ID=xxxxxxx
--------------------------------------------------------------------------------
/examples/next-openai-pages/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env*.local
29 |
30 | # vercel
31 | .vercel
32 |
33 | # typescript
34 | *.tsbuildinfo
35 | next-env.d.ts
36 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/app/api/generate-chat/route.ts:
--------------------------------------------------------------------------------
1 | import { CoreMessage, generateText } from 'ai';
2 | import { openai } from '@ai-sdk/openai';
3 |
4 | export async function POST(req: Request) {
5 | const { messages }: { messages: CoreMessage[] } = await req.json();
6 |
7 | const { response } = await generateText({
8 | model: openai('gpt-4'),
9 | system: 'You are a helpful assistant.',
10 | messages,
11 | });
12 |
13 | return Response.json({ messages: response.messages });
14 | }
15 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/app/api/generate-text/route.ts:
--------------------------------------------------------------------------------
1 | import { generateText } from 'ai';
2 | import { openai } from '@ai-sdk/openai';
3 |
4 | export async function POST(req: Request) {
5 | const { prompt }: { prompt: string } = await req.json();
6 |
7 | const { text } = await generateText({
8 | model: openai('gpt-4'),
9 | system: 'You are a helpful assistant.',
10 | prompt,
11 | });
12 |
13 | return Response.json({ text });
14 | }
15 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/app/api/stream-chat/route.ts:
--------------------------------------------------------------------------------
1 | import { CoreMessage, streamText } from 'ai';
2 | import { openai } from '@ai-sdk/openai';
3 |
4 | export async function POST(req: Request) {
5 | const { messages }: { messages: CoreMessage[] } = await req.json();
6 |
7 | const result = streamText({
8 | model: openai('gpt-4'),
9 | system: 'You are a helpful assistant.',
10 | messages,
11 | });
12 |
13 | return result.toDataStreamResponse();
14 | }
15 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/app/api/stream-text/route.ts:
--------------------------------------------------------------------------------
1 | import { streamText } from 'ai';
2 | import { openai } from '@ai-sdk/openai';
3 |
4 | export async function POST(req: Request) {
5 | const { prompt }: { prompt: string } = await req.json();
6 |
7 | const result = streamText({
8 | model: openai('gpt-4'),
9 | system: 'You are a helpful assistant.',
10 | prompt,
11 | });
12 |
13 | return result.toDataStreamResponse();
14 | }
15 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {};
3 |
4 | module.exports = nextConfig;
5 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/pages/_app.tsx:
--------------------------------------------------------------------------------
1 | import '@/styles/globals.css';
2 | import type { AppProps } from 'next/app';
3 |
4 | export default function App({ Component, pageProps }: AppProps) {
5 | return ;
6 | }
7 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/pages/_document.tsx:
--------------------------------------------------------------------------------
1 | import { Html, Head, Main, NextScript } from 'next/document';
2 |
3 | export default function Document() {
4 | return (
5 |
6 |
8 |
9 |
10 |
11 |
12 | );
13 | }
14 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/pages/api/chat-edge.ts:
--------------------------------------------------------------------------------
1 | import { openai } from '@ai-sdk/openai';
2 | import { streamText } from 'ai';
3 |
4 | export const runtime = 'edge';
5 |
6 | export default async function handler(req: Request) {
7 | const { messages } = await req.json();
8 |
9 | const result = streamText({
10 | model: openai('gpt-4-turbo-preview'),
11 | messages,
12 | });
13 |
14 | return result.toDataStreamResponse();
15 | }
16 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/next-openai-pages/styles/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry-sentry/.env.local.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
2 | SENTRY_AUTH_TOKEN=xxxxxxx
3 | SENTRY_ORG=xxxxxxx
4 | SENTRY_PROJECT=xxxxxxx
5 | NEXT_PUBLIC_SENTRY_DSN=xxxxxxx
--------------------------------------------------------------------------------
/examples/next-openai-telemetry-sentry/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-openai-telemetry-sentry/app/favicon.ico
--------------------------------------------------------------------------------
/examples/next-openai-telemetry-sentry/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry-sentry/instrumentation.ts:
--------------------------------------------------------------------------------
1 | import { registerOTel } from '@vercel/otel';
2 |
3 | export async function register() {
4 | if (process.env.NEXT_RUNTIME === 'nodejs') {
5 | await import('./sentry.server.config');
6 | }
7 |
8 | if (process.env.NEXT_RUNTIME === 'edge') {
9 | await import('./sentry.edge.config');
10 | }
11 |
12 | registerOTel({
13 | serviceName: 'next-app',
14 | });
15 | }
16 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry-sentry/next.config.js:
--------------------------------------------------------------------------------
1 | const { withSentryConfig } = require('@sentry/nextjs');
2 |
3 | /** @type {import('next').NextConfig} */
4 | const nextConfig = {};
5 |
6 | module.exports = withSentryConfig(nextConfig, {
7 | org: process.env.SENTRY_ORG,
8 | project: process.env.SENTRY_PROJECT,
9 |
10 | // An auth token is required for uploading source maps.
11 | authToken: process.env.SENTRY_AUTH_TOKEN,
12 |
13 | silent: false, // Can be used to suppress logs
14 | });
15 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry-sentry/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry/.env.local.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
--------------------------------------------------------------------------------
/examples/next-openai-telemetry/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env*.local
29 |
30 | # vercel
31 | .vercel
32 |
33 | # typescript
34 | *.tsbuildinfo
35 | next-env.d.ts
36 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-openai-telemetry/app/favicon.ico
--------------------------------------------------------------------------------
/examples/next-openai-telemetry/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry/instrumentation.ts:
--------------------------------------------------------------------------------
1 | import { registerOTel } from '@vercel/otel';
2 |
3 | export function register() {
4 | registerOTel({
5 | serviceName: 'next-app',
6 | });
7 | }
8 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {};
3 |
4 | module.exports = nextConfig;
5 |
--------------------------------------------------------------------------------
/examples/next-openai-telemetry/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/next-openai-upstash-rate-limits/.env.local.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
2 | KV_REST_API_URL=xxxxxxx
3 | KV_REST_API_TOKEN=xxxxxxx
--------------------------------------------------------------------------------
/examples/next-openai-upstash-rate-limits/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-openai-upstash-rate-limits/app/favicon.ico
--------------------------------------------------------------------------------
/examples/next-openai-upstash-rate-limits/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/examples/next-openai-upstash-rate-limits/app/toaster.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | export { Toaster as default } from 'sonner';
4 |
--------------------------------------------------------------------------------
/examples/next-openai-upstash-rate-limits/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {};
3 |
4 | module.exports = nextConfig;
5 |
--------------------------------------------------------------------------------
/examples/next-openai-upstash-rate-limits/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/next-openai/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env*.local
29 |
30 | # vercel
31 | .vercel
32 |
33 | # typescript
34 | *.tsbuildinfo
35 | next-env.d.ts
36 |
--------------------------------------------------------------------------------
/examples/next-openai/app/completion-rsc/generate-completion.ts:
--------------------------------------------------------------------------------
1 | 'use server';
2 |
3 | import { openai } from '@ai-sdk/openai';
4 | import { streamText } from 'ai';
5 | import { createStreamableValue } from 'ai/rsc';
6 |
7 | export async function generateCompletion(prompt: string) {
8 | const result = streamText({
9 | model: openai('gpt-4-turbo'),
10 | maxTokens: 2000,
11 | prompt,
12 | });
13 |
14 | return createStreamableValue(result.textStream).value;
15 | }
16 |
--------------------------------------------------------------------------------
/examples/next-openai/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/next-openai/app/favicon.ico
--------------------------------------------------------------------------------
/examples/next-openai/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-assistant-responses-with-tools/ai.ts:
--------------------------------------------------------------------------------
1 | import { createAI } from 'ai/rsc';
2 | import { submitMessage } from './actions';
3 |
4 | export const AI = createAI({
5 | actions: {
6 | submitMessage,
7 | },
8 | initialAIState: [],
9 | initialUIState: [],
10 | });
11 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-assistant-responses-with-tools/layout.tsx:
--------------------------------------------------------------------------------
1 | import { ReactNode } from 'react';
2 | import { AI } from './ai';
3 |
4 | export default function Layout({ children }: { children: ReactNode }) {
5 | return {children};
6 | }
7 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-assistant-responses-with-tools/message.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import { StreamableValue, useStreamableValue } from 'ai/rsc';
4 |
5 | export function Message({ textStream }: { textStream: StreamableValue }) {
6 | const [text] = useStreamableValue(textStream);
7 |
8 | return {text}
;
9 | }
10 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-assistant-responses/ai.ts:
--------------------------------------------------------------------------------
1 | import { createAI } from 'ai/rsc';
2 | import { submitMessage } from './actions';
3 |
4 | export const AI = createAI({
5 | actions: {
6 | submitMessage,
7 | },
8 | initialAIState: [],
9 | initialUIState: [],
10 | });
11 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-assistant-responses/layout.tsx:
--------------------------------------------------------------------------------
1 | import { ReactNode } from 'react';
2 | import { AI } from './ai';
3 |
4 | export default function Layout({ children }: { children: ReactNode }) {
5 | return {children};
6 | }
7 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-assistant-responses/message.tsx:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | import { StreamableValue, useStreamableValue } from 'ai/rsc';
4 |
5 | export function Message({ textStream }: { textStream: StreamableValue }) {
6 | const [text] = useStreamableValue(textStream);
7 |
8 | return {text}
;
9 | }
10 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-ui/ai.ts:
--------------------------------------------------------------------------------
1 | import { createAI } from 'ai/rsc';
2 | import { AIState, submitUserMessage, UIState } from './actions';
3 | import { generateId } from 'ai';
4 |
5 | export const AI = createAI({
6 | actions: { submitUserMessage },
7 | initialUIState: [] as UIState,
8 | initialAIState: { chatId: generateId(), messages: [] } as AIState,
9 | });
10 |
--------------------------------------------------------------------------------
/examples/next-openai/app/stream-ui/layout.tsx:
--------------------------------------------------------------------------------
1 | import { AI } from './ai';
2 |
3 | export default function Layout({ children }: { children: React.ReactNode }) {
4 | return {children};
5 | }
6 |
--------------------------------------------------------------------------------
/examples/next-openai/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {};
3 |
4 | module.exports = nextConfig;
5 |
--------------------------------------------------------------------------------
/examples/next-openai/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/examples/node-http-server/.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=""
--------------------------------------------------------------------------------
/examples/node-http-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ai-sdk-http-server-example",
3 | "version": "0.0.0",
4 | "private": true,
5 | "dependencies": {
6 | "@ai-sdk/openai": "1.0.0-canary.3",
7 | "ai": "4.0.0-canary.13",
8 | "dotenv": "16.4.5",
9 | "zod": "3.23.8",
10 | "zod-to-json-schema": "3.23.2"
11 | },
12 | "scripts": {
13 | "type-check": "tsc --noEmit"
14 | },
15 | "devDependencies": {
16 | "@types/node": "20.11.20",
17 | "tsx": "4.7.1",
18 | "typescript": "5.6.3"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/node-http-server/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "declaration": true,
5 | "sourceMap": true,
6 | "target": "es2022",
7 | "lib": ["es2022", "dom"],
8 | "module": "esnext",
9 | "types": ["node"],
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "moduleResolution": "node",
13 | "rootDir": "./src",
14 | "outDir": "./build",
15 | "skipLibCheck": true
16 | },
17 | "include": ["src/**/*.ts"]
18 | }
19 |
--------------------------------------------------------------------------------
/examples/nuxt-openai/.env.example:
--------------------------------------------------------------------------------
1 | NUXT_OPENAI_API_KEY=xxxxxxx
2 | NUXT_ASSISTANT_ID=xxxxxxx
--------------------------------------------------------------------------------
/examples/nuxt-openai/.gitignore:
--------------------------------------------------------------------------------
1 | # Nuxt dev/build outputs
2 | .output
3 | .nuxt
4 | .vercel
5 | .nitro
6 | .cache
7 | dist
8 |
9 | # Node dependencies
10 | node_modules
11 |
12 | # Logs
13 | logs
14 | *.log
15 |
16 | # Misc
17 | .DS_Store
18 | .fleet
19 | .idea
20 |
21 | # Local env files
22 | .env
23 | .env.*
24 | !.env.example
25 | .dev.vars
26 | .data
--------------------------------------------------------------------------------
/examples/nuxt-openai/nuxt.config.ts:
--------------------------------------------------------------------------------
1 | // https://nuxt.com/docs/api/configuration/nuxt-config
2 | export default defineNuxtConfig({
3 | devtools: { enabled: true },
4 | modules: ['@nuxtjs/tailwindcss'],
5 |
6 | nitro: {
7 | preset: 'vercel-edge', // you can use 'vercel' or other providers here
8 | },
9 |
10 | runtimeConfig: {
11 | openaiApiKey: '',
12 | assistantId: '',
13 | },
14 |
15 | compatibilityDate: '2024-07-05',
16 | telemetry: false,
17 | });
18 |
--------------------------------------------------------------------------------
/examples/nuxt-openai/server/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../.nuxt/tsconfig.server.json"
3 | }
4 |
--------------------------------------------------------------------------------
/examples/nuxt-openai/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | // https://nuxt.com/docs/guide/concepts/typescript
3 | "extends": "./.nuxt/tsconfig.json"
4 | }
5 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
2 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | dist
3 | .solid
4 | .output
5 | .vercel
6 | .netlify
7 | .vinxi
8 |
9 | # Environment
10 | .env
11 | .env*.local
12 |
13 | # dependencies
14 | /node_modules
15 |
16 | # IDEs and editors
17 | /.idea
18 | .project
19 | .classpath
20 | *.launch
21 | .settings/
22 |
23 | # Temp
24 | gitignore
25 |
26 | # System Files
27 | .DS_Store
28 | Thumbs.db
29 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/app.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from '@solidjs/start/config';
2 |
3 | export default defineConfig({});
4 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/postcss.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/solidstart-openai/public/favicon.ico
--------------------------------------------------------------------------------
/examples/solidstart-openai/src/app.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
--------------------------------------------------------------------------------
/examples/solidstart-openai/src/app.tsx:
--------------------------------------------------------------------------------
1 | import { Router } from '@solidjs/router';
2 | import { FileRoutes } from '@solidjs/start/router';
3 | import { Suspense } from 'solid-js';
4 |
5 | import './app.css';
6 |
7 | export default function App() {
8 | return (
9 | (
11 | <>
12 | {props.children}
13 | >
14 | )}
15 | >
16 |
17 |
18 | );
19 | }
20 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/src/entry-client.tsx:
--------------------------------------------------------------------------------
1 | // @refresh reload
2 | import { mount, StartClient } from '@solidjs/start/client';
3 |
4 | mount(() => , document.getElementById('app')!);
5 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/src/global.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/tailwind.config.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | module.exports = {
3 | content: ["./src/**/*.{html,js,jsx,ts,tsx}"],
4 | theme: {
5 | extend: {}
6 | },
7 | plugins: []
8 | };
9 |
--------------------------------------------------------------------------------
/examples/solidstart-openai/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ESNext",
4 | "module": "ESNext",
5 | "moduleResolution": "bundler",
6 | "allowSyntheticDefaultImports": true,
7 | "esModuleInterop": true,
8 | "jsx": "preserve",
9 | "jsxImportSource": "solid-js",
10 | "allowJs": true,
11 | "noEmit": true,
12 | "strict": true,
13 | "types": ["vinxi/types/client"],
14 | "isolatedModules": true,
15 | "paths": {
16 | "~/*": ["./src/*"]
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/examples/sveltekit-openai/.env.example:
--------------------------------------------------------------------------------
1 | OPENAI_API_KEY=xxxxxxx
--------------------------------------------------------------------------------
/examples/sveltekit-openai/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /build
4 | /.svelte-kit
5 | /package
6 | .env
7 | .env.*
8 | !.env.example
9 | .vercel
10 | .output
11 | vite.config.js.timestamp-*
12 | vite.config.ts.timestamp-*
13 |
--------------------------------------------------------------------------------
/examples/sveltekit-openai/.npmrc:
--------------------------------------------------------------------------------
1 | engine-strict=true
2 | resolution-mode=highest
3 |
--------------------------------------------------------------------------------
/examples/sveltekit-openai/src/app.d.ts:
--------------------------------------------------------------------------------
1 | // See https://kit.svelte.dev/docs/types#app
2 | // for information about these interfaces
3 | declare global {
4 | namespace App {
5 | // interface Error {}
6 | // interface Locals {}
7 | // interface PageData {}
8 | // interface Platform {}
9 | }
10 | }
11 |
12 | export {};
13 |
--------------------------------------------------------------------------------
/examples/sveltekit-openai/src/app.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %sveltekit.head%
8 |
9 |
10 | %sveltekit.body%
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/sveltekit-openai/src/routes/+page.ts:
--------------------------------------------------------------------------------
1 | // since there's no dynamic data here, we can prerender
2 | // it so that it gets served as a static asset in production
3 | export const prerender = true;
4 |
--------------------------------------------------------------------------------
/examples/sveltekit-openai/static/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OpenRouterTeam/ai/f671cf094b1091b3731836efa0f2cafee10036a0/examples/sveltekit-openai/static/favicon.png
--------------------------------------------------------------------------------
/examples/sveltekit-openai/static/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/examples/sveltekit-openai/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { sveltekit } from '@sveltejs/kit/vite';
2 | import { defineConfig } from 'vite';
3 |
4 | export default defineConfig({
5 | plugins: [sveltekit()],
6 | });
7 |
--------------------------------------------------------------------------------
/examples/swarm/.env.example:
--------------------------------------------------------------------------------
1 | ANTHROPIC_API_KEY=""
2 | AWS_ACCESS_KEY_ID=""
3 | AWS_SECRET_ACCESS_KEY=""
4 | AWS_REGION=""
5 | AZURE_API_KEY=""
6 | AZURE_RESOURCE_NAME=""
7 | COHERE_API_KEY=""
8 | FIREWORKS_API_KEY=""
9 | GOOGLE_GENERATIVE_AI_API_KEY=""
10 | GOOGLE_VERTEX_LOCATION=""
11 | GOOGLE_VERTEX_PROJECT=""
12 | GROQ_API_KEY=""
13 | MISTRAL_API_KEY=""
14 | OPENAI_API_KEY=""
15 | PERPLEXITY_API_KEY=""
16 | XAI_API_KEY=""
--------------------------------------------------------------------------------
/examples/swarm/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "strict": true,
4 | "declaration": true,
5 | "sourceMap": true,
6 | "target": "es2022",
7 | "lib": ["es2022", "dom"],
8 | "module": "esnext",
9 | "types": ["node"],
10 | "esModuleInterop": true,
11 | "allowSyntheticDefaultImports": true,
12 | "moduleResolution": "node",
13 | "rootDir": "./src",
14 | "outDir": "./build",
15 | "skipLibCheck": true
16 | },
17 | "include": ["src/**/*.ts"]
18 | }
19 |
--------------------------------------------------------------------------------
/packages/ai/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['vercel-ai'],
4 | };
5 |
--------------------------------------------------------------------------------
/packages/ai/core/embed/index.ts:
--------------------------------------------------------------------------------
1 | export * from './embed';
2 | export * from './embed-many';
3 | export * from './embed-many-result';
4 | export * from './embed-result';
5 |
--------------------------------------------------------------------------------
/packages/ai/core/generate-object/index.ts:
--------------------------------------------------------------------------------
1 | export { generateObject } from './generate-object';
2 | export type { GenerateObjectResult } from './generate-object-result';
3 | export { streamObject } from './stream-object';
4 | export type {
5 | ObjectStreamPart,
6 | StreamObjectResult,
7 | } from './stream-object-result';
8 |
--------------------------------------------------------------------------------
/packages/ai/core/index.ts:
--------------------------------------------------------------------------------
1 | export { jsonSchema } from '@ai-sdk/ui-utils';
2 | export type { DeepPartial, Schema } from '@ai-sdk/ui-utils';
3 | export * from './embed';
4 | export * from './generate-object';
5 | export * from './generate-text';
6 | export * from './middleware';
7 | export * from './prompt';
8 | export * from './registry';
9 | export * from './tool';
10 | export * from './types';
11 | export { cosineSimilarity } from './util/cosine-similarity';
12 |
--------------------------------------------------------------------------------
/packages/ai/core/middleware/index.ts:
--------------------------------------------------------------------------------
1 | export type { Experimental_LanguageModelV1Middleware } from './language-model-v1-middleware';
2 | export { experimental_wrapLanguageModel } from './wrap-language-model';
3 |
--------------------------------------------------------------------------------
/packages/ai/core/prompt/data-content.test.ts:
--------------------------------------------------------------------------------
1 | import { dataContentSchema } from './data-content';
2 |
3 | describe('dataContentSchema', () => {
4 | it('should validate a Buffer', () => {
5 | const buffer = Buffer.from('Hello, world!');
6 | const result = dataContentSchema.parse(buffer);
7 | expect(result).toEqual(buffer);
8 | });
9 |
10 | it('should reject a non-matching object', () => {
11 | const nonMatchingObject = { foo: 'bar' };
12 | expect(() => dataContentSchema.parse(nonMatchingObject)).toThrow();
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/packages/ai/core/prompt/index.ts:
--------------------------------------------------------------------------------
1 | export type {
2 | FilePart,
3 | ImagePart,
4 | TextPart,
5 | ToolCallPart,
6 | ToolResultPart,
7 | } from './content-part';
8 | export { convertToCoreMessages } from './convert-to-core-messages';
9 | export type { DataContent } from './data-content';
10 | export type {
11 | AssistantContent,
12 | CoreAssistantMessage,
13 | CoreMessage,
14 | CoreSystemMessage,
15 | CoreToolMessage,
16 | CoreUserMessage,
17 | ToolContent,
18 | UserContent,
19 | } from './message';
20 |
--------------------------------------------------------------------------------
/packages/ai/core/prompt/split-data-url.ts:
--------------------------------------------------------------------------------
1 | export function splitDataUrl(dataUrl: string): {
2 | mimeType: string | undefined;
3 | base64Content: string | undefined;
4 | } {
5 | try {
6 | const [header, base64Content] = dataUrl.split(',');
7 | return {
8 | mimeType: header.split(';')[0].split(':')[1],
9 | base64Content,
10 | };
11 | } catch (error) {
12 | return {
13 | mimeType: undefined,
14 | base64Content: undefined,
15 | };
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/ai/core/prompt/ui-message.ts:
--------------------------------------------------------------------------------
1 | import { Attachment, ToolInvocation } from '@ai-sdk/ui-utils';
2 |
3 | // only for internal use - should be removed when we fully migrate to core messages
4 | export type UIMessage = {
5 | role: 'system' | 'user' | 'assistant' | 'data';
6 |
7 | content: string;
8 | toolInvocations?: ToolInvocation[];
9 | experimental_attachments?: Attachment[];
10 | };
11 |
--------------------------------------------------------------------------------
/packages/ai/core/registry/index.ts:
--------------------------------------------------------------------------------
1 | export { experimental_customProvider } from './custom-provider';
2 | export * from './no-such-provider-error';
3 | export * from './provider-registry';
4 |
--------------------------------------------------------------------------------
/packages/ai/core/telemetry/get-tracer.ts:
--------------------------------------------------------------------------------
1 | import { Tracer, trace } from '@opentelemetry/api';
2 | import { noopTracer } from './noop-tracer';
3 |
4 | export function getTracer({
5 | isEnabled = false,
6 | tracer,
7 | }: {
8 | isEnabled?: boolean;
9 | tracer?: Tracer;
10 | } = {}): Tracer {
11 | if (!isEnabled) {
12 | return noopTracer;
13 | }
14 |
15 | if (tracer) {
16 | return tracer;
17 | }
18 |
19 | return trace.getTracer('ai');
20 | }
21 |
--------------------------------------------------------------------------------
/packages/ai/core/test/mock-id.ts:
--------------------------------------------------------------------------------
1 | export function mockId(): () => string {
2 | let counter = 0;
3 | return () => `id-${counter++}`;
4 | }
5 |
--------------------------------------------------------------------------------
/packages/ai/core/test/mock-values.ts:
--------------------------------------------------------------------------------
1 | export function mockValues(...values: T[]): () => T {
2 | let counter = 0;
3 | return () => values[counter++] ?? values[values.length - 1];
4 | }
5 |
--------------------------------------------------------------------------------
/packages/ai/core/tool/index.ts:
--------------------------------------------------------------------------------
1 | export { tool } from './tool';
2 | export type { CoreTool } from './tool';
3 |
--------------------------------------------------------------------------------
/packages/ai/core/types/embedding-model.ts:
--------------------------------------------------------------------------------
1 | import { EmbeddingModelV1, EmbeddingModelV1Embedding } from '@ai-sdk/provider';
2 |
3 | /**
4 | Embedding model that is used by the AI SDK Core functions.
5 | */
6 | export type EmbeddingModel = EmbeddingModelV1;
7 |
8 | /**
9 | Embedding.
10 | */
11 | export type Embedding = EmbeddingModelV1Embedding;
12 |
--------------------------------------------------------------------------------
/packages/ai/core/types/json-value.ts:
--------------------------------------------------------------------------------
1 | import { JSONValue } from '@ai-sdk/provider';
2 | import { z } from 'zod';
3 |
4 | export const jsonValueSchema: z.ZodType = z.lazy(() =>
5 | z.union([
6 | z.null(),
7 | z.string(),
8 | z.number(),
9 | z.boolean(),
10 | z.record(z.string(), jsonValueSchema),
11 | z.array(jsonValueSchema),
12 | ]),
13 | );
14 |
--------------------------------------------------------------------------------
/packages/ai/core/types/language-model-request-metadata.ts:
--------------------------------------------------------------------------------
1 | export type LanguageModelRequestMetadata = {
2 | /**
3 | Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
4 | */
5 | body?: string;
6 | };
7 |
--------------------------------------------------------------------------------
/packages/ai/core/types/language-model-response-metadata.ts:
--------------------------------------------------------------------------------
1 | export type LanguageModelResponseMetadata = {
2 | /**
3 | ID for the generated response.
4 | */
5 | id: string;
6 |
7 | /**
8 | Timestamp for the start of the generated response.
9 | */
10 | timestamp: Date;
11 |
12 | /**
13 | The ID of the response model that was used to generate the response.
14 | */
15 | modelId: string;
16 |
17 | /**
18 | Response headers.
19 | */
20 | headers?: Record;
21 | };
22 |
--------------------------------------------------------------------------------
/packages/ai/core/util/is-non-empty-object.ts:
--------------------------------------------------------------------------------
1 | export function isNonEmptyObject(
2 | object: Record | undefined | null,
3 | ): object is Record {
4 | return object != null && Object.keys(object).length > 0;
5 | }
6 |
--------------------------------------------------------------------------------
/packages/ai/core/util/now.ts:
--------------------------------------------------------------------------------
1 | // Shim for performance.now() to support environments that don't have it:
2 | export function now(): number {
3 | return globalThis?.performance?.now() ?? Date.now();
4 | }
5 |
--------------------------------------------------------------------------------
/packages/ai/core/util/remove-text-after-last-whitespace.ts:
--------------------------------------------------------------------------------
1 | import { splitOnLastWhitespace } from './split-on-last-whitespace';
2 |
3 | export function removeTextAfterLastWhitespace(text: string): string {
4 | const match = splitOnLastWhitespace(text);
5 | return match ? match.prefix + match.whitespace : text;
6 | }
7 |
--------------------------------------------------------------------------------
/packages/ai/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "./dist/index.js",
3 | "module": "./dist/index.mjs",
4 | "types": "./dist/index.d.ts",
5 | "exports": "./dist/index.mjs",
6 | "private": true,
7 | "peerDependencies": {
8 | "react": ">=18"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/ai/rsc/index.ts:
--------------------------------------------------------------------------------
1 | export type {
2 | getAIState,
3 | getMutableAIState,
4 | createStreamableUI,
5 | createStreamableValue,
6 | streamUI,
7 | createAI,
8 | } from './rsc-server';
9 |
10 | export type {
11 | readStreamableValue,
12 | useStreamableValue,
13 | useUIState,
14 | useAIState,
15 | useActions,
16 | useSyncUIState,
17 | } from './rsc-client';
18 |
19 | export type { StreamableValue } from './streamable-value/streamable-value';
20 |
--------------------------------------------------------------------------------
/packages/ai/rsc/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "types": "./dist/index.d.ts",
3 | "exports": {
4 | "types": "./dist/index.d.ts",
5 | "react-server": "./dist/rsc-server.mjs",
6 | "import": "./dist/rsc-client.mjs"
7 | },
8 | "private": true,
9 | "peerDependencies": {
10 | "react": ">=18",
11 | "zod": ">=3"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/packages/ai/rsc/rsc-client.ts:
--------------------------------------------------------------------------------
1 | export {
2 | readStreamableValue,
3 | useStreamableValue,
4 | useUIState,
5 | useAIState,
6 | useActions,
7 | useSyncUIState,
8 | } from './rsc-shared.mjs';
9 |
--------------------------------------------------------------------------------
/packages/ai/rsc/rsc-server.ts:
--------------------------------------------------------------------------------
1 | export { getAIState, getMutableAIState } from './ai-state';
2 | export { createAI } from './provider';
3 | export { streamUI } from './stream-ui';
4 | export { createStreamableUI } from './streamable-ui/create-streamable-ui';
5 | export { createStreamableValue } from './streamable-value/create-streamable-value';
6 |
--------------------------------------------------------------------------------
/packages/ai/rsc/rsc-shared.mts:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | export {
4 | readStreamableValue,
5 | useStreamableValue,
6 | useUIState,
7 | useAIState,
8 | useActions,
9 | useSyncUIState,
10 | InternalAIProvider,
11 | } from './shared-client';
12 |
--------------------------------------------------------------------------------
/packages/ai/rsc/shared-client/index.ts:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | export { readStreamableValue } from '../streamable-value/read-streamable-value';
4 | export { useStreamableValue } from '../streamable-value/use-streamable-value';
5 | export {
6 | InternalAIProvider,
7 | useAIState,
8 | useActions,
9 | useSyncUIState,
10 | useUIState,
11 | } from './context';
12 |
--------------------------------------------------------------------------------
/packages/ai/rsc/stream-ui/index.tsx:
--------------------------------------------------------------------------------
1 | export { streamUI } from './stream-ui';
2 |
--------------------------------------------------------------------------------
/packages/ai/rsc/streamable-value/is-streamable-value.ts:
--------------------------------------------------------------------------------
1 | import { STREAMABLE_VALUE_TYPE, StreamableValue } from './streamable-value';
2 |
3 | export function isStreamableValue(value: unknown): value is StreamableValue {
4 | return (
5 | value != null &&
6 | typeof value === 'object' &&
7 | 'type' in value &&
8 | value.type === STREAMABLE_VALUE_TYPE
9 | );
10 | }
11 |
--------------------------------------------------------------------------------
/packages/ai/test/index.ts:
--------------------------------------------------------------------------------
1 | export { convertArrayToReadableStream } from '@ai-sdk/provider-utils/test';
2 | export { MockEmbeddingModelV1 } from '../core/test/mock-embedding-model-v1';
3 | export { mockId } from '../core/test/mock-id';
4 | export { MockLanguageModelV1 } from '../core/test/mock-language-model-v1';
5 | export { mockValues } from '../core/test/mock-values';
6 | export { simulateReadableStream } from '../core/test/simulate-readable-stream';
7 |
--------------------------------------------------------------------------------
/packages/ai/tests/e2e/next-server/app/layout.js:
--------------------------------------------------------------------------------
1 | export const metadata = {
2 | title: 'Next.js',
3 | description: 'Generated by Next.js',
4 | };
5 |
6 | export default function RootLayout({ children }) {
7 | return (
8 |
9 | {children}
10 |
11 | );
12 | }
13 |
--------------------------------------------------------------------------------
/packages/ai/tests/e2e/next-server/app/page.js:
--------------------------------------------------------------------------------
1 | export default function Page() {
2 | return Page
;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/ai/tests/e2e/next-server/app/rsc/client-utils.js:
--------------------------------------------------------------------------------
1 | 'use client';
2 |
3 | export function ClientInfo({ children }) {
4 | return {children}
;
5 | }
6 |
--------------------------------------------------------------------------------
/packages/ai/tests/e2e/next-server/app/rsc/page.js:
--------------------------------------------------------------------------------
1 | import { streamableUI, streamableValue } from './actions';
2 | import { Client } from './client';
3 |
4 | export default function Page() {
5 | return (
6 |
12 | );
13 | }
14 |
--------------------------------------------------------------------------------
/packages/ai/tests/e2e/next-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ai-core-e2e-next-server",
3 | "private": true,
4 | "scripts": {
5 | "dev": "next"
6 | },
7 | "dependencies": {
8 | "next": "canary",
9 | "react": "rc",
10 | "react-dom": "rc",
11 | "ai": "workspace:*"
12 | },
13 | "version": "0.0.0"
14 | }
15 |
--------------------------------------------------------------------------------
/packages/ai/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true,
6 | "lib": ["dom", "dom.iterable", "esnext"],
7 | "types": ["@types/node", "vitest/globals"]
8 | },
9 | "include": ["."],
10 | "exclude": ["*/dist", "dist", "build", "node_modules"]
11 | }
12 |
--------------------------------------------------------------------------------
/packages/ai/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/ai/util/constants.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Warning time for notifying developers that a stream is hanging in dev mode
3 | * using a console.warn.
4 | */
5 | export const HANGING_STREAM_WARNING_TIME_MS = 15 * 1000;
6 |
--------------------------------------------------------------------------------
/packages/ai/util/delay.ts:
--------------------------------------------------------------------------------
1 | export async function delay(delayInMs?: number): Promise {
2 | return delayInMs === undefined
3 | ? Promise.resolve()
4 | : new Promise(resolve => setTimeout(resolve, delayInMs));
5 | }
6 |
--------------------------------------------------------------------------------
/packages/ai/util/is-async-generator.ts:
--------------------------------------------------------------------------------
1 | export function isAsyncGenerator(
2 | value: unknown,
3 | ): value is AsyncGenerator {
4 | return (
5 | value != null && typeof value === 'object' && Symbol.asyncIterator in value
6 | );
7 | }
8 |
--------------------------------------------------------------------------------
/packages/ai/util/is-function.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Checks if the given value is a function.
3 | *
4 | * @param {unknown} value - The value to check.
5 | * @returns {boolean} True if the value is a function, false otherwise.
6 | */
7 | export const isFunction = (value: unknown): value is Function =>
8 | typeof value === 'function';
9 |
--------------------------------------------------------------------------------
/packages/ai/util/is-generator.ts:
--------------------------------------------------------------------------------
1 | export function isGenerator(
2 | value: unknown,
3 | ): value is Generator {
4 | return value != null && typeof value === 'object' && Symbol.iterator in value;
5 | }
6 |
--------------------------------------------------------------------------------
/packages/ai/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts{,x}'],
9 | exclude: [
10 | '**/*.ui.test.ts{,x}',
11 | '**/*.e2e.test.ts{,x}',
12 | '**/node_modules/**',
13 | ],
14 | typecheck: {
15 | enabled: true,
16 | },
17 | },
18 | });
19 |
--------------------------------------------------------------------------------
/packages/ai/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts{,x}'],
9 | exclude: [
10 | '**/*.ui.test.ts{,x}',
11 | '**/*.e2e.test.ts{,x}',
12 | '**/node_modules/**',
13 | ],
14 | typecheck: {
15 | enabled: true,
16 | },
17 | },
18 | });
19 |
--------------------------------------------------------------------------------
/packages/ai/vitest.ui.react.config.js:
--------------------------------------------------------------------------------
1 | import react from '@vitejs/plugin-react';
2 | import { defineConfig } from 'vite';
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [react()],
7 | test: {
8 | environment: 'jsdom',
9 | globals: true,
10 | include: ['rsc/**/*.ui.test.ts{,x}'],
11 | exclude: ['**/node_modules/**'],
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/packages/amazon-bedrock/src/index.ts:
--------------------------------------------------------------------------------
1 | export { bedrock, createAmazonBedrock } from './bedrock-provider';
2 | export type {
3 | AmazonBedrockProvider,
4 | AmazonBedrockProviderSettings,
5 | } from './bedrock-provider';
6 |
--------------------------------------------------------------------------------
/packages/amazon-bedrock/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/amazon-bedrock/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/amazon-bedrock/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/amazon-bedrock/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/amazon-bedrock/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/anthropic/src/index.ts:
--------------------------------------------------------------------------------
1 | export { anthropic, createAnthropic } from './anthropic-provider';
2 | export type {
3 | AnthropicProvider,
4 | AnthropicProviderSettings,
5 | } from './anthropic-provider';
6 |
--------------------------------------------------------------------------------
/packages/anthropic/src/map-anthropic-stop-reason.ts:
--------------------------------------------------------------------------------
1 | import { LanguageModelV1FinishReason } from '@ai-sdk/provider';
2 |
3 | export function mapAnthropicStopReason(
4 | finishReason: string | null | undefined,
5 | ): LanguageModelV1FinishReason {
6 | switch (finishReason) {
7 | case 'end_turn':
8 | case 'stop_sequence':
9 | return 'stop';
10 | case 'tool_use':
11 | return 'tool-calls';
12 | case 'max_tokens':
13 | return 'length';
14 | default:
15 | return 'unknown';
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/anthropic/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/anthropic/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/anthropic/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/anthropic/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/anthropic/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/azure/src/index.ts:
--------------------------------------------------------------------------------
1 | export { azure, createAzure } from './azure-openai-provider';
2 | export type {
3 | AzureOpenAIProvider,
4 | AzureOpenAIProviderSettings,
5 | } from './azure-openai-provider';
6 |
--------------------------------------------------------------------------------
/packages/azure/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/azure/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/azure/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/azure/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/azure/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/codemod/src/codemods/remove-anthropic-facade.ts:
--------------------------------------------------------------------------------
1 | import { API, FileInfo } from 'jscodeshift';
2 | import { removeFacade } from './lib/remove-facade';
3 |
4 | export default function transformer(fileInfo: FileInfo, api: API) {
5 | return removeFacade(fileInfo, api, {
6 | packageName: 'anthropic',
7 | className: 'Anthropic',
8 | createFnName: 'createAnthropic',
9 | });
10 | }
11 |
--------------------------------------------------------------------------------
/packages/codemod/src/codemods/remove-google-facade.ts:
--------------------------------------------------------------------------------
1 | import { API, FileInfo } from 'jscodeshift';
2 | import { removeFacade } from './lib/remove-facade';
3 |
4 | export default function transformer(fileInfo: FileInfo, api: API) {
5 | return removeFacade(fileInfo, api, {
6 | packageName: 'google',
7 | className: 'Google',
8 | createFnName: 'createGoogleGenerativeAI',
9 | });
10 | }
11 |
--------------------------------------------------------------------------------
/packages/codemod/src/codemods/remove-mistral-facade.ts:
--------------------------------------------------------------------------------
1 | import { API, FileInfo } from 'jscodeshift';
2 | import { removeFacade } from './lib/remove-facade';
3 |
4 | export default function transformer(fileInfo: FileInfo, api: API) {
5 | return removeFacade(fileInfo, api, {
6 | packageName: 'mistral',
7 | className: 'Mistral',
8 | createFnName: 'createMistral',
9 | });
10 | }
11 |
--------------------------------------------------------------------------------
/packages/codemod/src/codemods/remove-openai-facade.ts:
--------------------------------------------------------------------------------
1 | import { API, FileInfo } from 'jscodeshift';
2 | import { removeFacade } from './lib/remove-facade';
3 |
4 | export default function transformer(fileInfo: FileInfo, api: API) {
5 | return removeFacade(fileInfo, api, {
6 | packageName: 'openai',
7 | className: 'OpenAI',
8 | createFnName: 'createOpenAI',
9 | });
10 | }
11 |
--------------------------------------------------------------------------------
/packages/codemod/src/lib/transform-options.ts:
--------------------------------------------------------------------------------
1 | export interface TransformOptions {
2 | dry?: boolean;
3 | print?: boolean;
4 | verbose?: boolean;
5 | jscodeshift?: string;
6 | }
7 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-ai-stream-methods-from-stream-text-result.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { streamText } from 'ai';
3 |
4 | async function handler(req, res) {
5 | const stream = await streamText({
6 | model: 'gpt-4',
7 | prompt: 'Hello'
8 | });
9 |
10 | const aiStream = stream.toAIStream();
11 | stream.pipeAIStreamToResponse(res);
12 | return stream.toAIStreamResponse();
13 | }
14 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-anthropic-facade.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { Anthropic } from '@ai-sdk/anthropic';
3 |
4 | const anthropic = new Anthropic({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-anthropic-facade.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { createAnthropic } from '@ai-sdk/anthropic';
3 |
4 | const anthropic = createAnthropic({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-deprecated-provider-registry-exports.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { Provider, experimental_createProviderRegistry } from 'ai';
3 |
4 | function createProvider(): Provider {
5 | return {
6 | languageModel: () => null,
7 | textEmbeddingModel: () => null
8 | };
9 | }
10 |
11 | function createRegistry(): Provider {
12 | return experimental_createProviderRegistry({
13 | test: createProvider()
14 | });
15 | }
16 |
17 | const registry: Provider = createRegistry();
18 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-experimental-message-types.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { CoreMessage, CoreUserMessage, CoreAssistantMessage, CoreToolMessage } from 'ai';
3 |
4 | function processMessage(message: CoreMessage) {
5 | console.log(message);
6 | }
7 |
8 | function handleUser(msg: CoreUserMessage) {
9 | console.log(msg);
10 | }
11 |
12 | const assistant: CoreAssistantMessage = {
13 | role: 'assistant',
14 | content: 'Hello'
15 | };
16 |
17 | type ToolHandler = (msg: CoreToolMessage) => void;
18 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-experimental-tool-not-ai.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { ExperimentalTool } from 'not-ai';
3 |
4 | interface Config {
5 | tool: ExperimentalTool;
6 | }
7 |
8 | const myTool: ExperimentalTool = {
9 | description: 'test',
10 | parameters: {}
11 | };
12 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-experimental-tool-not-ai.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { ExperimentalTool } from 'not-ai';
3 |
4 | interface Config {
5 | tool: ExperimentalTool;
6 | }
7 |
8 | const myTool: ExperimentalTool = {
9 | description: 'test',
10 | parameters: {}
11 | };
12 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-experimental-tool.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { ExperimentalTool } from 'ai';
3 |
4 | interface Config {
5 | tool: ExperimentalTool;
6 | }
7 |
8 | const myTool: ExperimentalTool = {
9 | description: 'test',
10 | parameters: {}
11 | };
12 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-experimental-tool.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { CoreTool } from 'ai';
3 |
4 | interface Config {
5 | tool: CoreTool;
6 | }
7 |
8 | const myTool: CoreTool = {
9 | description: 'test',
10 | parameters: {}
11 | };
12 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-google-facade.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { Google } from '@ai-sdk/google';
3 |
4 | const google = new Google({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-google-facade.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { createGoogleGenerativeAI } from '@ai-sdk/google';
3 |
4 | const google = createGoogleGenerativeAI({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-mistral-facade.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { Mistral } from '@ai-sdk/mistral';
3 |
4 | const mistral = new Mistral({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-mistral-facade.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { createMistral } from '@ai-sdk/mistral';
3 |
4 | const mistral = createMistral({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-openai-facade-as.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import OpenAI from 'openai';
3 | import { OpenAI as AiOpenAI } from '@ai-sdk/openai';
4 |
5 | const client1 = new OpenAI();
6 | const client2 = new AiOpenAI();
7 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-openai-facade-as.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import OpenAI from 'openai';
3 | import { createOpenAI } from '@ai-sdk/openai';
4 |
5 | const client1 = new OpenAI();
6 | const client2 = createOpenAI();
7 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-openai-facade-corp.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import OpenAI from 'openai';
3 |
4 | const openaiClient = new OpenAI({
5 | apiKey: 'key2'
6 | });
7 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-openai-facade-corp.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import OpenAI from 'openai';
3 |
4 | const openaiClient = new OpenAI({
5 | apiKey: 'key2'
6 | });
7 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-openai-facade.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { OpenAI } from '@ai-sdk/openai';
3 |
4 | const openai = new OpenAI({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/remove-openai-facade.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { createOpenAI } from '@ai-sdk/openai';
3 |
4 | const openai = createOpenAI({
5 | apiKey: 'key',
6 | baseURL: 'url',
7 | headers: { 'custom': 'header' }
8 | });
9 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-format-stream-part-not-ai.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { formatStreamPart } from 'not-ai';
3 |
4 | const response = new Response(formatStreamPart('text', cached));
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-format-stream-part-not-ai.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { formatStreamPart } from 'not-ai';
3 |
4 | const response = new Response(formatStreamPart('text', cached));
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-format-stream-part.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { formatStreamPart } from 'ai';
3 |
4 | const response = new Response(formatStreamPart('text', cached));
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-format-stream-part.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { formatDataStreamPart } from 'ai';
3 |
4 | const response = new Response(formatDataStreamPart('text', cached));
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-parse-stream-part-not-ai.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { parseStreamPart } from 'not-ai';
3 |
4 | const result = parseStreamPart(data);
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-parse-stream-part-not-ai.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { parseStreamPart } from 'not-ai';
3 |
4 | const result = parseStreamPart(data);
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-parse-stream-part.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { parseStreamPart } from 'ai';
3 |
4 | const result = parseStreamPart(data);
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rename-parse-stream-part.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { parseDataStreamPart } from 'ai';
3 |
4 | const result = parseDataStreamPart(data);
5 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/replace-langchain-toaistream.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { LangChainAdapter } from 'ai';
3 | import { model } from 'langchain';
4 |
5 | const stream = LangChainAdapter.toAIStream(model.stream(), {
6 | onToken: token => console.log(token)
7 | });
8 |
9 | const response = new Response(stream);
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/replace-langchain-toaistream.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { LangChainAdapter } from 'ai';
3 | import { model } from 'langchain';
4 |
5 | const stream = LangChainAdapter.toDataStream(model.stream(), {
6 | onToken: token => console.log(token)
7 | });
8 |
9 | const response = new Response(stream);
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/replace-token-usage-types.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { TokenUsage, CompletionTokenUsage, EmbeddingTokenUsage } from 'ai';
3 |
4 | function recordUsage(usage: TokenUsage) {
5 | console.log(usage);
6 | }
7 |
8 | function processEmbedding(usage: EmbeddingTokenUsage) {
9 | console.log(usage);
10 | }
11 |
12 | const handler = (data: CompletionTokenUsage) => {
13 | console.log(data);
14 | };
15 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/replace-token-usage-types.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { LanguageModelUsage, LanguageModelUsage, EmbeddingModelUsage } from 'ai';
3 |
4 | function recordUsage(usage: LanguageModelUsage) {
5 | console.log(usage);
6 | }
7 |
8 | function processEmbedding(usage: EmbeddingModelUsage) {
9 | console.log(usage);
10 | }
11 |
12 | const handler = (data: LanguageModelUsage) => {
13 | console.log(data);
14 | };
15 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rewrite-framework-imports-solid.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { useChat } from 'ai/solid';
3 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rewrite-framework-imports-solid.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { useChat } from '@ai-sdk/solid';
3 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rewrite-framework-imports-svelte.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { useChat } from 'ai/svelte';
3 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rewrite-framework-imports-svelte.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { useChat } from '@ai-sdk/svelte';
3 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rewrite-framework-imports-vue.input.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { useChat } from 'ai/vue';
3 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/__testfixtures__/rewrite-framework-imports-vue.output.ts:
--------------------------------------------------------------------------------
1 | // @ts-nocheck
2 | import { useChat } from '@ai-sdk/vue';
3 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/jscodeshift-testUtils.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'jscodeshift/dist/testUtils' {
2 | export function defineTest(
3 | dirName: string,
4 | transformName: string,
5 | options?: any,
6 | testFilePrefix?: string,
7 | testOptions?: any,
8 | ): void;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-ai-stream-methods-from-stream-text-result.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-ai-stream-methods-from-stream-text-result';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-ai-stream-methods-from-stream-text-result', () => {
6 | it('transforms correctly', () => {
7 | testTransform(
8 | transformer,
9 | 'remove-ai-stream-methods-from-stream-text-result',
10 | );
11 | });
12 | });
13 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-anthropic-facade.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-anthropic-facade';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-anthropic-facade', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-anthropic-facade');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-deprecated-provider-registry-exports.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-deprecated-provider-registry-exports';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-deprecated-provider-registry-exports', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-deprecated-provider-registry-exports');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-experimental-ai-fn-exports.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-experimental-ai-fn-exports';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-experimental-ai-fn-exports', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-experimental-ai-fn-exports');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-experimental-message-types.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-experimental-message-types';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-experimental-message-types', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-experimental-message-types');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-experimental-streamdata.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-experimental-streamdata';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-experimental-streamdata', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-experimental-streamdata');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-experimental-tool.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-experimental-tool';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-experimental-tool', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-experimental-tool');
8 | });
9 |
10 | it('does not transform from other packages', () => {
11 | testTransform(transformer, 'remove-experimental-tool-not-ai');
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-experimental-useassistant.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-experimental-useassistant';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-experimental-useassistant', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-experimental-useassistant');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-google-facade.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-google-facade';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-google-facade', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-google-facade');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-isxxxerror.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-isxxxerror';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-isxxxerror', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-isxxxerror');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-metadata-with-headers.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-metadata-with-headers';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-metadata-with-headers', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-metadata-with-headers');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/remove-mistral-facade.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/remove-mistral-facade';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('remove-mistral-facade', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'remove-mistral-facade');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/rename-format-stream-part.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/rename-format-stream-part';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('rename-format-stream-part', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'rename-format-stream-part');
8 | });
9 |
10 | it('does not transform from other packages', () => {
11 | testTransform(transformer, 'rename-format-stream-part-not-ai');
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/rename-parse-stream-part.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/rename-parse-stream-part';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('rename-parse-stream-part', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'rename-parse-stream-part');
8 | });
9 |
10 | it('does not transform from other packages', () => {
11 | testTransform(transformer, 'rename-parse-stream-part-not-ai');
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/replace-baseurl.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/replace-baseurl';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('replace-baseurl', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'replace-baseurl');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/replace-continuation-steps.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/replace-continuation-steps';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('replace-continuation-steps', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'replace-continuation-steps');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/replace-langchain-toaistream.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/replace-langchain-toaistream';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('replace-langchain-toaistream', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'replace-langchain-toaistream');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/replace-nanoid.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/replace-nanoid';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('replace-nanoid', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'replace-nanoid');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/replace-roundtrips-with-maxsteps.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/replace-roundtrips-with-maxsteps';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('replace-roundtrips-with-maxsteps', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'replace-roundtrips-with-maxsteps');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/replace-token-usage-types.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/replace-token-usage-types';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('replace-token-usage-types', () => {
6 | it('transforms correctly', () => {
7 | testTransform(transformer, 'replace-token-usage-types');
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/packages/codemod/src/test/rewrite-framework-imports.test.ts:
--------------------------------------------------------------------------------
1 | import { describe, it } from 'vitest';
2 | import transformer from '../codemods/rewrite-framework-imports';
3 | import { testTransform } from './test-utils';
4 |
5 | describe('rewrite-framework-imports', () => {
6 | for (const framework of ['solid', 'vue', 'svelte'] as const) {
7 | it(`transforms ${framework} correctly`, () => {
8 | testTransform(transformer, `rewrite-framework-imports-${framework}`);
9 | });
10 | }
11 | });
12 |
--------------------------------------------------------------------------------
/packages/codemod/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/codemod/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/bin/codemod.ts'],
6 | outDir: 'dist/bin',
7 | format: ['cjs'],
8 | dts: false,
9 | sourcemap: true,
10 | },
11 | {
12 | entry: ['src/codemods/**/*.ts'],
13 | outDir: 'dist/codemods',
14 | format: ['cjs'],
15 | dts: false,
16 | sourcemap: true,
17 | },
18 | ]);
19 |
--------------------------------------------------------------------------------
/packages/codemod/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/codemod/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config';
2 |
3 | export default defineConfig({
4 | test: {
5 | globals: true,
6 | environment: 'node',
7 | },
8 | });
9 |
--------------------------------------------------------------------------------
/packages/cohere/src/cohere-chat-settings.ts:
--------------------------------------------------------------------------------
1 | // https://docs.cohere.com/docs/models
2 | export type CohereChatModelId =
3 | | 'command-r-plus'
4 | | 'command-r'
5 | | 'command'
6 | | 'command-light'
7 | | (string & {});
8 |
9 | export interface CohereChatSettings {}
10 |
--------------------------------------------------------------------------------
/packages/cohere/src/cohere-error.ts:
--------------------------------------------------------------------------------
1 | import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
2 | import { z } from 'zod';
3 |
4 | const cohereErrorDataSchema = z.object({
5 | message: z.string(),
6 | });
7 |
8 | export type CohereErrorData = z.infer;
9 |
10 | export const cohereFailedResponseHandler = createJsonErrorResponseHandler({
11 | errorSchema: cohereErrorDataSchema,
12 | errorToMessage: data => data.message,
13 | });
14 |
--------------------------------------------------------------------------------
/packages/cohere/src/index.ts:
--------------------------------------------------------------------------------
1 | export { cohere, createCohere } from './cohere-provider';
2 | export type { CohereProvider, CohereProviderSettings } from './cohere-provider';
3 |
--------------------------------------------------------------------------------
/packages/cohere/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/cohere/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/cohere/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/cohere/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/cohere/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/google-vertex/src/google-vertex-embedding-settings.ts:
--------------------------------------------------------------------------------
1 | export type GoogleVertexEmbeddingModelId = 'text-embedding-004' | (string & {});
2 |
3 | export interface GoogleVertexEmbeddingSettings {
4 | /**
5 | * Optional. Optional reduced dimension for the output embedding.
6 | * If set, excessive values in the output embedding are truncated from the end.
7 | */
8 | outputDimensionality?: number;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/google-vertex/src/index.ts:
--------------------------------------------------------------------------------
1 | export { createVertex, vertex } from './google-vertex-provider';
2 | export type {
3 | GoogleVertexProvider,
4 | GoogleVertexProviderSettings,
5 | } from './google-vertex-provider';
6 |
--------------------------------------------------------------------------------
/packages/google-vertex/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/google-vertex/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/google-vertex/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/google-vertex/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/google-vertex/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/google/src/get-model-path.ts:
--------------------------------------------------------------------------------
1 | export function getModelPath(modelId: string): string {
2 | return modelId.includes('/') ? modelId : `models/${modelId}`;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/google/src/google-generative-ai-embedding-settings.ts:
--------------------------------------------------------------------------------
1 | export type GoogleGenerativeAIEmbeddingModelId =
2 | | 'text-embedding-004'
3 | | (string & {});
4 |
5 | export interface GoogleGenerativeAIEmbeddingSettings {
6 | /**
7 | * Optional. Optional reduced dimension for the output embedding.
8 | * If set, excessive values in the output embedding are truncated from the end.
9 | */
10 | outputDimensionality?: number;
11 | }
12 |
--------------------------------------------------------------------------------
/packages/google/src/index.ts:
--------------------------------------------------------------------------------
1 | export { createGoogleGenerativeAI, google } from './google-provider';
2 | export type {
3 | GoogleGenerativeAIProvider,
4 | GoogleGenerativeAIProviderSettings,
5 | } from './google-provider';
6 |
--------------------------------------------------------------------------------
/packages/google/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/google/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/google/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/google/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/google/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/groq/src/get-response-metadata.ts:
--------------------------------------------------------------------------------
1 | export function getResponseMetadata({
2 | id,
3 | model,
4 | created,
5 | }: {
6 | id?: string | undefined | null;
7 | created?: number | undefined | null;
8 | model?: string | undefined | null;
9 | }) {
10 | return {
11 | id: id ?? undefined,
12 | modelId: model ?? undefined,
13 | timestamp: created != null ? new Date(created * 1000) : undefined,
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/packages/groq/src/groq-error.ts:
--------------------------------------------------------------------------------
1 | import { z } from 'zod';
2 | import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
3 |
4 | export const groqErrorDataSchema = z.object({
5 | error: z.object({
6 | message: z.string(),
7 | type: z.string(),
8 | }),
9 | });
10 |
11 | export type GroqErrorData = z.infer;
12 |
13 | export const groqFailedResponseHandler = createJsonErrorResponseHandler({
14 | errorSchema: groqErrorDataSchema,
15 | errorToMessage: data => data.error.message,
16 | });
17 |
--------------------------------------------------------------------------------
/packages/groq/src/index.ts:
--------------------------------------------------------------------------------
1 | export { createGroq, groq } from './groq-provider';
2 | export type { GroqProvider, GroqProviderSettings } from './groq-provider';
3 |
--------------------------------------------------------------------------------
/packages/groq/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/groq/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/groq/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/groq/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/groq/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/mistral/src/get-response-metadata.ts:
--------------------------------------------------------------------------------
1 | export function getResponseMetadata({
2 | id,
3 | model,
4 | created,
5 | }: {
6 | id?: string | undefined | null;
7 | created?: number | undefined | null;
8 | model?: string | undefined | null;
9 | }) {
10 | return {
11 | id: id ?? undefined,
12 | modelId: model ?? undefined,
13 | timestamp: created != null ? new Date(created * 1000) : undefined,
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/packages/mistral/src/index.ts:
--------------------------------------------------------------------------------
1 | export { createMistral, mistral } from './mistral-provider';
2 | export type {
3 | MistralProvider,
4 | MistralProviderSettings,
5 | } from './mistral-provider';
6 |
--------------------------------------------------------------------------------
/packages/mistral/src/map-mistral-finish-reason.ts:
--------------------------------------------------------------------------------
1 | import { LanguageModelV1FinishReason } from '@ai-sdk/provider';
2 |
3 | export function mapMistralFinishReason(
4 | finishReason: string | null | undefined,
5 | ): LanguageModelV1FinishReason {
6 | switch (finishReason) {
7 | case 'stop':
8 | return 'stop';
9 | case 'length':
10 | case 'model_length':
11 | return 'length';
12 | case 'tool_calls':
13 | return 'tool-calls';
14 | default:
15 | return 'unknown';
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/mistral/src/mistral-embedding-settings.ts:
--------------------------------------------------------------------------------
1 | export type MistralEmbeddingModelId = 'mistral-embed' | (string & {});
2 |
3 | export interface MistralEmbeddingSettings {
4 | /**
5 | Override the maximum number of embeddings per call.
6 | */
7 | maxEmbeddingsPerCall?: number;
8 |
9 | /**
10 | Override the parallelism of embedding calls.
11 | */
12 | supportsParallelCalls?: boolean;
13 | }
14 |
--------------------------------------------------------------------------------
/packages/mistral/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/mistral/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/mistral/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/mistral/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/mistral/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/openai/src/get-response-metadata.ts:
--------------------------------------------------------------------------------
1 | export function getResponseMetadata({
2 | id,
3 | model,
4 | created,
5 | }: {
6 | id?: string | undefined | null;
7 | created?: number | undefined | null;
8 | model?: string | undefined | null;
9 | }) {
10 | return {
11 | id: id ?? undefined,
12 | modelId: model ?? undefined,
13 | timestamp: created != null ? new Date(created * 1000) : undefined,
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/packages/openai/src/index.ts:
--------------------------------------------------------------------------------
1 | export { createOpenAI, openai } from './openai-provider';
2 | export type { OpenAIProvider, OpenAIProviderSettings } from './openai-provider';
3 |
--------------------------------------------------------------------------------
/packages/openai/src/internal/index.ts:
--------------------------------------------------------------------------------
1 | export * from '../openai-chat-language-model';
2 | export * from '../openai-chat-settings';
3 | export * from '../openai-completion-language-model';
4 | export * from '../openai-completion-settings';
5 | export * from '../openai-embedding-model';
6 | export * from '../openai-embedding-settings';
7 |
--------------------------------------------------------------------------------
/packages/openai/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/openai/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | {
11 | entry: ['src/internal/index.ts'],
12 | outDir: 'internal/dist',
13 | format: ['cjs', 'esm'],
14 | dts: true,
15 | sourcemap: true,
16 | },
17 | ]);
18 |
--------------------------------------------------------------------------------
/packages/openai/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/openai/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/openai/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/provider-utils/.gitignore:
--------------------------------------------------------------------------------
1 | # test distribution folder:
2 | ./test
--------------------------------------------------------------------------------
/packages/provider-utils/README.md:
--------------------------------------------------------------------------------
1 | # AI SDK - Provider Implementation Utilities
2 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/combine-headers.ts:
--------------------------------------------------------------------------------
1 | export function combineHeaders(
2 | ...headers: Array | undefined>
3 | ): Record {
4 | return headers.reduce(
5 | (combinedHeaders, currentHeaders) => ({
6 | ...combinedHeaders,
7 | ...(currentHeaders ?? {}),
8 | }),
9 | {},
10 | ) as Record;
11 | }
12 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/extract-response-headers.ts:
--------------------------------------------------------------------------------
1 | /**
2 | Extracts the headers from a response object and returns them as a key-value object.
3 |
4 | @param response - The response object to extract headers from.
5 | @returns The headers as a key-value object.
6 | */
7 | export function extractResponseHeaders(
8 | response: Response,
9 | ): Record {
10 | const headers: Record = {};
11 | response.headers.forEach((value, key) => {
12 | headers[key] = value;
13 | });
14 | return headers;
15 | }
16 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/fetch-function.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Fetch function type (standardizes the version of fetch used).
3 | */
4 | export type FetchFunction = typeof globalThis.fetch;
5 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/get-error-message.ts:
--------------------------------------------------------------------------------
1 | export function getErrorMessage(error: unknown | undefined) {
2 | if (error == null) {
3 | return 'unknown error';
4 | }
5 |
6 | if (typeof error === 'string') {
7 | return error;
8 | }
9 |
10 | if (error instanceof Error) {
11 | return error.message;
12 | }
13 |
14 | return JSON.stringify(error);
15 | }
16 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/is-abort-error.ts:
--------------------------------------------------------------------------------
1 | export function isAbortError(error: unknown): error is Error {
2 | return (
3 | error instanceof Error &&
4 | (error.name === 'AbortError' || error.name === 'TimeoutError')
5 | );
6 | }
7 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/remove-undefined-entries.ts:
--------------------------------------------------------------------------------
1 | export function removeUndefinedEntries(
2 | record: Record,
3 | ): Record {
4 | return Object.fromEntries(
5 | Object.entries(record).filter(([_key, value]) => value != null),
6 | ) as Record;
7 | }
8 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/test/convert-array-to-async-iterable.ts:
--------------------------------------------------------------------------------
1 | export function convertArrayToAsyncIterable(values: T[]): AsyncIterable {
2 | return {
3 | async *[Symbol.asyncIterator]() {
4 | for (const value of values) {
5 | yield value;
6 | }
7 | },
8 | };
9 | }
10 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/test/convert-array-to-readable-stream.ts:
--------------------------------------------------------------------------------
1 | export function convertArrayToReadableStream(
2 | values: T[],
3 | ): ReadableStream {
4 | return new ReadableStream({
5 | start(controller) {
6 | try {
7 | for (const value of values) {
8 | controller.enqueue(value);
9 | }
10 | } finally {
11 | controller.close();
12 | }
13 | },
14 | });
15 | }
16 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/test/convert-async-iterable-to-array.ts:
--------------------------------------------------------------------------------
1 | export async function convertAsyncIterableToArray(
2 | iterable: AsyncIterable,
3 | ): Promise {
4 | const result: T[] = [];
5 | for await (const item of iterable) {
6 | result.push(item);
7 | }
8 | return result;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/test/convert-readable-stream-to-array.ts:
--------------------------------------------------------------------------------
1 | export async function convertReadableStreamToArray(
2 | stream: ReadableStream,
3 | ): Promise {
4 | const reader = stream.getReader();
5 | const result: T[] = [];
6 |
7 | while (true) {
8 | const { done, value } = await reader.read();
9 | if (done) break;
10 | result.push(value);
11 | }
12 |
13 | return result;
14 | }
15 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/test/convert-response-stream-to-array.ts:
--------------------------------------------------------------------------------
1 | import { convertReadableStreamToArray } from './convert-readable-stream-to-array';
2 |
3 | export async function convertResponseStreamToArray(
4 | response: Response,
5 | ): Promise {
6 | return convertReadableStreamToArray(
7 | response.body!.pipeThrough(new TextDecoderStream()),
8 | );
9 | }
10 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/test/index.ts:
--------------------------------------------------------------------------------
1 | export * from './convert-array-to-async-iterable';
2 | export * from './convert-array-to-readable-stream';
3 | export * from './convert-async-iterable-to-array';
4 | export * from './convert-readable-stream-to-array';
5 | export * from './convert-response-stream-to-array';
6 | export * from './json-test-server';
7 | export * from './streaming-test-server';
8 | export * from './test-server';
9 |
--------------------------------------------------------------------------------
/packages/provider-utils/src/without-trailing-slash.ts:
--------------------------------------------------------------------------------
1 | export function withoutTrailingSlash(url: string | undefined) {
2 | return url?.replace(/\/$/, '');
3 | }
4 |
--------------------------------------------------------------------------------
/packages/provider-utils/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/provider-utils/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | {
11 | entry: ['src/test/index.ts'],
12 | outDir: 'test/dist',
13 | format: ['cjs', 'esm'],
14 | dts: true,
15 | sourcemap: true,
16 | },
17 | ]);
18 |
--------------------------------------------------------------------------------
/packages/provider-utils/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/provider-utils/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/provider-utils/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/provider/README.md:
--------------------------------------------------------------------------------
1 | # AI SDK - Provider Language Model Specification
2 |
--------------------------------------------------------------------------------
/packages/provider/src/embedding-model/index.ts:
--------------------------------------------------------------------------------
1 | export * from './v1/index';
2 |
--------------------------------------------------------------------------------
/packages/provider/src/embedding-model/v1/embedding-model-v1-embedding.ts:
--------------------------------------------------------------------------------
1 | /**
2 | An embedding is a vector, i.e. an array of numbers.
3 | It is e.g. used to represent a text as a vector of word embeddings.
4 | */
5 | export type EmbeddingModelV1Embedding = Array;
6 |
--------------------------------------------------------------------------------
/packages/provider/src/embedding-model/v1/index.ts:
--------------------------------------------------------------------------------
1 | export * from './embedding-model-v1';
2 | export * from './embedding-model-v1-embedding';
3 |
--------------------------------------------------------------------------------
/packages/provider/src/errors/get-error-message.ts:
--------------------------------------------------------------------------------
1 | export function getErrorMessage(error: unknown | undefined) {
2 | if (error == null) {
3 | return 'unknown error';
4 | }
5 |
6 | if (typeof error === 'string') {
7 | return error;
8 | }
9 |
10 | if (error instanceof Error) {
11 | return error.message;
12 | }
13 |
14 | return JSON.stringify(error);
15 | }
16 |
--------------------------------------------------------------------------------
/packages/provider/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './embedding-model/index';
2 | export * from './errors/index';
3 | export * from './json-value/index';
4 | export * from './language-model/index';
5 | export * from './provider/index';
6 |
7 | export type { JSONSchema7, JSONSchema7Definition } from 'json-schema';
8 |
--------------------------------------------------------------------------------
/packages/provider/src/json-value/index.ts:
--------------------------------------------------------------------------------
1 | export { isJSONArray, isJSONObject, isJSONValue } from './is-json';
2 | export type { JSONArray, JSONObject, JSONValue } from './json-value';
3 |
--------------------------------------------------------------------------------
/packages/provider/src/json-value/json-value.ts:
--------------------------------------------------------------------------------
1 | export type JSONValue =
2 | | null
3 | | string
4 | | number
5 | | boolean
6 | | JSONObject
7 | | JSONArray;
8 |
9 | export type JSONObject = {
10 | [key: string]: JSONValue;
11 | };
12 |
13 | export type JSONArray = JSONValue[];
14 |
--------------------------------------------------------------------------------
/packages/provider/src/language-model/index.ts:
--------------------------------------------------------------------------------
1 | export * from './v1/index';
2 |
--------------------------------------------------------------------------------
/packages/provider/src/language-model/v1/language-model-v1-function-tool-call.ts:
--------------------------------------------------------------------------------
1 | export type LanguageModelV1FunctionToolCall = {
2 | toolCallType: 'function';
3 | toolCallId: string;
4 | toolName: string;
5 |
6 | /**
7 | Stringified JSON object with the tool call arguments. Must match the
8 | parameters schema of the tool.
9 | */
10 | args: string;
11 | };
12 |
--------------------------------------------------------------------------------
/packages/provider/src/language-model/v1/language-model-v1-logprobs.ts:
--------------------------------------------------------------------------------
1 | /**
2 | Log probabilities for each token and its top log probabilities.
3 | */
4 | export type LanguageModelV1LogProbs = Array<{
5 | token: string;
6 | logprob: number;
7 | topLogprobs: Array<{
8 | token: string;
9 | logprob: number;
10 | }>;
11 | }>;
12 |
--------------------------------------------------------------------------------
/packages/provider/src/language-model/v1/language-model-v1-tool-choice.ts:
--------------------------------------------------------------------------------
1 | export type LanguageModelV1ToolChoice =
2 | | { type: 'auto' } // the tool selection is automatic (can be no tool)
3 | | { type: 'none' } // no tool must be selected
4 | | { type: 'required' } // one of the available tools must be selected
5 | | { type: 'tool'; toolName: string }; // a specific tool must be selected:
6 |
--------------------------------------------------------------------------------
/packages/provider/src/provider/index.ts:
--------------------------------------------------------------------------------
1 | export * from './v1/index';
2 |
--------------------------------------------------------------------------------
/packages/provider/src/provider/v1/index.ts:
--------------------------------------------------------------------------------
1 | export type { ProviderV1 } from './provider-v1';
2 |
--------------------------------------------------------------------------------
/packages/provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/provider/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/provider/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/react/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['vercel-ai'],
4 | };
5 |
--------------------------------------------------------------------------------
/packages/react/README.md:
--------------------------------------------------------------------------------
1 | # AI SDK: React provider
2 |
3 | [React](https://react.dev/) UI components for the [AI SDK](https://sdk.vercel.ai/docs):
4 |
5 | - [`useChat`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-chat) hook
6 | - [`useCompletion`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion) hook
7 | - [`useAssistant`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-assistant) hook
8 |
--------------------------------------------------------------------------------
/packages/react/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './use-assistant';
2 | export * from './use-chat';
3 | export * from './use-completion';
4 | export * from './use-object';
5 |
--------------------------------------------------------------------------------
/packages/react/src/throttle.ts:
--------------------------------------------------------------------------------
1 | import throttleFunction from 'throttleit';
2 |
3 | export function throttle any>(
4 | fn: T,
5 | waitMs: number | undefined,
6 | ): T {
7 | return waitMs != null ? throttleFunction(fn, waitMs) : fn;
8 | }
9 |
--------------------------------------------------------------------------------
/packages/react/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["*/dist", "dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/react/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | outDir: 'dist',
7 | banner: {},
8 | format: ['cjs', 'esm'],
9 | external: ['vue'],
10 | dts: true,
11 | sourcemap: true,
12 | },
13 | ]);
14 |
--------------------------------------------------------------------------------
/packages/react/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/react/vitest.config.js:
--------------------------------------------------------------------------------
1 | import react from '@vitejs/plugin-react';
2 | import { defineConfig } from 'vite';
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [react()],
7 | test: {
8 | environment: 'jsdom',
9 | globals: true,
10 | include: ['src/**/*.ui.test.ts', 'src/**/*.ui.test.tsx'],
11 | },
12 | });
13 |
--------------------------------------------------------------------------------
/packages/solid/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['vercel-ai'],
4 | rules: {
5 | 'react-hooks/rules-of-hooks': 'off',
6 | },
7 | };
8 |
--------------------------------------------------------------------------------
/packages/solid/README.md:
--------------------------------------------------------------------------------
1 | # AI SDK: Solid.js provider
2 |
3 | [Solid.js](https://www.solidjs.com/) UI components for the [AI SDK](https://sdk.vercel.ai/docs):
4 |
5 | - [`useChat`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-chat) hook
6 | - [`useCompletion`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion) hook
7 |
--------------------------------------------------------------------------------
/packages/solid/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './use-chat';
2 | export * from './use-completion';
3 |
--------------------------------------------------------------------------------
/packages/solid/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "./dist/index.js",
3 | "module": "./dist/index.mjs",
4 | "types": "./dist/index.d.ts",
5 | "exports": "./dist/index.mjs",
6 | "private": true,
7 | "peerDependencies": {
8 | "solid-js": "*"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/solid/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["*/dist", "dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/solid/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | outDir: 'dist',
7 | banner: {},
8 | format: ['cjs', 'esm'],
9 | external: ['vue'],
10 | dts: true,
11 | sourcemap: true,
12 | },
13 | ]);
14 |
--------------------------------------------------------------------------------
/packages/solid/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['vercel-ai'],
4 | };
5 |
--------------------------------------------------------------------------------
/packages/svelte/README.md:
--------------------------------------------------------------------------------
1 | # AI SDK: Svelte provider
2 |
3 | [Svelte](https://svelte.dev/) UI components for the [AI SDK](https://sdk.vercel.ai/docs):
4 |
5 | - [`useChat`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-chat) hook
6 | - [`useCompletion`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion) hook
7 | - [`useAssistant`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-assistant) hook
8 |
--------------------------------------------------------------------------------
/packages/svelte/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './use-chat';
2 | export * from './use-completion';
3 | export * from './use-assistant';
4 |
--------------------------------------------------------------------------------
/packages/svelte/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "./dist/index.js",
3 | "module": "./dist/index.mjs",
4 | "types": "./dist/index.d.ts",
5 | "exports": "./dist/index.mjs",
6 | "private": true,
7 | "peerDependencies": {
8 | "svelte": "*"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/svelte/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["*/dist", "dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/svelte/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | outDir: 'dist',
7 | banner: {},
8 | format: ['cjs', 'esm'],
9 | external: ['vue'],
10 | dts: true,
11 | sourcemap: true,
12 | },
13 | ]);
14 |
--------------------------------------------------------------------------------
/packages/svelte/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/swarm/src/index.ts:
--------------------------------------------------------------------------------
1 | export { Agent } from './agent';
2 | export type { AgentTool, AgentFunctionTool, AgentHandoverTool } from './agent';
3 | export { functionTool, handoverTool } from './agent';
4 | export { runSwarm } from './run-swarm';
5 |
--------------------------------------------------------------------------------
/packages/swarm/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/swarm/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | ]);
11 |
--------------------------------------------------------------------------------
/packages/swarm/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/ui-utils/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['vercel-ai'],
4 | };
5 |
--------------------------------------------------------------------------------
/packages/ui-utils/.gitignore:
--------------------------------------------------------------------------------
1 | # test distribution folder:
2 | ./test
--------------------------------------------------------------------------------
/packages/ui-utils/README.md:
--------------------------------------------------------------------------------
1 | # AI SDK - UI Framework Integration Implementation Utilities
2 |
3 | Important: this is an internal API. Expect breaking changes.
4 |
--------------------------------------------------------------------------------
/packages/ui-utils/src/data-url.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts a data URL of type text/* to a text string.
3 | */
4 | export function getTextFromDataUrl(dataUrl: string): string {
5 | const [header, base64Content] = dataUrl.split(',');
6 | const mimeType = header.split(';')[0].split(':')[1];
7 |
8 | if (mimeType == null || base64Content == null) {
9 | throw new Error('Invalid data URL format');
10 | }
11 |
12 | try {
13 | return window.atob(base64Content);
14 | } catch (error) {
15 | throw new Error(`Error decoding data URL`);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/ui-utils/src/process-text-stream.ts:
--------------------------------------------------------------------------------
1 | export async function processTextStream({
2 | stream,
3 | onTextPart,
4 | }: {
5 | stream: ReadableStream;
6 | onTextPart: (chunk: string) => Promise | void;
7 | }): Promise {
8 | const reader = stream.pipeThrough(new TextDecoderStream()).getReader();
9 | while (true) {
10 | const { done, value } = await reader.read();
11 | if (done) {
12 | break;
13 | }
14 | await onTextPart(value);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/packages/ui-utils/src/test/create-data-protocol-stream.ts:
--------------------------------------------------------------------------------
1 | import { convertArrayToReadableStream } from '@ai-sdk/provider-utils/test';
2 | import { DataStreamString } from '../data-stream-parts';
3 |
4 | export function createDataProtocolStream(
5 | dataPartTexts: DataStreamString[],
6 | ): ReadableStream {
7 | const encoder = new TextEncoder();
8 | return convertArrayToReadableStream(
9 | dataPartTexts.map(part => encoder.encode(part)),
10 | );
11 | }
12 |
--------------------------------------------------------------------------------
/packages/ui-utils/src/test/index.ts:
--------------------------------------------------------------------------------
1 | export * from './mock-fetch';
2 |
--------------------------------------------------------------------------------
/packages/ui-utils/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/ui-utils/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | format: ['cjs', 'esm'],
7 | dts: true,
8 | sourcemap: true,
9 | },
10 | {
11 | entry: ['src/test/index.ts'],
12 | outDir: 'test/dist',
13 | format: ['cjs', 'esm'],
14 | external: ['vitest'],
15 | dts: true,
16 | sourcemap: true,
17 | },
18 | ]);
19 |
--------------------------------------------------------------------------------
/packages/ui-utils/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/ui-utils/vitest.edge.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'edge-runtime',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/ui-utils/vitest.node.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 |
3 | // https://vitejs.dev/config/
4 | export default defineConfig({
5 | test: {
6 | environment: 'node',
7 | globals: true,
8 | include: ['**/*.test.ts', '**/*.test.tsx'],
9 | },
10 | });
11 |
--------------------------------------------------------------------------------
/packages/vue/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: ['vercel-ai'],
4 | };
5 |
--------------------------------------------------------------------------------
/packages/vue/README.md:
--------------------------------------------------------------------------------
1 | # AI SDK: Vue.js provider
2 |
3 | [Vue.js](https://vuejs.org/) UI components for the [AI SDK](https://sdk.vercel.ai/docs):
4 |
5 | - [`useChat`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-chat) composable
6 | - [`useCompletion`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion) composable
7 | - [`useAssistant`](https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-assistant) composable
8 |
--------------------------------------------------------------------------------
/packages/vue/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './use-chat';
2 | export * from './use-completion';
3 | export * from './use-assistant';
4 |
--------------------------------------------------------------------------------
/packages/vue/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "./dist/index.js",
3 | "module": "./dist/index.mjs",
4 | "types": "./dist/index.d.ts",
5 | "exports": "./dist/index.mjs",
6 | "private": true,
7 | "peerDependencies": {
8 | "vue": "*"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/vue/src/shims-vue.d.ts:
--------------------------------------------------------------------------------
1 | // required for vue testing library
2 | declare module '*.vue' {
3 | import Vue from 'vue';
4 | export default Vue;
5 | }
6 |
--------------------------------------------------------------------------------
/packages/vue/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./node_modules/@vercel/ai-tsconfig/react-library.json",
3 | "compilerOptions": {
4 | "target": "ES2018",
5 | "stripInternal": true
6 | },
7 | "include": ["."],
8 | "exclude": ["*/dist", "dist", "build", "node_modules"]
9 | }
10 |
--------------------------------------------------------------------------------
/packages/vue/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'tsup';
2 |
3 | export default defineConfig([
4 | {
5 | entry: ['src/index.ts'],
6 | outDir: 'dist',
7 | banner: {},
8 | format: ['cjs', 'esm'],
9 | external: ['vue'],
10 | dts: true,
11 | sourcemap: true,
12 | },
13 | ]);
14 |
--------------------------------------------------------------------------------
/packages/vue/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "//"
4 | ],
5 | "tasks": {
6 | "build": {
7 | "outputs": [
8 | "**/dist/**"
9 | ]
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/vue/vitest.config.js:
--------------------------------------------------------------------------------
1 | import vue from '@vitejs/plugin-vue';
2 | import { defineConfig } from 'vite';
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [vue()],
7 | test: {
8 | environment: 'jsdom',
9 | globals: true,
10 | include: ['src/**/*.ui.test.ts', 'src/**/*.ui.test.tsx'],
11 | },
12 | });
13 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - 'apps/*'
3 | - 'packages/*'
4 | - 'tools/*'
5 | - 'examples/*'
6 | - 'packages/ai/tests/e2e/next-server'
7 |
--------------------------------------------------------------------------------
/socket.yaml:
--------------------------------------------------------------------------------
1 | # top level version field is required
2 | version: 2
3 |
4 | githubApp:
5 | enabled: true
6 | pullRequestAlertsEnabled: false
7 | dependencyOverviewEnabled: false
8 | projectReportsEnabled: true
9 |
10 | projectIgnorePaths:
11 | - '.github/'
12 | - 'examples/'
13 |
--------------------------------------------------------------------------------
/tools/eslint-config/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['next', 'turbo', 'prettier'],
3 | rules: {
4 | '@next/next/no-html-link-for-pages': 'off',
5 | },
6 | parserOptions: {
7 | babelOptions: {
8 | presets: [require.resolve('next/babel')],
9 | },
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/tools/eslint-config/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-config-vercel-ai",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "main": "index.js",
6 | "dependencies": {
7 | "eslint-config-next": "^14.2.3",
8 | "eslint-config-prettier": "^9.1.0",
9 | "eslint-config-turbo": "^2.3.0",
10 | "eslint-plugin-react": "7.34.1"
11 | },
12 | "publishConfig": {
13 | "access": "public"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/tools/tsconfig/node14.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "Node 14",
4 | "extends": "./base.json",
5 | "compilerOptions": {
6 | "lib": ["ES2020"],
7 | "module": "commonjs",
8 | "target": "ES2020"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/tools/tsconfig/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vercel/ai-tsconfig",
3 | "version": "0.0.0",
4 | "private": true,
5 | "license": "MIT",
6 | "publishConfig": {
7 | "access": "public"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tools/tsconfig/react-library.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "display": "React Library",
4 | "extends": "./base.json",
5 | "compilerOptions": {
6 | "jsx": "react-jsx",
7 | "lib": ["dom", "ES2015"],
8 | "module": "ESNext",
9 | "target": "es6"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------