Create Anthropic message
curl --request POST \
--url https://api-direct.dimilinks.com/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [
{
"content": "<string>"
}
],
"system": "<string>",
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop_sequences": [
"<string>"
],
"stream": false,
"tools": [
{}
],
"tool_choice": {},
"metadata": {},
"thinking": {}
}
'import requests
url = "https://api-direct.dimilinks.com/messages"
payload = {
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [{ "content": "<string>" }],
"system": "<string>",
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop_sequences": ["<string>"],
"stream": False,
"tools": [{}],
"tool_choice": {},
"metadata": {},
"thinking": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'claude-sonnet-5',
max_tokens: 1024,
messages: [{content: '<string>'}],
system: '<string>',
temperature: 123,
top_p: 123,
top_k: 123,
stop_sequences: ['<string>'],
stream: false,
tools: [{}],
tool_choice: {},
metadata: {},
thinking: {}
})
};
fetch('https://api-direct.dimilinks.com/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-direct.dimilinks.com/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([
'model' => 'claude-sonnet-5',
'max_tokens' => 1024,
'messages' => [
[
'content' => '<string>'
]
],
'system' => '<string>',
'temperature' => 123,
'top_p' => 123,
'top_k' => 123,
'stop_sequences' => [
'<string>'
],
'stream' => false,
'tools' => [
[
]
],
'tool_choice' => [
],
'metadata' => [
],
'thinking' => [
]
]),
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-direct.dimilinks.com/messages"
payload := strings.NewReader("{\n \"model\": \"claude-sonnet-5\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {}\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-direct.dimilinks.com/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"claude-sonnet-5\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-direct.dimilinks.com/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 \"model\": \"claude-sonnet-5\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "msg_xxx",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5",
"content": [
{
"type": "text",
"text": "<string>"
}
],
"stop_reason": "<string>",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}Chat
Anthropic Messages
Call the full Claude model family through the native Anthropic protocol.
POST
/
messages
Create Anthropic message
curl --request POST \
--url https://api-direct.dimilinks.com/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [
{
"content": "<string>"
}
],
"system": "<string>",
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop_sequences": [
"<string>"
],
"stream": false,
"tools": [
{}
],
"tool_choice": {},
"metadata": {},
"thinking": {}
}
'import requests
url = "https://api-direct.dimilinks.com/messages"
payload = {
"model": "claude-sonnet-5",
"max_tokens": 1024,
"messages": [{ "content": "<string>" }],
"system": "<string>",
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop_sequences": ["<string>"],
"stream": False,
"tools": [{}],
"tool_choice": {},
"metadata": {},
"thinking": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'claude-sonnet-5',
max_tokens: 1024,
messages: [{content: '<string>'}],
system: '<string>',
temperature: 123,
top_p: 123,
top_k: 123,
stop_sequences: ['<string>'],
stream: false,
tools: [{}],
tool_choice: {},
metadata: {},
thinking: {}
})
};
fetch('https://api-direct.dimilinks.com/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-direct.dimilinks.com/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([
'model' => 'claude-sonnet-5',
'max_tokens' => 1024,
'messages' => [
[
'content' => '<string>'
]
],
'system' => '<string>',
'temperature' => 123,
'top_p' => 123,
'top_k' => 123,
'stop_sequences' => [
'<string>'
],
'stream' => false,
'tools' => [
[
]
],
'tool_choice' => [
],
'metadata' => [
],
'thinking' => [
]
]),
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-direct.dimilinks.com/messages"
payload := strings.NewReader("{\n \"model\": \"claude-sonnet-5\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {}\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-direct.dimilinks.com/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"claude-sonnet-5\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-direct.dimilinks.com/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 \"model\": \"claude-sonnet-5\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\n \"content\": \"<string>\"\n }\n ],\n \"system\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop_sequences\": [\n \"<string>\"\n ],\n \"stream\": false,\n \"tools\": [\n {}\n ],\n \"tool_choice\": {},\n \"metadata\": {},\n \"thinking\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "msg_xxx",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5",
"content": [
{
"type": "text",
"text": "<string>"
}
],
"stop_reason": "<string>",
"stop_sequence": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"code": "<string>"
}
}If you already use the official Anthropic SDK, or want native Claude capabilities such as system prompts, Tool Use, and Prompt Caching, call
We recommend including the
Response (abridged):
Node.js:
If the model response contains
/v1/messages directly. It follows the official Anthropic protocol.
Anthropic Messages and all other public APIs use
api-direct.dimilinks.com. The complete request URL is https://api-direct.dimilinks.com/v1/messages, and all protocols share the same Bearer key.Request URL
POST https://api-direct.dimilinks.com/v1/messages
Content-Type: application/json
Authorization: Bearer <DIMILINKS_API_KEY>
anthropic-version: 2023-06-01
anthropic-version header explicitly to match Anthropic’s official documentation. Requests without it are also supported and use the server’s default version.
Basic example
curl "https://api-direct.dimilinks.com/v1/messages" \
-H "Authorization: Bearer $DIMILINKS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"system": "You are a concise assistant.",
"messages": [
{"role": "user", "content": "Explain Pluto in one sentence."}
]
}'
{
"id": "msg_xxx",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5",
"content": [
{ "type": "text", "text": "Pluto is a dwarf planet at the outer edge of the Solar System." }
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 32,
"output_tokens": 24
}
}
Streaming
Add"stream": true. The server then returns native Anthropic events in this order: message_start / content_block_start / content_block_delta / content_block_stop / message_delta / message_stop.
curl "https://api-direct.dimilinks.com/v1/messages" \
-H "Authorization: Bearer $DIMILINKS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-N \
-d '{
"model": "claude-opus-4-8",
"max_tokens": 1024,
"stream": true,
"messages": [
{"role": "user", "content": "Write a four-line poem about a rainy night."}
]
}'
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Claude model ID, such as claude-opus-4-8, claude-sonnet-5, or claude-haiku-4-5. |
max_tokens | integer | Yes | Maximum output tokens for one response. |
messages | array | Yes | Message array. role supports user / assistant; content supports a string or [{type:"text",...}] content blocks. |
system | string | array | No | System prompt, either a string or an array such as [{type:"text",...}]. |
temperature | number | No | Sampling temperature from 0 to 1. |
top_p | number | No | Nucleus sampling probability from 0 to 1. |
top_k | integer | No | Top-k sampling. |
stop_sequences | string[] | No | Stop generation when one of these sequences is matched. |
stream | boolean | No | When true, returns SSE streaming events. |
tools | array | No | Native Anthropic Tool Use definitions. |
tool_choice | object | No | Controls whether a specific tool must be used. |
metadata | object | No | Metadata such as an end-user identifier. |
Call with the Anthropic SDK
Python:from anthropic import Anthropic
client = Anthropic(
api_key="sk-...",
base_url="https://api-direct.dimilinks.com/",
)
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
import Anthropic from '@anthropic-ai/sdk'
const client = new Anthropic({
apiKey: process.env.DIMILINKS_API_KEY,
baseURL: 'https://api-direct.dimilinks.com/',
})
const message = await client.messages.create({
model: 'claude-opus-4-8',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello' }],
})
Set the Anthropic SDK
base_url to https://api-direct.dimilinks.com/. The SDK appends /v1/messages automatically.Tool Use
curl "https://api-direct.dimilinks.com/v1/messages" \
-H "Authorization: Bearer $DIMILINKS_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Retrieve the current weather for a city",
"input_schema": {
"type": "object",
"properties": { "city": {"type": "string"} },
"required": ["city"]
}
}
],
"messages": [
{"role": "user", "content": "Check the current weather in Tokyo."}
]
}'
content[].type === "tool_use", execute the tool, then continue the conversation with a tool_result content block in a role=user message.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
Anthropic API version, e.g. 2023-06-01.
Example:
"2023-06-01"
Body
application/json
Example:
"claude-sonnet-5"
Example:
1024
Show child attributes
Show child attributes
Response
Anthropic message response. When stream is true the response is text/event-stream with Anthropic native events.