Claude Sonnet 5
Request ID claude-sonnet-5
Protocols
POST /v1/messages· Anthropic Messages examplePOST /v1/messages/count_tokens· Count Tokens example
Authentication
Requests require an API key from API key management. For JSON requests, set Content-Type: application/json.
- Anthropic Messages ·
x-api-key: YOUR_API_KEY
Request parameters
POST /v1/messages
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Required | Set the model ID to claude-sonnet-5. |
messages | object[] | Required | Send user and assistant messages in order. Put system instructions in the top-level system field. |
messages[].content | string / object[] | Required | The message body. Use plain text or an array of content blocks defined by the protocol. |
messages[].content[] | object | Conditional | Use a type: image content block and put image data in source. Accepted formats depend on the endpoint. |
system | string / object[] | Optional | System instructions as text or an array of text blocks. |
max_tokens | integer | Required | Caps output tokens. The accepted limit depends on the model and endpoint. |
stream | boolean | Optional | true requests an SSE stream. false requests a JSON response. Available modes depend on the endpoint. |
temperature | number | Conditional | Controls sampling randomness. Accepted values and whether the field takes effect depend on the model and endpoint. |
top_p | number | Conditional | Limits sampling candidates by cumulative probability. Use when the model and endpoint support it. |
tools | object[] | Conditional | Tool definitions available to the model. Tool types and parameter formats depend on the protocol and endpoint. |
tool_choice | object | Conditional | Controls tool selection. Use a forced or named choice only when the selected endpoint supports it. |
POST /v1/messages/count_tokens
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Required | Set the model ID to claude-sonnet-5. |
messages | object[] | Required | Send user and assistant messages in order. Put system instructions in the top-level system field. |
messages[].content | string / object[] | Required | The message body. Use plain text or an array of content blocks defined by the protocol. |
messages[].content[] | object | Conditional | Use a type: image content block and put image data in source. Accepted formats depend on the endpoint. |
system | string / object[] | Optional | System instructions as text or an array of text blocks. |
tools | object[] | Conditional | Tool definitions to include in the input token count. Send the same tools as in the Messages request. |
Request examples
Set your API key in the local ICODEEASY_API_KEY environment variable and choose an endpoint that accepts direct HTTP calls. For endpoints that require a specific client, follow that client’s setup guide.
Anthropic Messages
curl -sS 'https://api.icodeeasy.cc/v1/messages' \
-H "x-api-key: $ICODEEASY_API_KEY" \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
--data '{
"model": "claude-sonnet-5",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "Explain how a rainbow forms in one sentence."
}
]
}'
Count Tokens
curl -sS 'https://api.icodeeasy.cc/v1/messages/count_tokens' \
-H "x-api-key: $ICODEEASY_API_KEY" \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
--data '{
"model": "claude-sonnet-5",
"messages": [
{
"role": "user",
"content": "Explain how a rainbow forms in one sentence."
}
]
}'
Read the response
- Anthropic Messages · Read blocks of type
textincontent[]. In a stream, process SSE content block events in order. JSON · SSE - Count Tokens · Read the input token count from
input_tokens.
Capabilities and limits
streaming· Supportedtool_calling· Supportedimage_input· Conditional — Depends on the compatible endpoint and request formatvideo_input· Not supported
Model Capability Catalog · View pricing
Related guides
Install Claude Code, Configure a Custom API, and Troubleshoot Windows
Install Claude Code, configure a custom API key and URL, verify Windows or Unix settings, and troubleshoot authentication, rate limits, and connections.
Anthropic Messages
Send a request in the Anthropic Messages format. This page covers direct HTTP calls, with Claude Code setup covered in the related guides.
Model Capability Catalog
Compare public text, image, and video models by normalized request ID, compatible protocols, supported clients, tool use, media capabilities, limits, and review date.