BF Streaming API (Assistants)
The BetterForms assistants endpoint provides stateful assistant-style conversations with streamed updates.
Overview
The current server registers this endpoint at:
POST /stream/create/assistants
In the current implementation, the registered assistants provider is:
openai
This endpoint supports:
creating a new assistant thread
reusing an existing thread with
thread_idstreaming assistant deltas over BetterForms messaging
non-streaming polling mode
stopping an active run with
/stream/create/assistants/stop
Request Shape
apiKey
string
BetterForms API key for the endpoint request
channels
array
BetterForms messaging channels for streamed responses
actionName
string
Named action that handles streamed messages
payload
object
Assistant provider payload
Payload Object
The payload object contains all the necessary information for the assistant to process your request.
provider
string
Provider name. Current implementation defaults to and currently supports openai.
apiKey
string
Provider API key, for example your OpenAI API key
stream
boolean
If true, BetterForms streams events through messaging. If false, BetterForms polls until the run finishes and returns the final response.
messages
array
Messages to create or continue the assistant conversation
thread_id
string
Optional existing thread ID to continue
model
string
Optional model override
instructions
string
Optional assistant instructions
tools
array
Optional tool definitions
Tool calls are handled by the BetterForms assistants backend flow. In current builds, that backend work is routed through the assistants tool execution path rather than being documented as a generic Common Hook contract.
Example Request
Streaming Response
When payload.stream is true, the endpoint returns as soon as the run is created.
Typical result:
During streaming, BetterForms emits events to your configured channel and actionName.
Important event types include:
threadInfodeltafunction_callenderror
Example threadInfo payload:
This is the event your frontend can use to store the active assistant thread and run identifiers for later continuation or cancellation.
Non-Streaming Response
When payload.stream is false, BetterForms creates or continues the run, polls until completion, and returns the final assistant content directly in the HTTP response.
Typical shape:
Stop Endpoint
Active assistant runs can be stopped with:
POST /stream/create/assistants/stop
Required request fields:
Behavior notes:
both
threadIdandrunIdare requiredalready completed or already cancelled runs are handled gracefully
browser-side BetterForms workflows typically call this through the
assistantStopaction
Notes
Use
thread_idin the request payload to continue an existing assistant thread.Streaming requests emit
threadInfomessages that containassistantThreadIdandrunId.If you want the more general multi-provider/tooling contract, see BF Streaming API (LLM Query).
Related Pages
Last updated
Was this helpful?