MessageCreateParams

data class MessageCreateParams(val model: String, val messages: List<MessageCreateParams.Message>, val system: List<MessageCreateParams.SystemPrompt>? = null, val maxTokens: Int? = null, val temperature: Double? = null, val topP: Double? = null, val topK: Int? = null, val stream: Boolean? = null, val metadata: MessageCreateParams.Metadata? = null, val tools: List<Map<String, String>>? = null)(source)

Parameters for creating a message with Anthropic's Claude models. Based on the structure of com.anthropic.models.messages.MessageCreateParams

Constructors

Link copied to clipboard
constructor(model: String, messages: List<MessageCreateParams.Message>, system: List<MessageCreateParams.SystemPrompt>? = null, maxTokens: Int? = null, temperature: Double? = null, topP: Double? = null, topK: Int? = null, stream: Boolean? = null, metadata: MessageCreateParams.Metadata? = null, tools: List<Map<String, String>>? = null)

Types

Link copied to clipboard
sealed interface Content

Content of a message. Can be a simple string or a list of content blocks.

Link copied to clipboard
sealed interface ContentBlock

A content block in a multi-modal message.

Link copied to clipboard

List of content blocks for multi-modal messages.

Link copied to clipboard
@SerialName(value = "image")
data class ImageBlock(val type: String = "image", val source: MessageCreateParams.ImageSource) : MessageCreateParams.ContentBlock

Image content block.

Link copied to clipboard
data class ImageSource(val type: String, val mediaType: String, val data: String)

Source information for an image.

Link copied to clipboard
data class Message(val role: String, val content: MessageCreateParams.Content)

Message object for Claude API.

Link copied to clipboard
data class Metadata(val userId: String? = null)

Metadata about the request.

Link copied to clipboard
data class SystemPrompt(val text: String, val type: String = "text", val cacheControl: MessageCreateParams.SystemPrompt.CacheControl? = null, val citations: List<MessageCreateParams.SystemPrompt.Citation>? = null)

System prompt for Claude. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.

Link copied to clipboard
@SerialName(value = "text")
data class TextBlock(val type: String = "text", val text: String) : MessageCreateParams.ContentBlock

Text content block.

Link copied to clipboard
@SerialName(value = "text")
data class TextContent(val text: String?) : MessageCreateParams.Content

Text content for a message.

Properties

Link copied to clipboard
@SerialName(value = "max_tokens")
val maxTokens: Int?

The maximum number of tokens to generate before stopping.

Link copied to clipboard
Link copied to clipboard

An object describing metadata about the request.

Link copied to clipboard

The model that will complete your prompt. See the models page for a list of available models.

Link copied to clipboard

Whether to incrementally stream the response using server-sent events.

Link copied to clipboard

System prompt. A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.

Link copied to clipboard

Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks.

Link copied to clipboard
Link copied to clipboard
@SerialName(value = "top_k")
val topK: Int?

Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. Defaults to -1, which disables it.

Link copied to clipboard
@SerialName(value = "top_p")
val topP: Double?

Use nucleus sampling. In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by top_p. Defaults to -1.0, which disables it.