oRPC AI SDK Integration
Enables seamless integration of AI SDK streams into oRPC event iterators with zero overhead.
Install
mkdir -p .claude/skills/orpc-ai-sdk-integration && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11289" && unzip -o skill.zip -d .claude/skills/orpc-ai-sdk-integration && rm skill.zipInstalls to .claude/skills/orpc-ai-sdk-integration
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Seamlessly use AI SDK inside your oRPC projects without any extra overhead.Key capabilities
- →Convert AI SDK streams to oRPC Event Iterators on the server
- →Convert oRPC Event Iterators back to streams on the client
- →Implement oRPC procedure contracts as AI SDK tools
- →Create AI SDK tools from oRPC procedures
- →Integrate AI SDK v5.0.0 or later with oRPC projects
How it works
The skill provides utility functions to bridge AI SDK streams with oRPC Event Iterators, enabling streaming AI content within oRPC applications, and helpers to integrate oRPC procedures as AI SDK tools.
Inputs & outputs
When to use oRPC AI SDK Integration
- →Stream AI chat responses in an oRPC API
- →Integrate AI SDK v5.0.0+ into server handlers
- →Manage streaming data on the client side
About this skill
AI SDK Integration
AI SDK is a free open-source library for building AI-powered products. You can seamlessly integrate it with oRPC without any extra overhead.
Requires AI SDK v5.0.0 or later.
Server
Use streamToEventIterator to convert AI SDK streams to oRPC Event Iterators.
import { os, streamToEventIterator, type } from '@orpc/server'
import { convertToModelMessages, streamText, UIMessage } from 'ai'
import { google } from '@ai-sdk/google'
export const chat = os
.input(type<{ chatId: string, messages: UIMessage[] }>())
.handler(async ({ input }) => {
const result = streamText({
model: google('gemini-1.5-flash'),
system: 'You are a helpful assistant.',
messages: await convertToModelMessages(input.messages),
})
return streamToEventIterator(result.toUIMessageStream())
})
Client
Convert the event iterator back to a stream using eventIteratorToStream or eventIteratorToUnproxiedDataStream.
import { useChat } from '@ai-sdk/react'
import { eventIteratorToUnproxiedDataStream } from '@orpc/client'
export function Example() {
const { messages, sendMessage, status } = useChat({
transport: {
async sendMessages(options) {
return eventIteratorToUnproxiedDataStream(await client.chat({
chatId: options.chatId,
messages: options.messages,
}, { signal: options.abortSignal }))
},
reconnectToStream() {
throw new Error('Unsupported')
},
},
})
// render UI...
}
Prefer
eventIteratorToUnproxiedDataStreambecause AI SDK usesstructuredClone, which doesn't support proxied data.
implementTool helper
Implements a procedure contract as an AI SDK tool.
import { oc } from '@orpc/contract'
import { AI_SDK_TOOL_META_SYMBOL, AiSdkToolMeta, implementTool } from '@orpc/ai-sdk'
import { z } from 'zod'
interface ORPCMeta extends AiSdkToolMeta {}
const base = oc.$meta<ORPCMeta>({})
const getWeatherContract = base
.meta({ [AI_SDK_TOOL_META_SYMBOL]: { title: 'Get Weather' } })
.route({ summary: 'Get the weather in a location' })
.input(z.object({ location: z.string() }))
.output(z.object({ location: z.string(), temperature: z.number() }))
const getWeatherTool = implementTool(getWeatherContract, {
execute: async ({ location }) => ({
location,
temperature: 72 + Math.floor(Math.random() * 21) - 10,
}),
})
createTool helper
Converts a procedure into an AI SDK Tool.
import { os } from '@orpc/server'
import { AI_SDK_TOOL_META_SYMBOL, AiSdkToolMeta, createTool } from '@orpc/ai-sdk'
import { z } from 'zod'
const getWeatherProcedure = os
.meta({ [AI_SDK_TOOL_META_SYMBOL]: { title: 'Get Weather' } })
.route({ summary: 'Get the weather in a location' })
.input(z.object({ location: z.string() }))
.output(z.object({ location: z.string(), temperature: z.number() }))
.handler(async ({ input }) => ({
location: input.location,
temperature: 72,
}))
const getWeatherTool = createTool(getWeatherProcedure, { context: {} })
When not to use it
- →When using AI SDK versions older than v5.0.0
- →When `eventIteratorToUnproxiedDataStream` is not preferred for AI SDK due to proxied data issues
- →When `reconnectToStream` functionality is required on the client side
Prerequisites
Limitations
- →Requires AI SDK v5.0.0 or later
- →AI SDK uses `structuredClone`, which does not support proxied data
- →The `reconnectToStream` method is unsupported
How it compares
This integration provides specific functions like `streamToEventIterator` and `eventIteratorToUnproxiedDataStream` to manage data flow between AI SDK and oRPC, which is not natively supported.
Compared to similar skills
oRPC AI SDK Integration side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| oRPC AI SDK Integration (this skill) | 0 | 3mo | No flags | Intermediate |
| exa-core-workflow-b | 0 | 27d | Review | Intermediate |
| add-ai-endpoint | 0 | 4mo | Review | Intermediate |
| llm-what-to-use-when | 0 | 5mo | Caution | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
exa-core-workflow-b
jeremylongshore
Execute Exa secondary workflow: Core Workflow B. Use when implementing secondary use case, or complementing primary workflow. Trigger with phrases like "exa secondary workflow", "secondary task with exa".
add-ai-endpoint
malhajri07
Scaffold a Claude API powered endpoint with system prompt, structured output, token tracking, and rate limiting. Use when adding AI features like chatbot, matching, or text generation.
llm-what-to-use-when
TimelessP
Practical decision guide for choosing between Vercel AI SDK, LiteLLM, LightLLM, and direct provider SDKs based on runtime, deployment model, and constraints. Use when asked which LLM tooling to use for JS/TS apps, Python apps, static SPAs, or self-hosted inference.
mcp-builder
anthropics
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
telegram-mini-app
davila7
Expert in building Telegram Mini Apps (TWA) - web apps that run inside Telegram with native-like experience. Covers the TON ecosystem, Telegram Web App API, payments, user authentication, and building viral mini apps that monetize. Use when: telegram mini app, TWA, telegram web app, TON app, mini app.
stripe-integration
wshobson
Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.