inferable
v0.30.6
Published
Javascript SDK for inferable.ai
Downloads
2,813
Readme
Typescript SDK
This is the official Inferable AI SDK for Typescript.
Installation
npm
npm install inferable
yarn
yarn add inferable
pnpm
pnpm add inferable
Quick Start
1. Initializing Inferable
Create a file named i.ts which will be used to initialize Inferable. This file will export the Inferable instance.
// d.ts
import { Inferable } from "inferable";
// Initialize the Inferable client with your API secret.
// Get yours at https://console.inferable.ai.
export const d = new Inferable({
apiSecret: "YOUR_API_SECRET",
});
2. Hello World Service
In a separate file, create the "Hello World" service. This file will import the Inferable instance from i.ts and define the service.
// service.ts
import { i } from "./i";
// Define a simple function that returns "Hello, World!"
const sayHello = async ({ to }: { to: string }) => {
return `Hello, ${to}!`;
};
// Create the service
export const helloWorldService = d.service({
name: "helloWorld",
});
helloWorldService.register({
name: "sayHello",
func: sayHello,
schema: {
input: z.object({
to: z.string(),
}),
},
});
3. Running the Service
To run the service, simply run the file with the service definition. This will start the service and make it available to your Inferable agent.
tsx service.ts
Documentation
- Inferable documentation contains all the information you need to get started with Inferable.