develop-ai-functions-example_skill

This skill helps validate and demonstrate AI SDK functions by providing structured examples, tests, and fixtures across providers.
  • TypeScript
  • Official

22.3k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill vercel/ai --skill develop-ai-functions-example

  • SKILL.md7.7 KB

Overview

This skill provides a collection of concrete TypeScript examples for the AI SDK functions, organized under examples/ai-functions/src. It helps you create, run, and modify example scripts that validate provider support, demonstrate SDK features, and produce test fixtures. The examples cover text, streaming, structured outputs, embeddings, images, speech, transcription, reranking, agents, middleware, and telemetry.

How this skill works

Each example follows a consistent template that loads environment variables, wraps execution with run() for error handling, and calls a focused SDK function (generateText, streamText, generateObject, etc.). Files are named by provider and feature (e.g., provider-feature.ts) so you can quickly find or add examples. Utility helpers under lib/ provide printing, streaming visualization, saving raw chunks, and other developer conveniences used by examples.

When to use it

  • Adding a new provider: provide basic examples for core APIs (generateText, streamText, generateObject, etc.).
  • Implementing a new feature: include at least one provider example demonstrating the feature in practice.
  • Reproducing a bug: create a minimal example that reproduces the issue for debugging and CI tests.
  • Documenting provider-specific options: show how to pass providerOptions and any sub-provider configuration.
  • Creating test fixtures: generate API response fixtures or save streaming chunks for tests.

Best practices

  • Keep each example focused on a single feature or behavior to make intent and debugging clear.
  • Use descriptive prompts so outputs demonstrate the behavior being validated.
  • Leverage run() to standardize .env loading and error handling across examples.
  • Reuse tools and utilities (tools/, lib/) rather than duplicating logic across examples.
  • Use realistic model IDs and provider options to ensure examples run reliably during local testing.

Example use cases

  • Non-streaming text generation example using generateText for basic prompt testing.
  • Streaming text example using streamText and printFullStream to inspect intermediate chunks and tool calls.
  • Structured output example with generateObject and zod schema to validate parsed objects.
  • Agent/example using ToolLoopAgent to demonstrate tool calling and agent decision trace.
  • Embedding and batch embedding examples with embed() and embedMany() to validate vector output and shapes.
  • Image and speech generation examples to show media generation and saving outputs to disk.

FAQ

Examples are grouped by SDK function in src (generate-text, stream-text, generate-object, etc.) and follow a provider-feature file naming convention.

What utilities should I use in new examples?

Use the run() wrapper for env and error handling, print utilities for clean output, and printFullStream or save-raw-chunks for streaming scenarios.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
develop-ai-functions-example skill by vercel/ai | VeilStrat