Skip to main content
POST
Execute Tool

TypeScript SDK

The SDK is available on GitHub: premAI-io/api-sdk-ts

Usage

Basic Setup

Create a client with auto-generated encryption keys:

Pre-generate Keys

You can pre-generate encryption keys and reuse them:

Features

  • File-Producing Tools - Generate images, audio, and custom files
  • File-Processing Tools - Extract content from PDFs, images, audio, video, and other file types
  • Simple Tools - Web search, time, web scraping
  • RAG Tools - Search indexed documents with an optional file filter
  • End-to-end Encryption - All tool calls use end-to-end encryption
  • Automatic Decryption - The SDK automatically downloads and decrypts files
  • TypeScript - Full type safety

Tools

All tool calls use end-to-end encryption. The SDK automatically downloads and decrypts files.

File-Producing Tools

Generate files with these tools. The SDK automatically decrypts the files and returns them:

File-Processing Tools

Process uploaded files and get the results:

Simple Tools

These tools do not process files:

Available Tools

File-Producing Tools

  • generateImage(params: { prompt: string }) - Generate images from text
  • audioGenerateFromText(params: { text: string }) - Text-to-speech
  • createFileForUser(params: { fileName: string, fileExtension: string, fileContent: string, mimeType: string }) - Create custom files

File-Processing Tools

  • imageDescribeAndCaption(params: { fileId: string }) - Describe images
  • imageDescribeAndCaptionFallback(params: { fileId: string }) - Alternative image description
  • videoDescribeAndCaption(params: { fileId: string }) - Describe videos
  • getPDFContent(params: { fileId: string }) - Extract PDF text
  • getTextDocumentContent(params: { fileId: string }) - Extract document text
  • transcribeAudioToText(params: { fileId: string, language?: string }) - Audio transcription
  • transcribeAudioWithDiarization(params: { fileId: string, language?: string }) - Transcription with speakers
  • audioDiarization(params: { fileId: string }) - Identify speakers
  • getFileContentOCR(params: { fileId: string }) - OCR on images
  • getSpreadsheetContent(params: { fileId: string }) - Extract spreadsheet data
  • getDataFileContent(params: { fileId: string }) - Extract data file content
  • getPowerPointContent(params: { fileId: string, slideNumbers?: number[] }) - Extract presentation content

Simple Tools

  • getTime(params: { timezone: string }) - Get current time
  • webSearchTool(params: { query: string, country?: string, searchLang?: string }) - Web search
  • webPageScraperTool(params: { url: string, renderJs?: boolean }) - Scrape web pages

RAG Tools

  • searchRag(params: { query: string }) - Search indexed documents with an optional file filter

Configuration Options

Security Notes

  • ⚠️ Keep your DEK store secure. The DEK store contains all of your encryption keys.
  • ⚠️ Do not commit dek-store.json to version control.
  • ⚠️ Use environment variables for API keys.
  • ⚠️ Save the dekStore after each file upload. The dekStore holds the DEKs for your files.
  • ⚠️ Make a backup of your dekStore. If you lose it, you lose access to your uploaded files.

TypeScript Types

Authorizations

Authorization
string
header
required

Send your access token as header Authorization: Bearer {accessToken}

Authorization
string
header
required

Your API key that starts with sk_live or sk_test. You can create yours at go.prem.io/api-keys.

Path Parameters

id
string
required

The tool identifier (e.g., generateImage, audioGenerateFromText, createFileForUser)

Body

application/json

Request for simple tools that don't involve file I/O: webSearchTool, getTime, webPageScraperTool

cipherText
string
required

Cipher text from ML-KEM encapsulation for shared secret generation

encryptedParams
string
required

Encrypted JSON string containing the tool parameters

nonce
string
required

Nonce used for encrypting the parameters payload

Response

Tool executed successfully with encrypted response

status
enum<integer>
required

Status code of the response

Available options:
200,
201,
202
data
File Output Response · object
required

Response for file-producing tools (generateImage, audioGenerateFromText, createFileForUser)

Example:
message
string | null
required

Message of the response, human readable

Example:

"Resource created successfully"

env
enum<string>
required

API environment

Available options:
development,
production
error
string | null

Error message of the response, human readable

Example:

"Invalid email address"

log

Useful informaiton, not always present, to debug the response

Examples:

"Some pertinent log message"

validator

Validator response object, each key is the field name and value is the error message

Example:
support_id
string<uuid> | null

Support ID linked to the response, used to identify it when talking with our team

Example:

"support_uuidv7-something-else"