add-function-examples

Creates AI function examples in examples/ai-functions for testing features against provider APIs.

26.5k|5.1k|Updated May 23, 2023
One-click install
npx skills add https://github.com/vercel/ai --skill add-function-examples
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-function-examples
Source: https://github.com/vercel/ai/tree/main/skills/add-function-examples
Command: npx skills add https://github.com/vercel/ai --skill add-function-examples

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When new features or bug fixes land in the AI SDK, there is no systematic way to verify them against real provider APIs or to document usage for developers. This Skill reviews branch changes and adds the appropriate runnable examples to the examples/ai-functions directory.

Core Features & Use Cases

  • Change-Driven Example Creation: Reviews the current branch to identify new or modified features that need example coverage.
  • Model-Aware Variants: Adds generateText and streamText variants for language models, or the relevant top-level function (generateImage, generateSpeech) for other model kinds.
  • Type Safety Verification: Runs pnpm type-check:full after creating examples and fixes any errors encountered.
  • Use Case: After implementing a new streaming feature for a language model, use this Skill to generate both generateText and streamText examples that exercise the feature against the actual provider API.

Quick Start

Review the changes in my current branch and add appropriate function examples to examples/ai-functions for any new or modified features.

Frequently Asked Questions about add-function-examples

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add examples for new AI SDK features?

Review the changes in your current branch to identify new or modified features, then add examples to the examples/ai-functions directory. For language models, create both generateText and streamText variants; for other model kinds, use the relevant top-level function like generateImage or generateSpeech.

What are AI function examples used for in the Vercel AI SDK?

Function examples in examples/ai-functions test specific features against actual provider APIs rather than mocks. They also serve as documentation showing users how to call top-level functions like generateText, streamText, generateImage, and generateSpeech.

Which top-level function should I use for non-language models?

Use the top-level function matching the model kind: generateImage for image models and generateSpeech for speech models. Only language models require the dual generateText and streamText example variants.

How do I verify my new examples are type-safe?

Run pnpm type-check:full after creating the example. This performs a full type check across the repository, and any errors encountered must be fixed before the example is considered complete.

When should I not add a function example?

Skip examples for changes that do not affect user-facing features or provider API behavior, such as internal refactors or documentation-only edits. Examples are intended for features and bug fixes that benefit from real API testing.