Skip to main content
POST
/
chat
/
completions
Create chat completion
curl --request POST \
  --url https://dimilinks.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "claude-sonnet-5",
  "messages": [
    {
      "content": "<string>",
      "name": "<string>",
      "tool_call_id": "<string>"
    }
  ],
  "stream": false,
  "temperature": 123,
  "top_p": 123,
  "max_tokens": 123,
  "stop": "<string>",
  "presence_penalty": 123,
  "frequency_penalty": 123,
  "tools": [
    {}
  ],
  "tool_choice": "<string>",
  "response_format": {},
  "user": "<string>"
}
'
import requests

url = "https://dimilinks.com/v1/chat/completions"

payload = {
    "model": "claude-sonnet-5",
    "messages": [
        {
            "content": "<string>",
            "name": "<string>",
            "tool_call_id": "<string>"
        }
    ],
    "stream": False,
    "temperature": 123,
    "top_p": 123,
    "max_tokens": 123,
    "stop": "<string>",
    "presence_penalty": 123,
    "frequency_penalty": 123,
    "tools": [{}],
    "tool_choice": "<string>",
    "response_format": {},
    "user": "<string>"
}
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',
    messages: [{content: '<string>', name: '<string>', tool_call_id: '<string>'}],
    stream: false,
    temperature: 123,
    top_p: 123,
    max_tokens: 123,
    stop: '<string>',
    presence_penalty: 123,
    frequency_penalty: 123,
    tools: [{}],
    tool_choice: '<string>',
    response_format: {},
    user: '<string>'
  })
};

fetch('https://dimilinks.com/v1/chat/completions', 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://dimilinks.com/v1/chat/completions",
  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',
    'messages' => [
        [
                'content' => '<string>',
                'name' => '<string>',
                'tool_call_id' => '<string>'
        ]
    ],
    'stream' => false,
    'temperature' => 123,
    'top_p' => 123,
    'max_tokens' => 123,
    'stop' => '<string>',
    'presence_penalty' => 123,
    'frequency_penalty' => 123,
    'tools' => [
        [
                
        ]
    ],
    'tool_choice' => '<string>',
    'response_format' => [
        
    ],
    'user' => '<string>'
  ]),
  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://dimilinks.com/v1/chat/completions"

	payload := strings.NewReader("{\n  \"model\": \"claude-sonnet-5\",\n  \"messages\": [\n    {\n      \"content\": \"<string>\",\n      \"name\": \"<string>\",\n      \"tool_call_id\": \"<string>\"\n    }\n  ],\n  \"stream\": false,\n  \"temperature\": 123,\n  \"top_p\": 123,\n  \"max_tokens\": 123,\n  \"stop\": \"<string>\",\n  \"presence_penalty\": 123,\n  \"frequency_penalty\": 123,\n  \"tools\": [\n    {}\n  ],\n  \"tool_choice\": \"<string>\",\n  \"response_format\": {},\n  \"user\": \"<string>\"\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://dimilinks.com/v1/chat/completions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"claude-sonnet-5\",\n  \"messages\": [\n    {\n      \"content\": \"<string>\",\n      \"name\": \"<string>\",\n      \"tool_call_id\": \"<string>\"\n    }\n  ],\n  \"stream\": false,\n  \"temperature\": 123,\n  \"top_p\": 123,\n  \"max_tokens\": 123,\n  \"stop\": \"<string>\",\n  \"presence_penalty\": 123,\n  \"frequency_penalty\": 123,\n  \"tools\": [\n    {}\n  ],\n  \"tool_choice\": \"<string>\",\n  \"response_format\": {},\n  \"user\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://dimilinks.com/v1/chat/completions")

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  \"messages\": [\n    {\n      \"content\": \"<string>\",\n      \"name\": \"<string>\",\n      \"tool_call_id\": \"<string>\"\n    }\n  ],\n  \"stream\": false,\n  \"temperature\": 123,\n  \"top_p\": 123,\n  \"max_tokens\": 123,\n  \"stop\": \"<string>\",\n  \"presence_penalty\": 123,\n  \"frequency_penalty\": 123,\n  \"tools\": [\n    {}\n  ],\n  \"tool_choice\": \"<string>\",\n  \"response_format\": {},\n  \"user\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "chatcmpl_xxx",
  "object": "chat.completion",
  "created": 1777080000,
  "model": "claude-sonnet-5",
  "choices": [
    {
      "index": 123,
      "message": {
        "content": "<string>",
        "name": "<string>",
        "tool_call_id": "<string>"
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_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>"
  }
}
/v1/chat/completions is the recommended DimiLinks chat endpoint. Its request and response structures match the official OpenAI endpoint, so you can use the OpenAI SDK directly. Set model to the name of a text model available to the current key to call Claude, GPT, or another model.

Request URL

POST https://dimilinks.com/v1/chat/completions
Content-Type: application/json
Authorization: Bearer <DIMILINKS_API_KEY>

Basic example

curl "https://dimilinks.com/v1/chat/completions" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Explain Pluto in one sentence."}
    ]
  }'
Response (abridged):
{
  "id": "chatcmpl_xxx",
  "object": "chat.completion",
  "created": 1777080000,
  "model": "claude-sonnet-5",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 32,
    "completion_tokens": 24,
    "total_tokens": 56
  }
}

Streaming

Add "stream": true to the request. The server returns incremental chunks as text/event-stream and ends with data: [DONE].
curl "https://dimilinks.com/v1/chat/completions" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -H "Content-Type: application/json" \
  -N \
  -d '{
    "model": "gpt-5.5",
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a four-line poem about the deep sea."}
    ]
  }'
Each event has this structure:
data: {"id":"chatcmpl_xxx","object":"chat.completion.chunk","model":"gpt-5.5",
"choices":[{"index":0,"delta":{"content":"Far"},"finish_reason":null}]}

Parameters

The table lists common fields. Any unlisted field is passed through to the upstream provider when the model supports it.
ParameterTypeDefaultDescription
modelstringRequiredModel ID, such as claude-sonnet-5, claude-opus-4-8, gpt-5.5, gpt-5.6-terra, or qwen3.7-max.
messagesarrayRequiredMessage array containing at least one role=user item. Supported roles are system / user / assistant / tool.
streambooleanfalseWhen true, returns SSE streaming chunks.
temperaturenumberModel defaultSampling temperature from 0 to 2.
top_pnumberModel defaultNucleus sampling probability from 0 to 1.
max_tokensintegerModel defaultMaximum tokens in one response; we recommend setting it explicitly for Claude models.
stopstring | string[]EmptyStop generation when one of these sequences is matched.
presence_penaltynumber0Penalty for repeating topics, from -2 to 2.
frequency_penaltynumber0Penalty for repeating words, from -2 to 2.
toolsarrayEmptyTool definitions compatible with OpenAI Tool Calling.
tool_choicestring | objectautoControls whether a specific tool must be called.
response_formatobjectEmptyRequests JSON output, for example { "type": "json_object" }.
userstringEmptyEnd-user identifier for auditing and rate limiting.
ScenarioModels
General chat / long documentsclaude-sonnet-5, claude-opus-4-8, gpt-5.5
Complex reasoning / codingclaude-opus-4-8, kimi-k2.7-code, gpt-5.6-terra
Chinese-language and general tasksqwen3.7-max, glm-5.2, MiniMax-M3
Low-cost batch tasksclaude-haiku-4-5, gpt-5.4-mini, deepseek-v4-flash
Multimodal visiongpt-image-2 is dedicated to image generation. Visual chat support varies by model; first inspect input_modalities from /v1/models.

Call with the OpenAI SDK

Python:
from openai import OpenAI

client = OpenAI(
    api_key="sk-...",
    base_url="https://dimilinks.com/v1",
)

response = client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[
        {"role": "system", "content": "You are a rigorous assistant."},
        {"role": "user", "content": "Explain the Fourier transform."},
    ],
    max_tokens=1024,
)

print(response.choices[0].message.content)
Node.js:
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.DIMILINKS_API_KEY,
  baseURL: 'https://dimilinks.com/v1',
})

const response = await client.chat.completions.create({
  model: 'gpt-5.5',
  messages: [{ role: 'user', content: 'Hello' }],
})

Tool calling

curl "https://dimilinks.com/v1/chat/completions" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [
      {"role": "user", "content": "Check the current weather in Tokyo."}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Retrieve the current weather for a city",
          "parameters": {
            "type": "object",
            "properties": {
              "city": {"type": "string"}
            },
            "required": ["city"]
          }
        }
      }
    ]
  }'
When the model returns tool_calls, execute the tool, add its result to messages as a role=tool message, and call the endpoint again.

Error handling

Failed requests return the OpenAI-style error wrapper. See Errors. If an upstream connection closes during a streaming request, the final event may not be [DONE]; treat a closed connection as a retryable error as well.

Authorizations

Authorization
string
header
required

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

Body

application/json
model
string
required
Example:

"claude-sonnet-5"

messages
object[]
required
stream
boolean
default:false
temperature
number
top_p
number
max_tokens
integer
stop
presence_penalty
number
frequency_penalty
number
tools
object[]
tool_choice
response_format
object
user
string

Response

Chat completion result. When stream is true the response is text/event-stream.

id
string
Example:

"chatcmpl_xxx"

object
string
Example:

"chat.completion"

created
integer
Example:

1777080000

model
string
Example:

"claude-sonnet-5"

choices
object[]
usage
object