useChatfor AG-UI streaming chatuseAgentfor direct agent invocationuseCompletionfor one-shot text generation
/api/ag-ui. Use the route from Chat UI or Agents, run veryfront dev, then open the page that renders the hook.
Prerequisites
- A page that can render React client components.
- An AG-UI route mounted at
/api/ag-ui(or another path you pass viaapi). - For
useCompletion, an API route that returns plain text or SSE for thecompletecall.
useChat
useChat exposes messages, input state, submit handlers, stop/reload handlers, model state, branch helpers, and inference status. It uses AG-UI for Veryfront AG-UI routes created with createAgUiHandler.
useAgent
UseuseAgent for direct agent invocation without the chat protocol:
useCompletion
Inference mode
useChat exposes inferenceMode so your UI can show whether inference is running through cloud, server-local, or browser runtime.
Verify it worked
Render the hook in a page and exercise the surface you care about:useChat: submit a message.chat.messagesshould grow andisLoadingshould flip while the response streams.useAgent: callinvoke.statusshould move throughrunningtoidleandmessagesshould contain the agent’s reply.useCompletion: callcomplete.completionshould populate andisLoadingshould flip back tofalsewhen the response ends.
isLoading never flips back, check the network tab for the request to
your API and the dev-server log for handler errors.