LLMs API Reference
Concise reference for the public exports from react-actions-chat-llms.
Main Flow Creator
createChatTextGenerationFlow(config)
Creates a reusable flow that reads chat messages, converts them into LLM messages, calls a text generator, and adds the assistant reply back into the transcript.
Returned API:
respond(): Promise<GeneratedText | null>respondToMessages(messages): Promise<GeneratedText | null>
Important config fields:
generatorsystemPromptgetMessagesaddMessagesetLoadingcreateAssistantMessagecreateErrorMessagethrowOnError
Backend Helper
createTextGenerationBackend(config)
Creates a TextGenerator that POSTs transcript messages to your own backend route.
Important config fields:
urlcredentialsheadersfetch
Core Types
TextGenerator
Generator contract with:
generateText(request): Promise<GeneratedText>
GenerateTextRequest
Request shape with:
messagesmaxOutputTokens?signal?
GeneratedText
Successful generation result with:
text
LLMMessage
Provider-ready transcript message with:
rolecontent
LLMMessageRole
Supported roles:
assistantdevelopersystemuser
ChatTextGenerationContext
Flow context with:
chatMessagesllmMessages
ChatTextGenerationFlowMessage
Chat message shape accepted by respondToMessages(...).
Shared Utilities
FetchLike
Fetch-compatible type you can pass when you want a custom request implementation for tests or server runtimes.