Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
bjornmelin avatar

Ai Sdk Core

  • 9 installs
  • 5 repo stars
  • Updated August 5, 2026
  • bjornmelin/dev-skills

Ai-sdk-core is a Claude Code skill giving expert guidance for AI SDK Core text generation, structured data, tool calling, embeddings, and MCP integration.

About

Ai-sdk-core is a Claude Code skill for building with AI SDK Core: generating text and structured output, tool calling, embeddings and reranking, MCP integration, middleware, telemetry, and error handling. It provides a function-selection table (generateText, streamText, generateObject, streamObject, embed, rerank) and patterns for typed and dynamic tools, multi-step execution, and provider setup. Developers use it to wire LLM calls, tools, and MCP servers with a consistent API across providers.

  • Guidance for AI SDK Core: text, structured data, tool calling, embeddings, reranking
  • Covers MCP integration via createMCPClient and stdio/HTTP transports
  • Includes middleware, telemetry, provider setup, and error handling

Ai Sdk Core by the numbers

  • 9 all-time installs (skills.sh)
  • Ranked #12,152 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

ai-sdk-core capabilities & compatibility

Free skill; requires a model provider API key (e.g. OpenAI or Anthropic) to run the generated calls.

Capabilities
api development · orchestration
Works with
openai · anthropic · vercel
Use cases
api development · orchestration
Pricing
Bring your own API key
From the docs

What ai-sdk-core says it does

Use AI SDK Core to generate text/structured output, call tools, and connect to MCP servers with consistent APIs across providers.
SKILL.md
Use `createMCPClient()` to load MCP tools, resources, and prompts.
SKILL.md
npx skills add https://github.com/bjornmelin/dev-skills --skill ai-sdk-core

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs9
repo stars5
Last updatedAugust 5, 2026
Repositorybjornmelin/dev-skills

What it does

Generate text and structured output, call tools, and connect to MCP servers with the AI SDK Core across LLM providers.

Who is it for?

Wiring text/structured generation, tool calling, and MCP servers with the AI SDK Core across providers

Skip if: Building the client-side chat UI, which is covered by the AI SDK UI hooks instead

When should I use this skill?

Building with generateText/streamText, generateObject/streamObject, tools, embeddings, or MCP tools

What you get

Correct AI SDK Core calls for text, structured data, tools, embeddings, and MCP with proper error handling.

  • AI SDK Core text/structured/tool implementations
  • MCP client integrations

By the numbers

  • 6-row function-selection table
  • 10 bundled reference files

Files

SKILL.mdMarkdownGitHub ↗

AI SDK Core

Use AI SDK Core to generate text/structured output, call tools, and connect to MCP servers with consistent APIs across providers.

Quick Start

pnpm add ai @ai-sdk/openai zod@^4.3.5
import { generateText } from 'ai';

const { text } = await generateText({
  model: 'openai/gpt-4o',
  prompt: 'Explain quantum computing in one paragraph.',
});

Function Selection

NeedFunctionStreaming
Text responsegenerateTextNo
Streaming textstreamTextYes
Structured JSONgenerateObjectNo
Streaming JSONstreamObjectYes
Embeddingsembed / embedManyNo
RerankrerankNo

Core Patterns

Generate Text

import { generateText } from 'ai';

const { text, usage } = await generateText({
  model: 'anthropic/claude-sonnet-4.5',
  system: 'You are a helpful assistant.',
  prompt: 'What is the capital of France?',
});

Stream Text

import { streamText } from 'ai';

const result = streamText({
  model: 'openai/gpt-4o',
  prompt: 'Write a short story.',
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

Generate Structured Data

import { generateObject } from 'ai';
import { z } from 'zod';

const { object } = await generateObject({
  model: 'openai/gpt-4o',
  schema: z.object({
    recipe: z.object({
      name: z.string(),
      ingredients: z.array(z.object({ name: z.string(), amount: z.string() })),
      steps: z.array(z.string()),
    }),
  }),
  prompt: 'Generate a recipe for chocolate chip cookies.',
});

Tool Calling (Typed)

import { generateText, tool } from 'ai';
import { z } from 'zod';

const { text, toolCalls } = await generateText({
  model: 'openai/gpt-4o',
  tools: {
    weather: tool({
      description: 'Get weather for a location',
      inputSchema: z.object({ location: z.string() }),
      execute: async ({ location }) => ({ temperature: 72, condition: 'sunny' }),
    }),
  },
  prompt: 'What is the weather in San Francisco?',
});

Dynamic Tools (Runtime Schemas)

import { dynamicTool } from 'ai';
import { z } from 'zod';

const customTool = dynamicTool({
  description: 'Execute a custom function',
  inputSchema: z.object({}),
  execute: async input => ({ ok: true, input }),
});

Multi-Step Tool Execution

import { generateText, stepCountIs } from 'ai';

const { steps } = await generateText({
  model: 'openai/gpt-4o',
  tools: { search, analyze, summarize },
  stopWhen: stepCountIs(5),
  prompt: 'Research and summarize AI developments.',
});

Tooling Checklist

  • Use tool() for typed inputs and dynamicTool() for unknown schemas.
  • Use needsApproval for sensitive actions (tool-approval-request/response flow).
  • Use stopWhen with stepCountIs/hasToolCall for multi-step loops.
  • Use prepareStep for per-step controls (model swap, toolChoice, activeTools, prompt compression).
  • Use experimental_context when tools need app-specific context.
  • Use inputExamples and strict to improve tool call reliability.

MCP Integration (Model Context Protocol)

  • Use createMCPClient() to load MCP tools, resources, and prompts.
  • Prefer HTTP transport for production; use Experimental_StdioMCPTransport only for local Node.js servers.
  • Close MCP clients after use (try/finally or onFinish).

See references/mcp-integration.md for transports, schema definition, outputSchema typing, and elicitation.

Reference Files

ReferenceWhen to Use
references/text-generation.mdgenerateText/streamText callbacks, streaming, response handling
references/structured-data.mdgenerateObject/streamObject, Output API, Zod patterns
references/tool-calling.mdtool/dynamicTool, approval flow, repair, activeTools, hooks
references/dynamic-tools.mddynamicTool patterns, MCP + dynamic tools, large tool sets
references/embeddings-rag.mdembed/embedMany, rerank, chunking
references/providers.mdOpenAI/Anthropic/Google setup, registry, AI Gateway
references/middleware.mdwrapLanguageModel, built-in/custom middleware
references/mcp-integration.mdMCP client, transports, tools/resources/prompts/elicitation
references/production.mdTelemetry, error handling, testing, cost control
references/migration.mdv6 upgrade notes

Error Handling

import { generateText, AI_APICallError } from 'ai';

try {
  await generateText({ model: 'openai/gpt-4o', prompt: 'Hello' });
} catch (error) {
  if (error instanceof AI_APICallError) {
    console.error('API Error:', error.message);
  }
}

Provider Setup

import { openai } from '@ai-sdk/openai';

const { text } = await generateText({
  model: openai('gpt-4o'),
  prompt: 'Hello!',
});

Version Guidance

  • Use AI SDK v6+ with matching provider packages.
  • Pin major versions in package.json to avoid breaking changes.

Related skills

FAQ

Which function should I use for structured JSON?

Use generateObject for non-streaming structured JSON and streamObject for streaming it, both with a Zod schema.

How does AI SDK Core integrate with MCP?

Use createMCPClient() to load MCP tools, resources, and prompts, preferring HTTP transport for production and Experimental_StdioMCPTransport only for local Node.js servers, and close clients after use.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.