API
ReByte provides a set of APIs to make it easy to integrate ReByte into your own applications. There are three main APIs: File API, Tool API, and Thread API.
Tool API
Tool API allows you to call the tool you created on ReByte. It supports:
Thread API
Thread API allows you to create a conversation thread and add messages to the thread.
Combined with the Tool API, you can create a tool with memory without having your own backend.
File API
Allows you to upload files to ReByte. Uploaded files can be used in the agent's actions, such as File Loader
action.
Tool API
The Tool API allows you to call customized tools from your own applications. It provides a set of APIs to interact with the tool, such as sending messages, uploading files, and creating threads.
Overview
A typical integration of the Tool API has the following flow:
Create a Tool on rebyte tool editor by defining its custom actions, such as
Model
,Data
,Utilities
,Control Flow
, etc. Pick the model and parameters that you want to use.Create a Thread when a user starts a conversation.
Add Messages to the Thread as the user asks questions.
Run the Tool on the Thread to generate a response.
Step by step
Create a Tool.
Here, we'll just use this "Chat with GPT3.5 tool" as an example. Remember to test your tool first and make sure it works as expected. Also, click "Deploy" to make it available for the API.
Create a thread
Before using the API, get your API key from the API console on the sidebar. You should use this key to authenticate your requests.
When creating a thread, you can append the messages to the thread when creating it. You can also attach metadata to the thread. This can be useful for storing additional information about the object in a structured format.
In the response, you will find the thread id. You can use this thread id to add messages to the thread and run the tool on the thread.
Example Response
Add messages to the thread
In the response, you can see the message information.
Example Response
Run the tool on the thread
In order to run the tool on the thread, you should get the url from deploying your tool and make a request to this url.
When calling the tool, you should specify the thread id, and you will be able to get all the messages and metadata from the thread.
You can also use "contentOnly:true" to get only the content of the messages.
Get the messages from the thread
In the response, you will get the list of all messages on the thread.
Example Response
Blocking and Non-blocking calls
Add 'blocking' parameter to the request body to specify whether the call should be blocking or non-blocking. If 'blocking' is set to true, the call will wait for the response from the tool. If 'blocking' is set to false, the call will return immediately with a run_id, which can be used to check the status of the call later.
Streaming
Add 'stream' parameter to the request body to specify whether the call should be streaming or not. If 'stream' is set to true, the call will return a stream of messages from the tool as they are generated. If 'stream' is set to false, the call will return the final response from the tool.
Thread API
Create thread
POST https://rebyte.ai/api/sdk/threads
Create a new thread.
Request body
messages: An array of messages to start the thread with.
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.
Example Request
Return
A thread object.
Example
List threads
GET https://rebyte.ai/api/sdk/threads
Get list of threads.
Query parameters
limit: An integer, with the maximum number of threads to return. Default is 20.
order: A string, with the order to return the threads. Default is desc.
before: A string, used as a cursor for use in pagination. after is an object ID that defines your place in the list.
after: A string, used as a cursor for use in pagination. before is an object ID that defines your place in the list.
Example Request
Return
A list of thread objects.
Example
Get thread
GET https://rebyte.ai/api/sdk/threads/{thread_id}
Get a thread by id.
Path parameters
thread_id(required): A string, with the ID of the thread to retrieve.
Example Request
Returns The thread object matching the specified ID.
Example
Update thread
POST https://rebyte.ai/api/sdk/threads/{thread_id}
Update a thread.
Path parameters
thread_id(required): A string, with the ID of the thread to retrieve.
Request body
metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.
Example Request
Returns The modified thread object matching the specified ID.
Example
File API
Upload file
POST https://rebyte.ai/api/sdk/files
Upload a file that can be used across various endpoints.
Request Body
file(required): File object to be uploaded.
Example Request
Return
Returns an object with message, fileId and path.
Response
List files
GET https://rebyte.ai/api/sdk/files
Get list of files.
Example Request
Return
Returns a list of files.
Response
Retrieve file
GET https://rebyte.ai/api/sdk/files/{fileId}
Retrieve file by fileId.
Example Request
Return
Returns a file object.
Response
Retrieve file content
GET https://rebyte.ai/api/sdk/files/{fileId}/content
Retrieve file content by fileId.
Example Request
Return
Returns the content of the file.
Response
Delete file
DELETE https://rebyte.ai/api/sdk/files/{fileId}
Delete file by fileId.
Example Request
Return
Returns a message object.
Response
Last updated