Feature Announcement
Introducing @pastecn/ai-sdk
AI SDK tools for creating and reading pastecn snippets directly from your AI agents.
AI agents are becoming the primary interface for code generation. Whether you're building a coding assistant, a component generator, or an automated workflow, your agents need a way to share the code they create.
@pastecn/ai-sdk provides ready-to-use tools for the Vercel AI SDK that let your agents create and retrieve pastecn snippets programmatically.
Installation
Install directly into your project using the shadcn CLI:
This copies tools/pastecn.ts to your project and installs the required dependencies (ai, zod).
Available tools
createSnippet
Creates a code snippet on pastecn and returns a shareable URL. Supports multiple files, different snippet types (component, hook, lib, block, file), and optional password protection.
getSnippet
Retrieves a snippet from pastecn by ID. Returns the full snippet content including all files. Supports password-protected snippets via the password parameter.
Usage example
Here's how to use the tools with the Vercel AI SDK:
import { createSnippet, getSnippet } from "@/tools/pastecn";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const result = await generateText({
model: openai("gpt-4o-mini"),
prompt: "Create a React button component and save it to pastecn",
tools: {
createSnippet: createSnippet(),
getSnippet: getSnippet(),
},
});The agent will automatically call createSnippet with the appropriate parameters and return the shareable URL.
Use cases
Coding assistants. Let your AI generate components and share them via pastecn URLs.
Component generators. Build tools that create shadcn-compatible components and distribute them instantly.
Code review bots. Retrieve snippets for analysis and create improved versions.
Automated workflows. Integrate snippet creation into CI/CD pipelines or automation tools.
Configuration
Both tools accept an optional baseUrl parameter for self-hosted instances or development:
// Use a custom instance
const tools = {
createSnippet: createSnippet({
baseUrl: "https://my-pastecn.example.com"
}),
getSnippet: getSnippet({
baseUrl: "https://my-pastecn.example.com"
}),
};Why pastecn for AI agents?
No authentication required
Agents can create public snippets without API keys or OAuth flows.
Instant distribution
Generated code becomes immediately installable via shadcn add.
Multi-file support
Create complex components with multiple files, styles, and utilities in a single snippet.