API
Anthropic Messages
Anthropic Messages at /v1/messages. Anthropic SDKs take the bare origin https://inference.dagon.so as base URL (no /v1); errors on this endpoint use the Anthropic error shape.
On this page
Request
POST/v1/messages
curl https://inference.dagon.so/v1/messages \
-H "x-api-key: $DAGON_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "abliterated-model-large-flash", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'# pip install anthropic
import os
import anthropic
client = anthropic.Anthropic(base_url="https://inference.dagon.so", api_key=os.environ["DAGON_KEY"])
msg = client.messages.create(
model="abliterated-model-large-flash",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)// npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://inference.dagon.so", apiKey: process.env.DAGON_KEY });
const msg = await client.messages.create({
model: "abliterated-model-large-flash",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(msg.content[0].type === "text" ? msg.content[0].text : msg.content);Forwarded fields
model, messages, max_tokens, system, stop_sequences, stream, temperature, top_p, top_k, tools, tool_choice, thinking, metadata. Anything else non-null is 400 unsupported_parameter.
max_tokensis required (400 missing_max_tokens), at most 65,536 or the model's limit.tool_choicemay be{type: "auto" | "any" | "none"}or{type: "tool", name}naming one of the request's tools. Server tools (web search, web fetch, code execution, MCP) are refused.- No
anthropic-betavalue is accepted: any beta is400 unsupported_parameter.container,context_management,mcp_serversandfilesources are refused too. - Images:
imageblocks with abase64source.
Count tokens
POST/v1/messages/count_tokens
Free. Validated like /v1/messages and answered {"input_tokens": n}. It needs a key with credit available (402 insufficient_credits otherwise) and is limited to 600 calls per hour and 2 in flight per account. Counting is served by abliteration.ai, so a model it does not serve on Messages is 400 unsupported_endpoint.
curl https://inference.dagon.so/v1/messages/count_tokens \
-H "x-api-key: $DAGON_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "abliterated-model-large-flash", "messages": [{"role": "user", "content": "Hello"}]}'Last updated