Anthropic Messages
Use DeerAPI to call the Anthropic Messages endpoint with request details, response details, examples, and an OpenAPI playground.
curl https://api.deerapi.com/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEERAPI_KEY" \
-d '{
"max_tokens": 1024,
"system": "You are a concise technical assistant.",
"messages": [
{
"content": "Summarize the benefits of retry logic for production API clients.",
"role": "user"
}
],
"model": "claude-sonnet-4-6"
}'import os
import requests
url = "https://api.deerapi.com/v1/messages"
headers = {
"Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
"Content-Type": "application/json",
}
payload = {
"max_tokens": 1024,
"system": "You are a concise technical assistant.",
"messages": [
{
"content": "Summarize the benefits of retry logic for production API clients.",
"role": "user"
}
],
"model": "claude-sonnet-4-6"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
const response = await fetch("https://api.deerapi.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"max_tokens": 1024,
"system": "You are a concise technical assistant.",
"messages": [
{
"content": "Summarize the benefits of retry logic for production API clients.",
"role": "user"
}
],
"model": "claude-sonnet-4-6"
}),
});
console.log(await response.json());
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.deerapi.com/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'max_tokens' => 1024,
'messages' => [
[
'content' => 'Summarize the benefits of retry logic for production API clients.',
'role' => 'user'
]
],
'model' => 'claude-sonnet-4-6'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.deerapi.com/v1/messages"
payload := strings.NewReader("{\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"Summarize the benefits of retry logic for production API clients.\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"claude-sonnet-4-6\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.deerapi.com/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"Summarize the benefits of retry logic for production API clients.\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"claude-sonnet-4-6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deerapi.com/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"Summarize the benefits of retry logic for production API clients.\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"claude-sonnet-4-6\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "message",
"role": "assistant",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>",
"thinking": "<string>",
"signature": "<string>",
"id": "<string>",
"name": "<string>",
"input": {},
"citations": [
{}
]
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123,
"cache_creation": {
"ephemeral_5m_input_tokens": 123,
"ephemeral_1h_input_tokens": 123
},
"inference_geo": "<string>",
"server_tool_use": {
"web_search_requests": 123,
"web_fetch_requests": 123
},
"service_tier": "<string>"
},
"container": {
"id": "<string>",
"expires_at": "<string>"
},
"stop_sequence": "<string>"
}Overview
Use this endpoint to call the Anthropic Messages workflow through DeerAPI. The API reference on this page shows the request schema, response schema, authentication requirements, and runnable examples for the configured endpoint.Before you start
Use the DeerAPI base URL and pass your API Key in theAuthorization header:
https://api.deerapi.com
Authorization: Bearer $DEERAPI_KEY
Model selection
Choose a current model ID from the live pricing page. Model availability changes over time, so avoid copying a model ID from an old project without checking the live list first.Implementation notes
- Use the OpenAPI playground for the exact request fields accepted by this endpoint.
- Keep API Keys on the server side when you build production applications.
- Log the request ID from failed calls so support can investigate the request.
- Retry
429,500, and503responses with exponential backoff.
Authorizations
Use a DeerAPI API Key as a Bearer token.
Body
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
auto, standard_only Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
0 <= x <= 1Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
0 <= x <= 1Response
Successful Response
Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
message Use this field according to the endpoint schema.
assistant Use this field according to the endpoint schema.
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
Show child attributes
Show child attributes
Use this field according to the endpoint schema.
curl https://api.deerapi.com/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DEERAPI_KEY" \
-d '{
"max_tokens": 1024,
"system": "You are a concise technical assistant.",
"messages": [
{
"content": "Summarize the benefits of retry logic for production API clients.",
"role": "user"
}
],
"model": "claude-sonnet-4-6"
}'import os
import requests
url = "https://api.deerapi.com/v1/messages"
headers = {
"Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
"Content-Type": "application/json",
}
payload = {
"max_tokens": 1024,
"system": "You are a concise technical assistant.",
"messages": [
{
"content": "Summarize the benefits of retry logic for production API clients.",
"role": "user"
}
],
"model": "claude-sonnet-4-6"
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
const response = await fetch("https://api.deerapi.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"max_tokens": 1024,
"system": "You are a concise technical assistant.",
"messages": [
{
"content": "Summarize the benefits of retry logic for production API clients.",
"role": "user"
}
],
"model": "claude-sonnet-4-6"
}),
});
console.log(await response.json());
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.deerapi.com/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'max_tokens' => 1024,
'messages' => [
[
'content' => 'Summarize the benefits of retry logic for production API clients.',
'role' => 'user'
]
],
'model' => 'claude-sonnet-4-6'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.deerapi.com/v1/messages"
payload := strings.NewReader("{\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"Summarize the benefits of retry logic for production API clients.\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"claude-sonnet-4-6\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.deerapi.com/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"Summarize the benefits of retry logic for production API clients.\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"claude-sonnet-4-6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deerapi.com/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"Summarize the benefits of retry logic for production API clients.\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"claude-sonnet-4-6\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "message",
"role": "assistant",
"model": "<string>",
"content": [
{
"type": "text",
"text": "<string>",
"thinking": "<string>",
"signature": "<string>",
"id": "<string>",
"name": "<string>",
"input": {},
"citations": [
{}
]
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_creation_input_tokens": 123,
"cache_read_input_tokens": 123,
"cache_creation": {
"ephemeral_5m_input_tokens": 123,
"ephemeral_1h_input_tokens": 123
},
"inference_geo": "<string>",
"server_tool_use": {
"web_search_requests": 123,
"web_fetch_requests": 123
},
"service_tier": "<string>"
},
"container": {
"id": "<string>",
"expires_at": "<string>"
},
"stop_sequence": "<string>"
}