Skip to content
Rebyte Agent SDK

Rebyte Agent SDK

Use the official OpenAI client with Rebyte extensions, React packages, CLI and runnable examples.

On this pageReact application templatesRun the Node templateVerify the flowRestore an existing SessionServer integrationApplication function results

The Rebyte Agent SDK combines the official openai API client with Rebyte-specific Workflow and Schedule resources, React hooks, UI components, a server adapter, the CLI and runnable examples. Rebyte runs the Agent Loop and persists Sessions.

The React templates were previously called AppKit. They are one part of the SDK. The GitHub repository is now named rebyte-agent-sdk. Existing npm package names are unchanged. The retired @rebyteai/agent-sdk client fork is not the package to install.

ComponentInstall or openPurpose
Official API clientopenai@7.15.0Agents, Sessions, streaming, Files and Artifacts
Rebyte extensions@rebyteai/agent-extensionsWorkflow Agents and Schedules
React hooks@rebyteai/agent-reactConversation state, history, function waits and result submission
Chat components@rebyteai/agent-uiOptional React chat interface
Server adapter@rebyteai/agent-serverNode/Cloudflare proxy that keeps the organization key on your server
CLI@rebyteai/cliManage saved Agents from a manifest
ExamplesExample catalogAPI recipes and complete Node/Cloudflare applications

Standard backend integrations need only openai. Add the extension package for Rebyte resources, or the React packages for a browser application. These packages do not run the separate @openai/agents execution framework.

React application templates

text
React UI → your application server → official openai client → Rebyte Agents API

The current npm release, 0.3.0, uses the official client. Existing 0.2.x npm releases still depend on the old client fork. Install the components your application uses:

Terminal
pnpm add @rebyteai/agent-react@0.3.0 @rebyteai/agent-ui@0.3.0 @rebyteai/agent-server@0.3.0
pnpm add -D @rebyteai/cli@0.3.0

Version 0.4.0 is available in the repository source; npm publication is pending. The function-wait features below require 0.4.0. Use the source setup below to try them now; installing npm 0.3.0 does not include those additions.

Run the Node template

Use Node.js 22+ and pnpm 10:

Terminal
git clone https://github.com/ReByteAI/rebyte-agent-sdk.git
cd rebyte-agent-sdk
pnpm install --frozen-lockfile
pnpm build
cp examples/react-chat/.env.example examples/react-chat/.env.local

Put your organization key in .env.local. It needs tasks:read, tasks:write, files:read and files:write, and the organization needs credit. The key stays on the application server; do not put it in a VITE_ variable.

dotenv
REBYTE_API_KEY=rbk_replace_me
REBYTE_AGENT_ID=
REBYTE_API_URL=https://api.rebyte.ai/v1

Create one saved Agent with the official client, using the template's setup script:

Terminal
cd examples/react-chat
pnpm exec tsx scripts/create-agent.ts

Copy the printed REBYTE_AGENT_ID into .env.local, then run pnpm dev. Open http://127.0.0.1:4100. The application server is on 4101.

Verify the flow

  1. Send a message and watch the response stream.
  2. Ask for a file in /workspace/outputs and download its Artifact.
  3. Upload a file and ask the Agent to read it.
  4. Send a follow-up or reload; the same Session retains its history and files.
  5. Start a new conversation for a separate Session.

The event inspector shows native agent.session.* events. Stop submits a cancellation event. New conversation preserves the previous Session; delete it explicitly when finished to release its environment and Artifacts.

Restore an existing Session

Save the Session ID reported by onSession and pass it as initialSessionId when mounting useAgentSession again. The React hook loads saved Items, Turns and Artifacts through your application server and reconstructs the conversation. The server adapter retrieves all history pages from Rebyte's client.beta.agents.sessions.items.list() endpoint. For an active or waiting recovered Session, the React hook polls persisted state until the work settles.

See Retrieve conversation history for the API and curl examples. Persist your user-to-Session association and authorize access on your server; an organization API key is not per-user authorization. The history can be restored without saving every streamed delta in the browser.

Server integration

The shared @rebyteai/agent-server adapter creates an official client with the Rebyte endpoint explicitly configured. Its Node and Cloudflare templates share the same Session, upload, download and event routes. Add application login and user-to-Session authorization on every route before serving other users.

The frontend subscribes to live events before submitting input. It uses the official event types and SSE parser, and keeps UI state in useAgentSession. The React templates use native Agents events.

Application function results

In SDK 0.4.0, chat.status === 'requires_action' is a normal waiting state. chat.requiredActions exposes the pending calls after live events or Session restoration. Execute them in your application's authorized handler; a function_call Item alone does not authorize execution.

typescript
await chat.submitToolResult({
  turn_id: action.turn_id,
  call_id: action.call_id,
  success: true,
  output: JSON.stringify(result),
});

The hook submits one result per request with a stable per-call idempotency key. Use success: false and error for failures. Your application must persist its operation/result by call_id to avoid repeating external effects on reload. The hook never runs handlers automatically. It also observes results submitted by a backend worker, supports Dynamic Workflow handoffs, and keeps Stop available while waiting. send() completes when the Turn settles.

These function-wait improvements require SDK 0.4.0 or later. See the function guide and Workflow function recipe.

See Upgrade to 0.3.0 for replacing the old client and moving Workflow and Schedule calls to the optional extension.

See the Node template and Cloudflare template.