Anthropic Messages API
An Anthropic-compatible /v1/messages endpoint for every chat model on the platform, so the Anthropic SDKs, Claude Code and other Anthropic clients work by changing only the base URL and key. Authenticate with x-api-key (or Authorization: Bearer). Pricing, plan limits and model access are the same as Chat Completions; errors use Anthropic's error format.
POST
/v1/messagesQuick example
curl
curl https://api.pawan.krd/v1/messages \
-H "x-api-key: pk-your_key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "pkrd/cosmosrp-3.5",
"max_tokens": 1024,
"system": "You are a helpful assistant.",
"messages": [{ "role": "user", "content": "Hello!" }]
}'Python (Anthropic SDK)
import anthropic
client = anthropic.Anthropic(base_url="https://api.pawan.krd", api_key="pk-your_key")
message = client.messages.create(
model="pkrd/cosmosrp-3.5",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a haiku about Erbil."}],
)
print(message.content[0].text)Parameters
modelstringrequired- Any chat model ID on the platform.
max_tokensintegerrequired- Maximum tokens to generate.
messagesarrayrequired- User / assistant turns. Content blocks:
text,image(base64 or url),document(text or base64 PDF),tool_use,tool_result. systemstring | array- System prompt (text blocks; cache_control is accepted and ignored).
toolsarray- Client tools with
input_schema. Anthropic server tools (web search, code execution, computer use, …) are not available and are ignored. tool_choiceobjectauto,any,toolornone;disable_parallel_tool_useis honoured.thinkingobject{ type: "enabled", budget_tokens }turns on reasoning for reasoning models and returnsthinkingblocks.streamboolean- Anthropic server-sent events (message_start … message_stop).
stop_sequencesarray- Up to 4 stop sequences.
temperature / top_p / top_knumber- Sampling controls, clamped to the model's ranges.
metadata.user_idstring- End-user identifier.
Tool use
The model replies with tool_use blocks and stop_reason: "tool_use". Send the result back in the next user message as a tool_result block with the same tool_use_id.
Request with a tool
{
"model": "openai/gpt-oss-20b",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Current weather for a city",
"input_schema": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
],
"messages": [{ "role": "user", "content": "Weather in Duhok?" }]
}Other endpoints
POST
/v1/messages/count_tokensGET
/v1/modelscount_tokens returns { "input_tokens": N } and is free. /v1/models answers in Anthropic's format when the anthropic-version header is sent.
Claude Code
See Coding Agents to run Claude Code against any model on Pawan.Krd.