Introduction
The client library for JavaScript/TypeScript offers an easy-to-use interface to interact with Port’s services.Installation
To integrate the client into your project, install it using npm:Features
Calling Endpoints
Port manages endpoint requests through a queue system, ensuring reliability and scalability. Use thesubscribe method to submit a request and await the result.
Example:
Queue Management
Manage your requests with these methods:Submitting a Request
Submit a request and retrieve therequest_id for later use.
Example:
Checking Request Status
Retrieve the status of a request. Example:Retrieving Request Results
Fetch the result of a completed request. Example:Storage
Thestorage API allows you to upload files and receive a URL, which can then be used in your model endpoint requests. This is particularly useful for models that require file inputs, such as image-to-video or speech-to-text.
Maximum file size: 100MB
Uploading Files in the Browser
You can allow users to upload files directly from their browser. The following example shows how to use an<input type="file"> element to select a file and upload it.
Uploading Files in Node.js
On the server-side with Node.js, you can read files from the local filesystem and upload them.Automatic Uploads with Model Endpoints
The JavaScript SDK can automatically handle file uploads for you. When you pass aFile object, Blob, or a base64 data URI to a model endpoint’s input, the SDK will first upload it to storage and then use the resulting URL in the request.
This simplifies the process as you don’t need to perform a separate upload step.
Support
Join our community for help or discussions:- Discord Community: Join us
- GitHub Repository: Visit here