Skip to Content
LoremLLM

Vercel AI SDK

A UI message stream endpoint for useChat, plus provider routes for generateText and streamText.

There are two ways to use a mock with the AI SDK.

useChat

Every mock serves an AI SDK UI message stream at:

POST https://api.loremllm.com/m/<mock>/api/chat

Point useChat at it with the default transport:

import { useChat } from "@ai-sdk/react";
import { DefaultChatTransport } from "ai";

const { messages, sendMessage } = useChat({
  transport: new DefaultChatTransport({
    api: "https://api.loremllm.com/m/support-bot/api/chat",
  }),
});

The response is a UI message stream (SSE with the x-vercel-ai-ui-message-stream: v1 header), the same thing result.toUIMessageStreamResponse() returns from a route handler:

Reply partStream parts
texttext-start, text-delta, text-end
reasoningreasoning-start, reasoning-delta, reasoning-end
toolCalltool-input-start, tool-input-delta, tool-input-available
with outputthen tool-output-available (or tool-output-error with error)
sourcesource-url
each model stepstart-step, finish-step

The stream opens with start and closes with finish, whose messageMetadata holds scenario, usage and cost. Resolved tool calls render as output-available tool parts, so tool UIs work without a backend.

CORS is open on this route, so browser apps on any origin can call it.

generateText and streamText

The AI SDK's OpenAI and Anthropic providers work with a custom base URL:

import { createOpenAI } from "@ai-sdk/openai";
import { streamText } from "ai";

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

const result = streamText({ model: loremllm("gpt-4.1"), prompt: "Refund order A-1042" });

loremllm(...) calls the Responses API, the provider's default. Use loremllm.chat(...) for Chat Completions. createAnthropic({ baseURL: "https://api.loremllm.com/m/support-bot/v1" }) works the same way.

No network at all

@loremllm/ai-sdk gives you a chat transport and a language model that run the mock in the browser or in your test process.

On this page