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.
Before you start
Follow the quickstart to get an API key and select an endpoint that accepts direct HTTP calls. The example sends ICODEEASY_API_KEY in x-api-key and includes anthropic-version. Replace YOUR_MODEL_ID with a model ID supported by your endpoint.
Request example
Set model, cap output with max_tokens, and put the conversation in 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": "YOUR_MODEL_ID",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": "Say hello."
}
]
}'
Read the response
Read blocks of type text from content[]. Read usage from usage.input_tokens and usage.output_tokens. When present, cache_creation_input_tokens and cache_read_input_tokens count cache writes and reads respectively.
{
"content": [
{
"type": "text",
"text": "Hello!"
}
],
"stop_reason": "end_turn"
}
Streaming response example
Set stream: true in the request body to receive SSE. Append delta.text from content_block_delta. Read the stop reason from message_delta and confirm completion at message_stop. Treat an SSE error event as a failure even if HTTP already returned 200.
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello!"}}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":4}}
event: message_stop
data: {"type":"message_stop"}
Read streaming usage from message_start.message.usage and later message_delta.usage. Cache fields have the same meaning as in the JSON response.
Related guides
Getting Started
Create an account, obtain an API key, choose an endpoint, and send a first request to confirm that I Code Easy is working.
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.
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.