Skip to Content
LoremLLM

OpenAI

Chat Completions, Responses, Embeddings and Models, compatible with the OpenAI SDK.

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

import OpenAI from "openai";

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

Routes

RouteNotes
POST /v1/chat/completionsStreaming and non-streaming, tools, tool_choice, response_format
POST /v1/responsesStreaming events, function tools, reasoning summaries, previous_response_id, text.format
POST /v1/embeddingsDeterministic vectors: the same input always gets the same embedding
GET /v1/modelsLists the mock's model name

What maps to what

RequestUsed for
last user message or inputprompt matching
system / developer messages, instructionssystem matching
toolstools matching
tool messages, function_call_output itemstoolResult matching
response_format.json_schema, text.formatschema matching and json({ schema: true })
modelmodel matching, echoed back in the response
metadatametadata in function replies and templates

Streaming

Chat Completions sends chat.completion.chunk objects: delta.content, delta.tool_calls with function.arguments split across chunks, a final chunk with finish_reason, then data: [DONE]. With stream_options: { include_usage: true } an extra chunk carries usage.

Responses sends typed events: response.created, response.output_item.added, response.output_text.delta, response.function_call_arguments.delta, response.reasoning_summary_text.delta, response.output_item.done, and response.completed with usage. Reasoning only streams here, as it does on OpenAI. Chat Completions drops reasoning parts and reports their tokens in usage.completion_tokens_details.reasoning_tokens.

Reply partChat CompletionsResponses
textdelta.contentoutput_text item
toolCalldelta.tool_calls[]function_call item
finish("stop")finish_reason: "stop"status: "completed"
finish("length")finish_reason: "length"status: "incomplete", max_output_tokens
finish("tool-calls")finish_reason: "tool_calls"status: "completed"
finish("content-filter")finish_reason: "content_filter"status: "incomplete", content_filter

Errors

Errors use OpenAI's body, { "error": { "message", "type", "param", "code" } }, so the SDK raises its usual classes: error(429) becomes RateLimitError, error(400) becomes BadRequestError.

Without a server

@loremllm/openai gives you a fetch you pass to the SDK, so the same mock runs in process.

On this page