This is the official Inferable AI SDK for Typescript.
npm install inferable
yarn add inferable
pnpm add 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",
});
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(),
}),
},
});
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
- Inferable documentation contains all the information you need to get started with Inferable.