API Reference

Vercel AI SDK compatible endpoint for streaming chat

Once you've created the token for a user, you can build your chatbot UI using our streaming chat endpoint which is compatible with Vercel AI SDKs useChat, you can read more about it here.

Here is an example:

'use client';

import { useChat } from 'ai/react';

export default function Page() {
  const { messages, input, handleInputChange, handleSubmit } = useChat({
    api: `https://manageprompt.com/api/v1/chat/${token}/stream`,
    keepLastMessageOnError: true,
  });

  return (
    <>
      {messages.map(message => (
        <div key={message.id}>
          {message.role === 'user' ? 'User: ' : 'AI: '}
          {message.content}
        </div>
      ))}

      <form onSubmit={handleSubmit}>
        <input name="prompt" value={input} onChange={handleInputChange} />
        <button type="submit">Submit</button>
      </form>
    </>
  );
}