Skip to main content
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 /v1/messages directly. It follows the official Anthropic protocol.
The native Anthropic protocol uses the dedicated api-direct.dimilinks.com domain, which is different from the OpenAI-compatible dimilinks.com/v1 base URL. Both use the same 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
We recommend including the 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."}
    ]
  }'
Response (abridged):
{
  "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

ParameterTypeRequiredDescription
modelstringYesClaude model ID, such as claude-opus-4-8, claude-sonnet-5, or claude-haiku-4-5.
max_tokensintegerYesMaximum output tokens for one response.
messagesarrayYesMessage array. role supports user / assistant; content supports a string or [{type:"text",...}] content blocks.
systemstring | arrayNoSystem prompt, either a string or an array such as [{type:"text",...}].
temperaturenumberNoSampling temperature from 0 to 1.
top_pnumberNoNucleus sampling probability from 0 to 1.
top_kintegerNoTop-k sampling.
stop_sequencesstring[]NoStop generation when one of these sequences is matched.
streambooleanNoWhen true, returns SSE streaming events.
toolsarrayNoNative Anthropic Tool Use definitions.
tool_choiceobjectNoControls whether a specific tool must be used.
metadataobjectNoMetadata 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)
Node.js:
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."}
    ]
  }'
If the model response contains content[].type === "tool_use", execute the tool, then continue the conversation with a tool_result content block in a role=user message.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

anthropic-version
string

Anthropic API version, e.g. 2023-06-01.

Example:

"2023-06-01"

Body

application/json
model
string
required
Example:

"claude-sonnet-5"

max_tokens
integer
required
Example:

1024

messages
object[]
required
system
temperature
number
top_p
number
top_k
integer
stop_sequences
string[]
stream
boolean
default:false
tools
object[]
tool_choice
object
metadata
object
thinking
object

Response

Anthropic message response. When stream is true the response is text/event-stream with Anthropic native events.

id
string
Example:

"msg_xxx"

type
string
Example:

"message"

role
string
Example:

"assistant"

model
string
Example:

"claude-sonnet-5"

content
object[]
stop_reason
string
stop_sequence
string
usage
object