AnthropicRequest
Defined in: adapters/anthropic.ts:122
Anthropic Messages API request structure.
Defines all parameters for making a request to Claude via Anthropic’s Messages API. Key differences from OpenAI: system message is a separate parameter (not in messages), max_tokens is required, and supports top_k sampling parameter.
- AnthropicMessage
- AnthropicResponse
- https://docs.anthropic.com/en/api/messages
Example
Section titled “Example”const request: AnthropicRequest = { model: 'claude-3-5-sonnet-20241022', max_tokens: 1024, messages: [ { role: 'user', content: 'Hello, Claude!' } ], system: 'You are a helpful assistant.', temperature: 0.7};Properties
Section titled “Properties”max_tokens
Section titled “max_tokens”max_tokens:
number
Defined in: adapters/anthropic.ts:133
Maximum tokens to generate - REQUIRED by Anthropic API
messages
Section titled “messages”messages:
AnthropicMessage[]
Defined in: adapters/anthropic.ts:127
Array of conversation messages (user and assistant only)
metadata?
Section titled “metadata?”
optionalmetadata:object
Defined in: adapters/anthropic.ts:151
Optional metadata for tracking and abuse prevention
user_id?
Section titled “user_id?”
optionaluser_id:string
User identifier for abuse monitoring
model:
string
Defined in: adapters/anthropic.ts:124
Model ID (e.g., ‘claude-3-5-sonnet-20241022’, ‘claude-3-opus-20240229’)
stop_sequences?
Section titled “stop_sequences?”
optionalstop_sequences:string[]
Defined in: adapters/anthropic.ts:145
Stop sequences - generation stops when encountered
stream?
Section titled “stream?”
optionalstream:boolean
Defined in: adapters/anthropic.ts:148
Enable streaming responses via Server-Sent Events
system?
Section titled “system?”
optionalsystem:string
Defined in: adapters/anthropic.ts:130
System prompt/instructions (separate from messages array)
temperature?
Section titled “temperature?”
optionaltemperature:number
Defined in: adapters/anthropic.ts:136
Sampling temperature 0-1. Higher = more random. Default 1
top_k?
Section titled “top_k?”
optionaltop_k:number
Defined in: adapters/anthropic.ts:142
Top-K sampling parameter. Only sample from top K tokens
top_p?
Section titled “top_p?”
optionaltop_p:number
Defined in: adapters/anthropic.ts:139
Nucleus sampling parameter 0-1. Alternative to temperature