Functions

Functions let assistants call custom logic defined by your application.

Endpoints

Manage assistant functions with these REST endpoints.

Function type

ParameterTypeDescription
idstringUnique identifier for the function
openapiSpecstringOpenAPI specification in JSON format
handlerHandlerFunction handler configuration
createdAtstringTimestamp when the function was created
updatedAtstringTimestamp when the function was last updated

Example function

const fn = { id: '00cfe680-fee5-49b9-b386-6a7097eb8497', openapiSpec: '{"openapi":"3.1.0"}', handler: { type: 'REQUEST', requestHandler: { url: 'https://example.com', method: 'GET', headers: '{}', body: '{}', }, }, createdAt: '2024-01-15T10:30:00Z', updatedAt: '2024-01-15T10:30:00Z', }

Handler type

Handlers determine how functions execute. The shape depends on type:
typeObject keyFields
REQUESTrequestHandler{ url: string, method: string, headers: string, body: string }
FIRECRAWLfirecrawlHandler{ type: string, apiKey: string, body: string }
REPLICATEreplicateHandler{ type: string, apiKey: string, identifier: string, body: string }
CLIENT_TOOLclientToolHandler{ type: string, name: string, arguments: string }
ASSISTANTassistantHandler{ assistantId: string }
LIST_TASKSlistTasksHandler{ keyTemplate: string }
CREATE_TASKcreateTaskHandler{ keyTemplate: string }
UPDATE_TASKupdateTaskHandler{ keyTemplate: string }
DELETE_TASKdeleteTaskHandler{ keyTemplate: string }