Using bem

Creating a Function

Learn how to create a bem Function, a long-lived, reusable configuration that acts as the blueprint for your data processing workflows, defining your output schema and result destinations.

Updated 12/11/2025

Functions are the atomic units of logic in bem. While Workflows orchestrate the process, Functions perform the actual work.

Function Primitives

bem offers several types of function primitives to handle different aspects of data processing:

  1. Transform: The core primitive. Extracts structured data from unstructured inputs (documents, images, text) based on a JSON schema.
  2. Analyze: Similar to Transform, but focused on analyzing content (e.g., classification) without necessarily extracting a full schema.
  3. Route: Directs data to different functions based on content or metadata rules.
  4. Split: Breaks down large inputs (like multi-page PDFs) into smaller units.
  5. Join: Aggregates results from multiple inputs into a single output.
  6. Payload Shaping: Transforms JSON payloads using JMESPath to fit specific schema requirements.
  7. Enrich: Adds external data to your payload.

Creating a Function

You create functions using the /v2/functions endpoint.

Example: Creating a Transform Function

1curl -X POST https://api.bem.ai/v2/functions \
2  -H "x-api-key: <YOUR_BEM_API_KEY>" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "functionName": "invoice-processor",
6    "displayName": "Invoice Processor",
7    "type": "transform",
8    "outputSchemaName": "InvoiceSchema",
9    "outputSchema": {
10      "type": "object",
11      "properties": {
12        "total": { "type": "number" }
13      }
14    }
15  }'