Calling LLMs and agents from custom functions in flows
In flows, Python custom functions can call an LLM through one of two clients on the CLIENTS object:
-
LLM client (
CLIENTS.llm_client) — Sends a prompt to the model, with optional file data or a response schema, and returns the response. Your code reads the input files and parses, checks, and writes the response. The LLM client uses agent mode v1 capabilities, using the LLMs available in your environment and the app’s configured AI runtime. -
Opt-in Agent client (
CLIENTS.agent_client) — Lets custom functions in Map UDF and Reduce UDF steps use agent mode v2, which hands tasks to the SuperApp AI agent to answer questions about the step’s input files, extract structured records, and check the results. The agent client attaches the input files, validates extraction results against your schema, and writes them to the step output. You can choose the model and reasoning effort for each call.
Client comparison
The two clients have different methods and availability, and you can’t substitute one for the other.
