kernl

@kernl-sdk/protocol

For AI agents: These reference docs help coding agents understand the kernl SDK. If your agent gets stuck, share this page with it.

Standard interfaces and types for AI model providers and realtime communication.

Language Models

Type-safe interfaces for chat completion APIs:

import type { LanguageModel, LanguageModelMessage } from '@kernl-sdk/protocol';

const messages: LanguageModelMessage[] = [
  { role: 'system', content: 'You are a helpful assistant.' },
  { role: 'user', content: 'Hello!' },
];

Embedding Models

Interfaces for text embedding APIs:

import type { EmbeddingModel, EmbeddingResult } from '@kernl-sdk/protocol';

Realtime

Protocol types for voice/streaming communication:

import type {
  RealtimeClientEvent,
  RealtimeServerEvent,
  SessionConfig,
} from '@kernl-sdk/protocol';

Standard interfaces and types for AI model providers.

Classes

ClassDescription
RealtimeErrorError from a realtime session.

Interfaces

InterfaceDescription
AbortEventStream event indicating the agent execution was aborted.
ActivityEndEventClient event to signal end of user activity (manual VAD).
ActivityStartEventClient event to signal start of user activity (manual VAD).
AssistantMessage-
AudioConfigAudio format configuration for input and output.
AudioFormatAudio format specification.
AudioInputAppendEventClient event to append audio to the input buffer.
AudioInputClearedEventServer event confirming the audio input buffer has been cleared.
AudioInputClearEventClient event to clear the audio input buffer.
AudioInputCommitEventClient event to commit the audio input buffer as a user message.
AudioInputCommittedEventServer event confirming the audio input buffer has been committed.
AudioOutputDeltaEventServer event containing an audio output chunk.
AudioOutputDoneEventServer event indicating audio output is complete.
DataPartRepresents a structured data segment (e.g., JSON) within a message or artifact.
EmbeddingModelEmbedding model interface.
EmbeddingModelRequest-
EmbeddingModelRequestSettings-
EmbeddingModelResponseThe response from an embedding model.
EmbeddingModelUsageUsage information for an embedding model call.
ErrorEventStream event indicating an error occurred during execution.
FilePartWithDataA file with inline data (base64 string or binary).
FilePartWithUriA file referenced by URI.
FinishEventStream event indicating the completion of agent execution.
ItemCreatedEventServer event indicating an item has been added to the conversation.
ItemCreateEventClient event to add an item to the conversation.
ItemDeletedEventServer event indicating an item has been deleted.
ItemDeleteEventClient event to delete an item from the conversation.
ItemTruncatedEventServer event indicating an item has been truncated.
ItemTruncateEventClient event to truncate assistant audio at a specific timestamp.
LanguageModelDefines the standard interface for language model providers in kernl.
LanguageModelFinishReasonReason why a language model finished generating a response.
LanguageModelItemBaseShared base for language model items.
LanguageModelRequestA request to a large language model.
LanguageModelRequestSettingsSettings to use when calling an LLM.
LanguageModelResponseThe base response interface for a language model.
LanguageModelResponseJSONJSON response format.
LanguageModelResponseTextText response format.
LanguageModelUsageUsage information for a language model call.
MessageBase-
ModelSettingsText-
PartBaseDefines base properties common to all message or artifact parts.
ProviderProvider for language, text embedding, and image generation models.
RawEventStream event containing raw provider-specific data.
RealtimeAuthenticateOptionsOptions for authenticating with a realtime provider.
RealtimeChannelBase interface for audio I/O channels.
RealtimeConnectionAn active bidirectional connection to a realtime model.
RealtimeConnectOptions-
RealtimeEventBaseBase interface for all realtime events.
RealtimeModelA realtime model that can establish bidirectional streaming connections.
RealtimeResponseConfigConfiguration for creating a response (for response.create event).
RealtimeSessionA realtime session as returned from the server.
RealtimeSessionConfigConfiguration for a realtime session.
RealtimeTransportA transport factory for custom connection mechanisms (e.g., WebRTC).
RealtimeUsageToken usage information for a response.
ReasoningReasoning that the model has generated.
ReasoningDeltaEventStream event containing a delta (chunk) of reasoning output.
ReasoningEndEventStream event indicating the end of reasoning output.
ReasoningStartEventStream event indicating the start of reasoning output.
ResponseCancelEventClient event to cancel an in-progress response.
ResponseCreatedEventServer event indicating a response has been created.
ResponseCreateEventClient event to trigger a model response.
ResponseDoneEventServer event indicating a response is complete.
ResponseInterruptedEventServer event indicating a response has been interrupted.
SessionCreatedEventServer event indicating the session has been created.
SessionErrorEventServer event indicating a session error.
SessionResumeConfigConfiguration for resuming a previous session.
SessionUpdatedEventServer event indicating the session configuration has been updated.
SessionUpdateEventClient event to update session configuration.
SharedBase-
SpeechStartedEventServer event indicating speech has been detected (VAD).
SpeechStoppedEventServer event indicating speech has stopped (VAD).
StartEventStream event indicating the start of agent execution.
StreamEventBaseBase interface for all stream events.
SystemMessage-
TextDeltaEventStream event containing a delta (chunk) of text output.
TextEndEventStream event indicating the end of a text output.
TextOutputDeltaEventServer event containing a text output chunk.
TextOutputEventServer event containing the complete text output.
TextPartText that the model has generated.
TextStartEventStream event indicating the start of a text output.
ToolCallTool calls that the model has generated.
ToolCallEventServer event indicating the model wants to call a tool.
ToolCancelledEventServer event indicating a tool call has been cancelled.
ToolDeltaEventServer event containing a tool call arguments chunk.
ToolInputDeltaEventStream event containing a delta (chunk) of tool input.
ToolInputEndEventStream event indicating the end of tool input generation.
ToolInputStartEventStream event indicating the start of tool input generation.
ToolResultResult of a tool call that has been executed by the provider.
ToolResultEventClient event to submit a tool result.
ToolStartEventServer event indicating a tool call has started.
TranscriptInputDeltaEventServer event containing an input transcription chunk.
TranscriptInputEventServer event containing the complete input transcription.
TranscriptOutputDeltaEventServer event containing an output transcription chunk.
TranscriptOutputEventServer event containing the complete output transcription.
TurnDetectionConfigTurn detection / VAD configuration.
UserMessage-
VoiceConfigVoice configuration for audio output.
WebSocketLikeMinimal WebSocket interface matching the standard WebSocket API.

Type Aliases

Type AliasDescription
ClientCredentialA client credential for browser-based realtime connections.
EmbeddingAn embedding is a vector, i.e. an array of numbers. It is e.g. used to represent a text as a vector of word embeddings.
FilePartA file that has been generated by the model or referenced by URI.
JSONArray-
JSONObject-
JSONValueA JSON value can be a string, number, boolean, object, array, or null. JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
LanguageModelFunctionToolA tool has a name, a description, and a set of parameters.
LanguageModelItem-
LanguageModelProviderToolThe configuration of a tool that is defined by the provider.
LanguageModelResponseItemA subset of LanguageModelItem that excludes items that wouldn't make sense for a model to generate (e.g. system/user messages, tool results).
LanguageModelResponseTypeResponse format specification for language model output.
LanguageModelStreamEventUnion of all language model stream events.
LanguageModelTool-
LanguageModelToolChoice-
Message-
MessagePart-
ModelSettingsReasoningConfiguration options for model reasoning
ModelSettingsReasoningEffortConstrains effort on reasoning for reasoning models.
RealtimeChannelEventsEvents emitted by a realtime channel.
RealtimeClientEventUnion of all client → server events.
RealtimeConnectionEventsEvents emitted by a realtime connection.
RealtimeModalityOutput modality for realtime sessions.
RealtimeServerEventUnion of all server → client events.
RealtimeToolChoiceTool choice behavior for realtime sessions.
ResponseStatusStatus of a response.
SharedProviderMetadataAdditional provider-specific metadata.
SharedProviderOptions-
SharedWarningWarning from the model provider for this call. The call will proceed, but e.g. some settings might not be supported, which can lead to suboptimal results.
ToolCallStateState of a tool call execution.
TransportStatusStatus of a realtime transport connection.
WebSocketConstructorWebSocket constructor type for cross-platform compatibility.

Variables

VariableDescription
COMPLETED-
DEADTask is being removed from the system. Final cleanup in progress, about to be fully deleted.
FAILED-
IN_PROGRESSProtocol Constants
INTERRUPTIBLETask is sleeping/blocked, waiting for a condition. Can be woken up by: - The condition being met (e.g., approval granted) - A signal (e.g., user cancellation)
RUNNINGTask is either: - Currently executing - In run queue waiting to be scheduled (might want to differentiate between running + queued here)
STOPPEDTask has been stopped by a signal (SIGSTOP). Will remain stopped until explicitly continued (SIGCONT).
UNINTERRUPTIBLETask is sleeping/blocked and CANNOT be interrupted by signals. Only wakes when the condition is met.
WS_CLOSED-
WS_CLOSING-
WS_CONNECTING-
WS_OPEN-
ZOMBIETask has finished execution but hasn't been cleaned up yet. Waiting for parent to read exit status (wait/waitpid).

Functions

FunctionDescription
messageCreate a message with text content
reasoningCreate a reasoning item

On this page