
Develop Ai Functions Example
Maintain and extend AI SDK provider examples under examples/ai-functions when you need reproducible scripts for generateText, streamText, agents, and embeddings.
Install
npx skills add https://github.com/vercel-labs/ai --skill develop-ai-functions-exampleWhat is this skill?
- 10 example category folders under examples/ai-functions/src (generate-text, stream-text, generate-object, stream-object,
- Run and modify scripts to validate provider support and demonstrate features
- Creates test fixtures aligned with each AI SDK function
- Marked internal in metadata—intended for SDK contributors and advanced integrators
- Organized by function: non-streaming vs streaming text, structured objects, agents, embeddings, image, speech, transcrip
Adoption & trust: 56 installs on skills.sh; 24.7k GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Journey fit
Example scripts live in the AI SDK repo and exist to exercise SDK APIs during product and library development—not a ship or launch activity. Maps to agent-tooling because examples cover ToolLoopAgent, streaming, structured output, and multimodal SDK surfaces agents rely on.
Common Questions / FAQ
Is Develop Ai Functions Example safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Develop Ai Functions Example
## 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()` | | `transcribe/` | Audio transcription with `transcribe()` | | `rerank/` | Document reranking with `rerank()` | | `middleware/` | Custom middleware implementations | | `registry/` | Provider registry setup and usage | | `telemetry/` | OpenTelemetry integration | | `complex/` | Multi-component examples (agents, routers) | | `lib/` | Shared utilities (not examples) | | `tools/` | Reusable tool definitions | ## File Naming Convention Examples follow the pattern: `{provider}-{feature}.ts` | Pattern | Example | Description | | ---------------------------------------- | ------------------------------------------ | -------------------------- | | `{provider}.ts` | `openai.ts` | Basic provider usage | | `{provider}-{feature}.ts` | `openai-tool-call.ts` | Specific feature | | `{provider}-{sub-provider}.ts` | `amazon-bedrock-anthropic.ts` | Provider with sub-provider | | `{provider}-{sub-provider}-{feature}.ts` | `google-vertex-anthropic-cache-control.ts` | Sub-provider with feature | ## Example Structure All examples use the `run()` wrapper from `lib/run.ts` which: - Loads environment variables from `.env` - Provides error handling with detailed API error logging ### Basic Template ```typescript import { providerName } from '@ai-sdk/provider-name'; import { generateText } from 'ai'; import { run } from '../lib/run'; run(async () => { const result = await generateText({ model: providerName('model-id'), prompt: 'Your prompt here.', }); console.log(result.text); console.log('Token usage:', result.usage); console.log('Finish reason:', result.finishReason); }); ``` ### Streaming Template ```typescript import { providerName } from '@ai-sdk/provider-name'; import { streamText } from 'ai'; import { printFullStream } from '../lib/print-full-stream'; import { run } from '../lib/run'; run(async () => { const result = streamText({ model: providerName('model-id'), prompt: 'Your prompt here.', }); await printFullStream({ result }); }); ``` ### Tool Calling Template ```typescript import { providerName } from '@ai-sdk/provider-name'; import { generateText, tool } from 'ai'; import { z } from 'zod'; import { run