develop-ai-functions-example
Development and validation scripts for AI SDK functions across multiple providers and capabilities.
- Organized by AI SDK function category (text generation, streaming, structured output, embeddings, image generation, speech, transcription, reranking, and agents)
- File naming convention maps provider and feature combinations (e.g.,
openai-tool-call.ts,amazon-bedrock-anthropic-cache-control.ts) for quick identification - Includes shared utility helpers for error handling, environment loading, streaming output formatting, and test fixture generation
- Templates provided for common patterns: basic generation, streaming, tool calling, and structured output with Zod schemas
AI Functions Examples
The examples/ai-functions/ directory contains scripts for validating, testing, and iterating on AI SDK functions across providers.
Example Categories
Examples are organized by AI SDK function in examples/ai-functions/src/:
| Directory | Purpose |
|---|---|
generate-text/ |
Non-streaming text generation with generateText() |
stream-text/ |
Streaming text generation with streamText() |
generate-object/ |
Structured output generation with generateObject() |
stream-object/ |
Streaming structured output with streamObject() |
agent/ |
ToolLoopAgent examples for agentic workflows |
embed/ |
Single embedding generation with embed() |
embed-many/ |
Batch embedding generation with embedMany() |
generate-image/ |
Image generation with generateImage() |
generate-speech/ |
Text-to-speech with generateSpeech() |
More from vercel/ai
ai-sdk
Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".
25.8Kcapture-api-response-test-fixture
Capture API response test fixture.
734list-npm-package-content
List the contents of an npm package tarball before publishing. Use when the user wants to see what files are included in an npm bundle, verify package contents, or debug npm publish issues.
692adr-skill
Create and maintain Architecture Decision Records (ADRs) optimized for agentic coding workflows. Use when you need to propose, write, update, accept/reject, deprecate, or supersede an ADR; bootstrap an adr folder and index; consult existing ADRs before implementing changes; or enforce ADR conventions. This skill uses Socratic questioning to capture intent before drafting, and validates output against an agent-readiness checklist.
453add-provider-package
Guide for adding new AI provider packages to the AI SDK. Use when creating a new @ai-sdk/<provider> package to integrate an AI service into the SDK.
443update-provider-models
Add new or remove obsolete model IDs for existing AI SDK providers. Use when adding a model to a provider, removing an obsolete model, or processing a list of model changes from an issue. Triggers on "add model", "remove model", "new model ID", "obsolete model", "update model IDs".
126