@ratel-ai/vercel-ai-sdk
Raw API of @ratel-ai/vercel-ai-sdk — the official Vercel AI SDK adapter: the aiSdk() factory for ratel().adaptTo(), speaking ai@5-7 tool and message shapes.
v0.1.0 · TypeScript · npm · source
Generated from the doc comments at
ratel-ai/ratel@5b6e154— do not edit by hand. Regenerate withpnpm sync:apiinapps/docs.
@ratel-ai/vercel-ai-sdk — the Vercel AI SDK adapter for Ratel. Implements
the @ratel-ai/sdk framework-adapter SPI (ADR-0013) for ai@^5 || ^6 || ^7, so
ratel(config).adaptTo(aiSdk()) speaks the AI SDK's native Tool and
ModelMessage shapes and adds the SDK-idiomatic per-turn recall helpers.
Interfaces
AiSdkExt
The AI SDK-idiomatic per-turn recall helpers aiSdk merges onto the
adapted view via the SPI's extend hook. Two ways to inject the same
synthetic search_capabilities pair; pick one per host (see the package
README's cache trade-off).
Methods
appendRecall()
appendRecall(
messages):Promise<ModelMessage[]>
Rank the catalog against the last user message and append the synthetic
search_capabilities pair at the transcript suffix (recall mode), then
return messages. Mutates and returns the same array so prior turns' recalls
stay in the history — a suffix append extends the cached prefix instead of
busting it. Async (core recall is async). A no-op that returns messages
untouched and spends no call id unless the last message is a user turn with
text and there are hits. Hosts that rebuild the array per request must
persist the appended pair themselves.
Parameters
| Parameter | Type |
|---|---|
messages | ModelMessage[] |
Returns
Promise<ModelMessage[]>
prepareStep()
prepareStep(
options):Promise<{messages:ModelMessage[]; } |undefined>
A prepareStep for generateText / streamText / an Agent: on step 0 with
a user turn and hits, append a cached recall pair to a fresh messages array.
On later steps, return undefined when the host already carried the pair
forward (ai@7), or reinsert the cached pair at its original boundary when
the host rebuilt the prompt without it (ai@5/6). Never mutates the caller's
messages or repeats recall within one run. Structurally assignable to
PrepareStepFunction<TOOLS> for any TOOLS; direct step-0 calls may omit
steps when no multi-step carry-forward is needed.
Parameters
| Parameter | Type |
|---|---|
options | { messages: ModelMessage[]; stepNumber: number; steps?: readonly unknown[]; } |
options.messages | ModelMessage[] |
options.stepNumber | number |
options.steps? | readonly unknown[] |
Returns
Promise<{ messages: ModelMessage[]; } | undefined>
Functions
aiSdk()
aiSdk():
RatelAdapter<Tool,ModelMessage,AiSdkExt>
The Vercel AI SDK adapter: ratel(config).adaptTo(aiSdk()) gives the
framework-neutral core the AI SDK's native Tool and
ModelMessage shapes, across ai@5, ai@6, and ai@7. The core owns every guard (reserved ids, top-K clamp,
first-registration-wins, recall-id counter), so the adapter is just the three
codecs — ingest / expose / recallMessages — plus the AiSdkExt
recall helpers.
Returns
RatelAdapter<Tool, ModelMessage, AiSdkExt>
A RatelAdapter over the AI SDK's tool and message types.