POST /v1/messages

POST /v1/messages

The Anthropic Messages API. Anthropic SDKs and tools such as Claude Code work when you set their base URL to https://api.abliteratedllm.dev. They add /v1/messages themselves, so leave /v1 off the base URL.

Placeholders: $API_BASE is https://api.abliteratedllm.dev/v1, $API_ORIGIN is https://api.abliteratedllm.dev, and $YOUR_KEY is your API key.

Request

curl $API_ORIGIN/v1/messages \
  -H "x-api-key: $YOUR_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "glm-5.3-flash-abliterated",
    "max_tokens": 1024,
    "system": "You are a gothic horror narrator.",
    "messages": [{"role": "user", "content": "Describe the abandoned manor in one paragraph."}]
  }'

Authorization: Bearer $YOUR_KEY works in place of x-api-key. The anthropic-version header is accepted but not required.

Abridged response:

{
  "id": "…",
  "type": "message",
  "role": "assistant",
  "content": [{ "type": "text", "text": "The manor leaned against the storm…" }],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 29,
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0,
    "output_tokens": 187
  }
}

Parameters

Fields not listed here are passed to the model unchanged.

FieldNotes
modelRequired. Any id from GET /v1/models, currently glm-5.3-flash-abliterated, deepseek-v4.1-flash or deepseek-v4-pro.
max_tokensRequired, as in the Anthropic API. A request without it fails with 400 invalid_request. Values above the model's max output (max_output_tokens in GET /v1/models), or above 4096 on trial accounts, are lowered, not rejected.
messages, systemText only. image blocks fail with 400 unsupported_content.
thinkingPassed through. See below.
streamtrue for server-sent events. Without it, the answer is generated as a stream on our side and returned as one message when it ends, so a request cut by the time limit or a disconnect is billed for the output generated so far.
tools, tool_choiceClient tools with an input_schema, as in the Anthropic API.
temperature, top_p, top_k, stop_sequencesPassed through after a range check: temperature 0 to 2, top_p 0 to 1, top_k 0 to 100, and stop_sequences an array of strings (no limit on how many). A value outside its range fails with 400 invalid_request before anything is charged.

Thinking

thinking is passed through, so the usual Anthropic forms work:

{ "thinking": { "type": "enabled", "budget_tokens": 4096 }, "max_tokens": 8192 }
  • budget_tokens must be at least 1024 and lower than max_tokens. When max_tokens is lowered (to the model's max output, to 4096 on trial accounts, or to what your balance covers), a budget_tokens that no longer fits is lowered to max_tokens - 1, or thinking is turned off if that would fall below 1024.
  • The models reason by effort level rather than to an exact token budget. A budget of 1024 to 4999 runs at low effort, 5000 to 9999 at medium, and 10000 or more at high.
  • {"type": "disabled"} turns reasoning off.
  • output_config.effort ("low", "medium" or "high") is accepted too, and wins when both are set.

Thinking arrives as thinking content blocks. Thinking tokens are output tokens: they count toward max_tokens and are billed at the output price.

Streaming

With "stream": true you receive the standard event sequence: message_start, then content_block_start, content_block_delta and content_block_stop for each block, then message_delta and message_stop. Until the first event arrives, the stream carries an SSE comment line, : ping, every 15 seconds, which SSE clients ignore.

Token usage arrives only in the final message_delta event. The usage in message_start is always zero, so don't read it.

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"input_tokens":29,"cache_read_input_tokens":0,"output_tokens":187}}

Cache-read pricing

Prompt caching is automatic. You don't need cache_control markers. Tokens read from cache are reported in usage.cache_read_input_tokens and billed at the cached-input price. input_tokens already excludes them, and there is no charge for writing to the cache (cache_creation_input_tokens is always 0):

cost = input_tokens × input price
     + cache_read_input_tokens × cached-input price
     + output_tokens × output price

Prices are per 1M tokens and each term is rounded up to the next $0.000001. See GET /v1/models for current prices.

Not available

  • Only POST /v1/messages is served. Token counting (/v1/messages/count_tokens) and message batches are not available.
  • Server-side tools that Anthropic runs for you, such as web search, web fetch and code execution, are not available. Define them as client tools and run them yourself.

Errors

Errors on this endpoint use the Anthropic shape, {"type": "error", "error": {"type", "message"}}, so the Anthropic SDKs raise their usual exception classes. This shape has no code field: you get the HTTP status, error.type and a message. The Errors page lists which status each condition returns.