Functions

Triggering AI Functions for promptless, API driven AI features

Overview

Make your product AI-powered without prompts. Functions let you call curated LLM skills from code and receive text or JSON outputs you can trust, with versioning, tests, and observability built in.

📘

Use Functions when you want a deterministic API (well-defined inputs/outputs) instead of an open-ended chat.

When to Use Functions

  • Synchronous AI APIs: quick, reliable responses for product features.
  • Deterministic contracts: predictable outputs via schemas.
  • Non-chat use cases: summaries, classification, extraction, or generation tasks.

Prerequisites

📘

⚠️ Important: Functions are created and versioned in the Agent Studio UI under Actions → Functions.


How it works

  1. In Agent Studio (UI)

    • Define a new Function under Actions → Functions.
    • Provide input/output schema, description, and optional test cases.
    • Save and Publish a version (e.g. v1).
  2. In your app (code)

    • Call the Function by name with its published schema.
    • Handle success/failure and use the structured result.

Parameters

ParameterTypeRequiredDescription
apiKeystringYesThe name of the AI Function to call (as defined in Agent Studio).
datastring, number, object, or arrayYesInput payload for the Function. Must match the Function’s input schema if one is defined.
resolvefunctionNo*Success handler. Called with the Function’s output. Optional if using the Promise form.
rejectfunctionNo*Error handler. Called if the Function call fails. Optional if using the Promise form.

Using aiFunctionCall

const apiKey: string = "generate_xyz";
// Input
const data: string | number | object | Array<any> = {};

// Callback response
const resolve = (value: object) => {
  console.log("Success", value);
};

const reject = (reason?: any) => {
  console.error("Error", reason);
};

// Call the API
window.eucera.agent("your-agent-api-name").aiFunctionCall(apiKey, data, resolve, reject);