Using steamship in a react context is often as simple as making an API request to your agent. To interact with your agent you'll need a few environment variables that must be securely stored server side. As such, if you're working with React you'll likely be working in one of the more popular frameworks like Next.js or Remix.

As it stands, we have a few Next.js specific utilites that make getting started with steamship as easy as possible. We'll be adding support for other frameworks in the future.

This package also ships with a few React components and hooks that make it easy to get started with steamship in a React context, regardless of framework.


  npm i @steamship/react



@steamship/react integrates directly with vercels ai package.

Setup Env Vars


Your STEAMSHIP_API_KEY can be found at (opens in a new tab).

Your STEAMSHIP_AGENT_URL can be found by navigating to Dashboard > Your Agent > API > POST /prompt > cURL. This should look something like{workspace-id}/{package-instance-id}/prompt

Setup api endpoints

Handle chat requests by creating a file: app/api/steamship/chat/route/ts

import { StreamingTextResponse } from "ai";
export const POST = async (req: Request) => {
  const { messages, id } = (await req.json()) as {
    messages: { role: "user" | "assistent"; content: string }[];
    id: string;
  const mostRecentUserMessage = messages
    .find((message) => message.role === "user");
  const steamshipResponse = await fetch(
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${process.env.STEAMSHIP_API_KEY}`,
      method: "POST",
      body: JSON.stringify({
        question: mostRecentUserMessage?.content,
        chat_session_id: id,
  return new StreamingTextResponse(
    steamshipResponse.body as ReadableStream<any>

Handle resolving requests by creating a file: app/api/steamship/chat/block/[blockid]/route.ts

import { NextResponse } from "next/server";
const GET = (req: Request, context: { params: any }) => {
  const blockId = context.params.blockId;
  return fetch(`${blockId}/raw`, {
    headers: {
      Authorization: `Bearer ${process.env.STEAMSHIP_API_KEY}`,
    method: "GET",
  }) as Promise<NextResponse>;
export { GET };

Use in components

You can refer directly to the useChat docs for the easiest way to interact with your steamship api endpoints. You'll need to set the api endpoint to match the endpoints we previous setup. In the example below we also create a dummy chat ID.

'use client';
import { useChat } from 'ai/react';
import { SteamshipMessage } from '@steamship/react';
export default function Chat() {
  const chatUUID = useMemo(() => uuidv4(), []);
  const { messages, input, handleInputChange, handleSubmit } = useChat({
    id: chatUUID,
    body: { id: chatUUID },
    api: '/api/steamship/chat'
  return (
      { => (
        <div key={}>
          {m.role === 'user' ? 'User: ' : 'AI: '}
          <SteamshipMessage message={m.content} />
      <form onSubmit={handleSubmit}>
          Say something...
          <input value={input} onChange={handleInputChange} />
        <button type="submit">Send</button>

Steamship agents often offer multi-modal support. To provide out of the box support for multi-modal responses, you can use a few utility methods.

SteamshipMessage will take a message from useChat and support text, markdown, syntax highlighting, audio streams, and images.

useBlockUrl will take a blockId returned from steamship and fetch the raw data associated with it. This is used for fetching audio and image data, for example.

As an example, you can import or look at the SteamshipChatPrompt component. (opens in a new tab)