Skip to main content
sunpeak API

Overview

Returns a function to request LLM completions from the host via MCP sampling/createMessage. The host decides which model to use and may modify or reject the request. Check getHostCapabilities()?.sampling before calling. For tool-augmented completions, check ?.sampling?.tools.

Import

Signature

CreateSamplingMessageParams

Standard MCP CreateMessageRequest params:
SamplingMessage[]
required
Conversation messages to send to the model.
number
required
Maximum tokens in the response.
string
System prompt for the model.
number
Sampling temperature.
Tool[]
Tools the model can call. When provided, the result may include tool_use blocks.

Returns

(params) => Promise<CreateMessageResult | CreateMessageResultWithTools | undefined>
Function to request an LLM completion.

CreateMessageResult

string
Model used by the host.
string
Response role (typically "assistant").
Content
Response content block.
string
Why the model stopped ("endTurn", "toolUse", etc.).

Usage