Claude format
Create Claude messages compatible with the Anthropic Messages protocol, supporting streaming and non-streaming responses
Features
- Supports both streaming (SSE) and non-streaming response modes
- Supports multimodal content (text, images, etc.)
- Supports tool use
- Supports thinking/reasoning mode configuration
- Supports cache control optimization
Use cases
Suitable for scenarios requiring interaction with Claude models, including:- Single-turn or multi-turn conversations
- Structured output (JSON Schema)
- Tool calling and function execution
- Code execution and container reuse
Authentication
Include theAuthorization header in the format Bearer YOUR_API_KEY.
anthropic-version header, e.g. 2023-06-01.Quick example
Headers
"2023-06-01"
"YOUR_API_KEY"
Body
Maximum number of output tokens (required)
Model name, e.g. claude-sonnet-4-0, claude-opus-4-0, etc.
List of messages
Nucleus sampling, 0-1
Top-K sampling
Stop sequences
Tool choice configuration, can be a String or ClaudeToolChoice object
Top-level cache control configuration Automatically applies a cache_control marker to the last cacheable block in the request
Inference geographic region Specifies the geographic region for inference processing. If not specified, uses the workspace's default_inference_geo
Output configuration Configures model output format options, such as effort level and structured output format
Service tier Determines whether to use priority capacity (if available) or standard capacity Possible values: "auto" / "standard_only"
System instruction, can be a String or List
Sampling temperature, 0.0-1.0
Whether to enable streaming output
Thinking/reasoning mode configuration
List of tool definitions
Metadata
Container identifier, used for cross-request container reuse (code execution tool)
Response
Claude Messages API non-streaming response Reference: https://platform.claude.com/docs/en/api/messages/create
Stop reason: end_turn / max_tokens / stop_sequence / tool_use / pause_turn / refusal Always output in the message_start event (even when null)
Stop sequence that was matched (can be null) Always output in the message_start event (even when null)
Refusal stop details Structured information returned when the model refuses due to safety policy
Message ID (msg_ prefix)
Object type, always "message"
Role, always "assistant"
List of response content blocks
Model name (the actual model that completed the task)
Container information Container identifier for the code execution tool, used for cross-request reuse
Usage statistics