Skip to content

AIDK API Reference / aidk-ai-sdk

aidk-ai-sdk ​

AIDK Vercel AI SDK Adapter ​

Bidirectional integration between AIDK and the Vercel AI SDK. Use AI SDK models in AIDK agents, or use AIDK's JSX components with AI SDK's execution.

Two Directions ​

1. AI SDK → AIDK (Use AI SDK models in AIDK Engine) ​

typescript
import { Engine } from 'aidk';
import { aiSdk } from 'aidk-ai-sdk';
import { openai } from '@ai-sdk/openai';

const engine = new Engine({
  model: aiSdk(openai('gpt-4')),
});

2. AIDK → AI SDK (Use AIDK components with AI SDK) ​

Progressive adoption from simple to full-featured:

typescript
import { compile, createCompiler, generateText } from 'aidk-ai-sdk';

// Level 1: Compile JSX to AI SDK messages
const { messages, tools } = await compile(<MyAgent />);

// Level 2: Managed single execution
const compiler = createCompiler();
const result = await compiler.run(<MyAgent />, executor);

// Level 3: Streaming execution
for await (const event of compiler.stream(<MyAgent />, executor)) {
  // Handle streaming events
}

// Level 4: Drop-in replacement for AI SDK
const result = await generateText(<MyAgent />);

See ​

  • aiSdk - Create AI SDK model adapter
  • compile - Compile JSX to AI SDK format
  • AiSdkCompiler - Full compiler with execution management

Classes ​

ClassDescription
AiSdkCompilerAI SDK Compiler.

Interfaces ​

InterfaceDescription
AiSdkAdapterConfigConfiguration options for the AI SDK adapter
AiSdkModelPropsProps for AiSdkModel component. Extends adapter config with optional Model component props.
CompiledInputLibrary-native compiled output. This is what compile() returns - ready to pass to generateText/streamText.
CompilerConfigConfiguration for the compiler.
MessagePropsProps for ai-sdk-style Message component. Uses ai-sdk's role and content format.
ToolResultPropsProps for ai-sdk-style ToolResult component.

Type Aliases ​

Type AliasDescription
AiSdkAdapter-
AiSdkContentAI SDK compatible message content. Supports string (simple text) or content parts array.
AiSdkContentPartAI SDK content part types we support.
CompilerStreamEventEvents emitted during streaming.
ExecutorExecutor function signature. User provides this to control model execution.
GenerateOptionsOptions for generateText/streamText methods. Matches ai-sdk's options interface.
StreamExecutorStream executor function signature.

Functions ​

FunctionDescription
aiSdkShorthand factory for creating AI SDK adapter.
aiSdkMessagesToEngineInputConvert AI SDK messages directly to EngineInput. Convenience function that chains fromAiSdkInputMessages → messagesToEngineInput.
AssistantAI SDK-style Assistant message component.
compileCompile JSX to library-native input.
createAiSdkModelCreate an AI SDK adapter for use with the engine.
createCompilerCreate an AI SDK compiler.
fromAiSdkInputMessagesConvert AI SDK input messages to our Message[] format. This is the inverse of toAiSdkMessages.
fromAiSdkMessages-
generateTextGenerate text using JSX.
mapAiSdkContentToContentBlocks-
mapAiSdkPartToContentBlock-
mapContentBlocksToAiSdkContent-
mapContentBlockToAiSdkPart-
mapToolResultToContentBlocks-
MessageAI SDK-style Message component.
ModelAiSdkModel component for declarative model configuration in JSX.
streamTextStream text using JSX.
SystemAI SDK-style System message component.
toAiSdkCompiledInputConvert compiled output (COMInput) to AI SDK CompiledInput format. Used by the compiler adapter to produce library-native output.
toAiSdkMessages-
ToolResultAI SDK-style ToolResult component.
UserAI SDK-style User message component.

References ​

AiSdkModel ​

Renames and re-exports Model


createAiSdkCompiler ​

Renames and re-exports createCompiler


Timeline ​

Re-exports Timeline

Released under the MIT License.