Skip to main content
Complete API documentation for the @corti/ai-sdk-adapter package.

Functions

convertToParams()

Converts an array of CortiUIMessage objects (from the Vercel AI SDK useChat hook) into A2A MessageSendParams ready to send to a Corti agent.
Returns: MessageSendParams — an A2A-compatible params object you can pass to client.sendMessage() or client.sendMessageStream(). Automatic behavior:
  • Extracts contextId from the last assistant message to maintain conversation context.
  • Includes taskId only when the last assistant message has state: 'input-required'.
  • Attaches credentials only on the first message.

toUIMessageStream()

Converts an A2A streaming response into a UI message stream compatible with the Vercel AI SDK’s createUIMessageStreamResponse().
Returns: ReadableStream — a stream you can pass to createUIMessageStreamResponse({ stream }).

createA2AClientFactory()

Creates a factory for building A2A clients that are pre-configured with Corti authentication.
Returns: A2AClientFactory — a factory with a createFromUrl(url, agentId) method to build A2A clients. Usage:

createFetchImplementation()

Creates a fetch-compatible function that automatically injects Corti authentication headers into every request. This is the lower-level primitive used internally by createA2AClientFactory(), but you can use it directly when you need a custom A2A client setup.
Returns: A fetch-compatible function (input, init?) => Promise<Response> that adds Corti authentication to outgoing requests. Usage:

Types

CortiUIMessage

Extends the standard Vercel AI SDK UIMessage with A2A-specific metadata and data parts.
Metadata fields: Custom data parts:

CortiTextPart

A text data part. Alias for string.

CortiJSONPart

A JSON data part. Alias for JSONValue from @ai-sdk/provider.

CortiStatusUpdate

A status update emitted by the agent during streaming.

ExpertCredential

Credentials for authenticating with MCP servers connected to a Corti agent.

StreamConversionOptions

Options passed to toUIMessageStream() to configure stream behavior.
Callback reference: