Messages
Anthropic Messages compatibility for Claude Code and the Anthropic SDKs. Supply max_tokens and put system instructions in the top-level system field.
https://api.saveapi.cc/v1/messagesOn this page
Set the Anthropic SDK base URL to https://api.saveapi.cc. The SDK appends /v1/messages. For raw HTTP, /v1/messages and /messages are equivalent.
curl -sS "https://api.saveapi.cc/v1/messages" \
-H "x-api-key: $AI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 256,
"system": "You are a helpful assistant.",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'x-api-keyYOUR_API_KEYRequired- Use your platform API key. You can also send
Authorization: Bearer YOUR_API_KEY. anthropic-version2023-06-01- Select the Anthropic API version. The default is
2023-06-01. anthropic-betastring- Enable Anthropic beta features supported by the selected model.
Content-Typeapplication/json- The request body is JSON.
This list covers common request fields. Optional settings depend on the selected model and API format.
modelstringRequired- Match a
data[].idfromGET /v1/modelsexactly. An unavailable model returns404model_not_found. max_tokensintegerRequired- Set an output limit from 1 to 32768. A missing value returns
400invalid_request_error. messagesarrayRequired- Send
userandassistantmessages in order. Usecontentfor text, text blocks, tool calls, and tool results. For eachtool_use, put atool_resultwith the matchingtool_use_idin the nextusermessage’scontent. systemstring | array- Set top-level system instructions as a string or an array of text blocks.
thinkingobject- Configure extended thinking on compatible models. Some Claude models use
adaptivemode and read the effort fromoutput_config.effort. cache_controlobject- Add prompt cache breakpoints to supported content blocks in
systemormessages, for example at the end ofsystemor in the last message. streamboolean- Set
trueto receive server-sent events. Omit for JSON. toolsarray- Declare client-executed tools and control their selection with
tool_choice. temperaturenumber- Control sampling randomness. The availability and range of
temperatureandtop_pdepend on the model. stop_sequencesarray- Set sequences that stop generation on supported models.
- Use this endpoint for supported extended thinking and prompt caching on Claude. For other text models, available options depend on the selected model.
- Only stateless text input is supported; image, audio, video and PDF inputs return
400.
Join the text blocks in content. stop_reason can indicate completion (end_turn), the output limit (max_tokens), or a tool call (tool_use). usage includes input_tokens and output_tokens, plus cache counts when available.
{
"id": "msg_example",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5-5",
"content": [
{
"type": "text",
"text": "Hello!"
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 7,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 4
}
}- Include the
x-request-idresponse header when reporting an issue, if available. It identifies the request on this platform. - For Claude,
input_tokensexcludes cached tokens. Cache writes appear incache_creation_input_tokensand reads incache_read_input_tokens.
Append text_delta data from content_block_delta events by index. message_delta may carry stop reasons and usage. message_stop ends the stream. Retain the request ID if an error occurs or the connection closes early.
curl -NsS "https://api.saveapi.cc/v1/messages" \
-H "x-api-key: $AI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"max_tokens": 256,
"system": "You are a helpful assistant.",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"stream": true
}'For a 400 response, check max_tokens and the message structure. For a 404, check how the SDK joins its base URL with /v1/messages and make sure /v1 is not repeated.
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "max_tokens is required for Anthropic Messages requests. Add max_tokens or use /chat/completions for OpenAI-compatible requests."
}
}