Skip to Content
LoremLLM

Anthropic

The Messages API, compatible with the Anthropic SDK.

Base URL: https://api.loremllm.com/m/<mock>

import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic({
  baseURL: "https://api.loremllm.com/m/support-bot",
  apiKey: process.env.LOREMLLM_KEY,
});

Routes

RouteNotes
POST /v1/messagesStreaming and non-streaming, tools, tool_choice, extended thinking
POST /v1/messages/count_tokensCounts with the reported model's tokenizer

What maps to what

RequestUsed for
last user text blockprompt matching
systemsystem matching
toolstools matching
tool_result blockstoolResult matching, including is_error: true
thinking enabledreasoning(...) parts are sent as thinking blocks
output_format, or a forced toolschema matching and json(...) replies

Responses

The stream uses Anthropic's events: message_start, content_block_start, content_block_delta (text_delta, input_json_delta, thinking_delta), content_block_stop, message_delta with stop_reason and usage, and message_stop.

Reply partstop_reason
finish("stop")end_turn
finish("length")max_tokens
finish("tool-calls")tool_use
finish("content-filter")refusal

usage reports input_tokens, output_tokens, cache_read_input_tokens and cache_creation_input_tokens, filled from usage(...).

Errors

Errors use Anthropic's body, { "type": "error", "error": { "type", "message" } }. error(529) returns overloaded_error, the one Anthropic clients most often need to retry. Mid-stream errors arrive as an error event, as they do from the real API.

Without a server

@loremllm/anthropic runs the same mock in process.

On this page