A typescript client for the PlatformAI API that enables building and deploying AI agent workflows. Supports agent creation, chat management, and thread persistence with TypeScript definitions.
npm install opxa-sdkThis SDK allows you to easily interact with the OPXA API using TypeScript.
A typescript client for the PlatformAI API that enables building and deploying AI agent workflows. Supports agent creation, chat management, and thread persistence with TypeScript definitions.
- CRUD Operations: Manage collections, documents, and paragraphs easily.
- Search: Perform searches across collections, documents, and paragraphs with relevance filtering.
- Error Handling: All API calls return a data, error, and isBusy object to handle responses and errors gracefully.
- TypeScript Support: Fully typed for TypeScript users.
To use the OPXA SDK, you first need to install it:
``bash`
npm install opxa-sdk
First, initialize the OPXA SDK with your API key:
`typescript
import { createClient } from 'opxa-sdk';
const opxa api = createClient({ apiKey: 'your-api-key-here' });
`
You can now use the SDK to interact with your API. Here's how you can use the functions available in the SDK:
Description: Login
Example:
`typescript
const { data, error } = await opxa_api.login(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: User registration
Example:
`typescript
const { data, error } = await opxa_api.createAccount(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Pre-confirm account
Example:
`typescript
const { data, error } = await opxa_api.preConfirmAccount(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Forgot password
Example:
`typescript
const { data, error } = await opxa_api.forgotPassword(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Reset password
Example:
`typescript
const { data, error } = await opxa_api.resetPassword(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Enable account
Example:
`typescript
const { data, error } = await opxa_api.anableAccount(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Disable account
Example:
`typescript
const { data, error } = await opxa_api.disableAccount(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Register tenant
Example:
`typescript
const { data, error } = await opxa_api.register(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get all call agents customers
Example:
`typescript
const { data, error } = await opxa_api.getAll();
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Create new service for call assistant agent
Example:
`typescript
const { data, error } = await opxa_api.createServiceForCallAssistant(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get all services by agent identifier
Example:
`typescript
const { data, error } = await opxa_api.getAllServicesByAgentId(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Update service for call assistant agent
Example:
`typescript
const { data, error } = await opxa_api.updateCallAssistantService(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Delete service for call assistant agent
Example:
`typescript
const { data, error } = await opxa_api.deleteCallAssistantService(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Create new faq for call assistant agent
Example:
`typescript
const { data, error } = await opxa_api.createFaqForCallAssistant(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get all faqs by agent identifier
Example:
`typescript
const { data, error } = await opxa_api.getAllFaqsByAgentId(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Update faq for call assistant agent
Example:
`typescript
const { data, error } = await opxa_api.updateCallAssistantFaq(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Delete faq for call assistant agent
Example:
`typescript
const { data, error } = await opxa_api.deleteCallAssistantFaq(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Create new action for agent
Example:
`typescript
const { data, error } = await opxa_api.createAgentAction(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get all agent actions
Example:
`typescript
const { data, error } = await opxa_api.getAllAgentActions(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Update agent action
Example:
`typescript
const { data, error } = await opxa_api.updateAgentAction(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Delete agent action
Example:
`typescript
const { data, error } = await opxa_api.deleteAgentAction(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Create new agent
Example:
`typescript
const { data, error } = await opxa_api.create(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get all agents
Example:
`typescript
const { data, error } = await opxa_api.getAll();
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get available agent tools
Example:
`typescript
const { data, error } = await opxa_api.getAvailableTools();
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get agent by identifier
Example:
`typescript
const { data, error } = await opxa_api.getById(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Update agent
Example:
`typescript
const { data, error } = await opxa_api.update(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Delete agent
Example:
`typescript
const { data, error } = await opxa_api.delete(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Create new config key value
Example:
`typescript
const { data, error } = await opxa_api.createKeyValueConfig(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get all key value configs
Example:
`typescript
const { data, error } = await opxa_api.getAllKeyValueConfigs();
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Update key value config
Example:
`typescript
const { data, error } = await opxa_api.updateKeyValueConfig(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Delete key value config
Example:
`typescript
const { data, error } = await opxa_api.deleteKeyValueConfig(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get book by ID
Example:
`typescript
const { data, error } = await opxa_api.getById(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Update book
Example:
`typescript
const { data, error } = await opxa_api.update(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Delete book
Example:
`typescript
const { data, error } = await opxa_api.delete(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get all books
Example:
`typescript
const { data, error } = await opxa_api.getAll();
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Create new book
Example:
`typescript
const { data, error } = await opxa_api.create(data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get book notes
Example:
`typescript
const { data, error } = await opxa_api.getNotesById(, );
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Get matching notes
Example:
`typescript
const { data, error } = await opxa_api.match(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Answer questions about book content
Example:
`typescript
const { data, error } = await opxa_api.answer(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Description: Create new content
Example:
`typescript
const { data, error } = await opxa_api.insert(, , data);
if (error) {
console.error('Error:', error);
} else {
console.log('Data:', data);
}
`
Each method in the OPXA SDK returns an object containing:
- data: The response data from the API if successful.error
- : An error message if the request fails.isBusy`: A boolean indicating whether the request is still in progress.
-
This allows you to handle API responses and errors effectively without worrying about exceptions being thrown.
If you would like to contribute to the OPXA SDK, feel free to fork the repository, make your changes, and submit a pull request. We welcome all contributions!
This project is licensed under the MIT License.