curl --request POST \
--url https://api.edgee.ai/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "<string>"
}
],
"system": "<string>",
"stream": false,
"tools": [
{
"name": "<string>",
"input_schema": {},
"description": "<string>"
}
],
"tool_choice": {
"type": "auto"
}
}
'{
"id": "<string>",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>"
}
],
"usage": {
"input_tokens": 1,
"output_tokens": 1
},
"stop_reason": "end_turn"
}Create messages using Anthropic native API format
curl --request POST \
--url https://api.edgee.ai/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "<string>"
}
],
"system": "<string>",
"stream": false,
"tools": [
{
"name": "<string>",
"input_schema": {},
"description": "<string>"
}
],
"tool_choice": {
"type": "auto"
}
}
'{
"id": "<string>",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>"
}
],
"usage": {
"input_tokens": 1,
"output_tokens": 1
},
"stop_reason": "end_turn"
}/v1/messages endpoint implements Anthropic’s Messages API format, which differs from the OpenAI-compatible /v1/chat/completions endpoint in several key ways:
claude-sonnet-4.5 instead of anthropic/claude-sonnet-4.5 (no provider prefix)max_tokens parameter is always required (not optional like OpenAI)system field instead of being part of the messages arrayx-api-key: <api_key>
Authorization: Bearer <api_key>
x-api-key takes precedence.
See the Authentication page for more details.
claude-sonnet-4.5, claude-opus-4, claude-haiku-4role and content.{"type": "auto"} - Model decides whether to use tools (default){"type": "any"} - Model must use one of the provided tools{"type": "tool", "name": "tool_name"} - Model must use the specified tooltype field indicating its type.Block types include:text: Text content from the modeltool_use: Tool call made by the model (includes id, name, and input fields)end_turn: Model reached a natural stopping pointmax_tokens: Reached the max_tokens limittool_use: Model called a toolstream: true, the response is sent as Server-Sent Events (SSE). Each event is prefixed with event: and data: lines.
Event types:
message_start: Initial event with message metadatacontent_block_start: A new content block beginscontent_block_delta: Incremental content for the current blockcontent_block_stop: Current content block is completemessage_delta: Message-level delta (includes stop_reason when done)message_stop: Stream is completeerror: An error occurredX-edgee-tags: production,chatbot,customer-supportcurl 'https://api.edgee.ai/v1/messages' \
-H "x-api-key: $EDGEE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello, Claude! How are you today?"
}
]
}'
curl 'https://api.edgee.ai/v1/messages' \
-H "x-api-key: $EDGEE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
},
{
"role": "assistant",
"content": "The capital of France is Paris."
},
{
"role": "user",
"content": "What is its population?"
}
]
}'
curl 'https://api.edgee.ai/v1/messages' \
-H "x-api-key: $EDGEE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"system": "You are a helpful assistant that always responds in a friendly and concise manner.",
"messages": [
{
"role": "user",
"content": "Tell me about the solar system."
}
]
}'
curl 'https://api.edgee.ai/v1/messages' \
-H "x-api-key: $EDGEE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"stream": true,
"messages": [
{
"role": "user",
"content": "Write a haiku about coding."
}
]
}'
curl 'https://api.edgee.ai/v1/messages' \
-H "x-api-key: $EDGEE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}
],
"messages": [
{
"role": "user",
"content": "What is the weather in San Francisco?"
}
]
}'
curl 'https://api.edgee.ai/v1/messages' \
-H "x-api-key: $EDGEE_API_KEY" \
-H 'Content-Type: application/json' \
-H 'X-Edgee-Enable-Compression: true' \
-d '{
"model": "claude-sonnet-4.5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Summarize this long document..."
}
]
}'
streaming_not_supported: Streaming was requested but the model doesn’t use the Anthropic providercount_tokens_not_supported: Token counting is only available with Anthropic providerThe model ID to use (Anthropic format, without provider prefix)
"claude-sonnet-4.5"
Maximum number of tokens to generate
x >= 11024
Array of message objects
1Show child attributes
System prompt as a string
Enable streaming responses
Tool definitions
Show child attributes
Show child attributes
Message created successfully
Unique identifier for this message
The model that generated the response
Array of content blocks
Show child attributes
Show child attributes
Why the model stopped generating
end_turn, max_tokens, tool_use Was this page helpful?