
Overview
Actions allow you to deploy serverless Python functions that can be triggered on-demand by endpoints or used as tools by AI agents. Think of actions as lambda-like functions that run in isolated environments.- Project Structure
my-project
config.yml
actions
send_mail_action.py
What Are Actions?
Actions are custom Python functions that run in isolated environments, accept parameters, return structured results, and can be triggered via endpoints or used as agent tools.Use Cases
Inside an action you can:- Invoke an LLM — call a model through your model account with
Agent, optionally with structured output - Run SQL queries — read from your datasets with
execute_query - Read and write knowledge objects — get, list, update and batch upsert instances with
KnowledgeObject - Use secure variables — access API keys and credentials with
Variable, without hardcoding them - Log execution details — emit info, warning and error logs with
context - Connect to SAP — read tables and execute function modules with
CloudFeedClient - Call any external API — the runtime ships with
requests, so any HTTP service is one call away
Action with Logging
Usecontext to log information during execution:
Action with Optional Parameters
Actions SDK Reference
Decorator
@action decorator marks a function as executable by Datazone.
Context API
The context object provides logging capabilities during action execution:function
Log informational messages during action execution.
function
Log warning messages for potential issues.
function
Log error messages when operations fail.
Variable API
The Variable class allows actions to access secure variables stored in Datazone:class
Access workspace variables securely within actions.
Example: Using Variables
Security Best Practice: Always store sensitive credentials as Variables rather than hardcoding them in your action code.
execute_query
Theexecute_query function runs SQL queries against your Datazone datasets and returns structured results:
function
Execute a SQL query against Datazone datasets.Returns a
QueryResult object with:data— list of row dictionariesstatus— execution status string
Example: Query and Transform
Agent
TheAgent class invokes an LLM through one of your Model Accounts, without any provider SDK or API key in your code — the call is proxied by Datazone and billed against your workspace.
class
Create an agent bound to a model account and model.Parameters:
model(optional) — model to use, e.g.CLAUDE_45_SONNET. Defaults to your organisation’s default model.model_account(optional) — model account id. Defaults to your organisation’s AI settings account.response_format(optional) — a Pydantic model or JSON schema dict for structured output.
method
Invoke the model and return a result dictionary.Accepts either a plain string or a message list:Message roles are
system, user and assistant. Returns a dict with:content— the raw text answer (empty whenresponse_formatis used)structured_response— the parsed object whenresponse_formatis used, otherwiseNonemodel— the model that produced the answer
RuntimeError if the invocation fails.Example: Summarize Text
Example: Structured Output
Pass a Pydantic model asresponse_format to get a validated object back instead of raw text:
Token usage is recorded per invocation and attributed to the action, so LLM costs show up alongside your other workspace usage.
KnowledgeObject
TheKnowledgeObject client reads and writes Knowledge Object instances from within an action. Instances are addressed by their opaque _key, and operations run on the action’s project (main branch by default).
class
Access instances of a knowledge object by name.Methods:
get(key, add_relationships=False)— fetch one instance (adict) by its_key.list(filters=None, page=1, page_size=50, fields=None)— iterate pages of instances (see below).update(key, payload)— partially update an instance; returns the updated instance.delete(key)— delete an instance by its_key.batch_upsert(payloads)— insert/update up to 1000 instances in one call; returns{"created", "updated", "total"}.
list(...) returns an iterator of pages; each page exposes .items and .total_count. filters is a list of {"column", "operator", "value"} objects combined with AND (operators: equal, not_equal, contains, not_contains, greater_than, less_than).
Example: Read and upsert
FileContainerClient
FileContainerClient provides access to files stored in the Datazone file container (LakeFS/S3-compatible storage). It is automatically initialized as file_client in agent code execution environments — no import is required.
file_client is pre-initialized in agent code execution contexts. It is not available inside @action decorated functions.method
Fetch raw bytes for a file from the file container.
path— path relative to the file container root- Returns raw
bytes - Raises
ValueErrorif the file exceeds 10 MB or cannot be fetched
Examples: Reading Different File Types
CloudFeedClient
CloudFeedClient is a simplified SAP connector for reading tables and executing function modules from within actions:
class
SAP CloudFeed client for table access and function execution.Constructor parameters:
base_url— base URL of the SAP systemusername— SAP usernamepassword— SAP passwordtimeout(optional) — request timeout in seconds (default: 30)max_retries(optional) — max retries on failure (default: 10)backoff_factor(optional) — exponential backoff factor (default: 0.3)
Example: Query SAP Sales Orders
Example: Execute SAP Function Module
Example: Search and Inspect SAP Tables
Configuration
Add to config.yaml
Register your actions inconfig.yaml:
Repository Structure
config.yml
actions
send_email.py
process_data.py
generate_report.py
workflows
Each file should contain one
@action decorated function. Action function names must be unique within your project.Return Values
Actions should return structured data (dict, list, or primitives):Error Handling
Actions can raise exceptions - they’ll be captured and returned:Using Actions
1. In Endpoints
Connect actions to API endpoints for webhook-style triggers:2. In Agents
Enable actions as tools for AI agents: When creating an agent:- Select “Action” in the tools section
- Choose which actions the agent can use
- The agent will automatically call actions when needed
Examples
Slack Notification
Data Validation
API Integration
Next Steps
- Create Action Endpoints
- Use Actions in Agents
- Manage Variables - Store secure credentials and configuration
- Learn About Projects