Python 3.13
Python 3.13 is the default language for Function tools. Use it for most logic, data work, and integrations. If you need the lowest possible latency and can live with a fixed package set, see Python 3.13 — Fast.
Handler structure
Section titled “Handler structure”Your code needs a main file named cortexone_function.py with a function called cortexone_handler that accepts event and context and returns a dict with statusCode and body:
import json
def cortexone_handler(event, context): result = {"message": "Hello, World!"} return {"statusCode": 200, "body": result}Input and output
Section titled “Input and output”event receives whatever JSON the caller passes, as a dict. Return plain dicts in body — the platform serializes automatically. Only reach for json.dumps() when your data contains types that don’t serialize natively (numpy int64, float32, custom objects).
Organizing code
Section titled “Organizing code”You can include multiple files alongside the handler. Supported types: .py, .csv, .md, .txt, .json, .yaml. List dependencies in a requirements.txt; common libraries like requests, numpy, and pandas are pre-installed, and this runtime has full PyPI access.
Secrets and limits
Section titled “Secrets and limits”Store credentials as Secrets, attach them to the tool, and read them via environment variables with os.environ.get(). Resource limits: 512 MB memory, 300-second runtime, 2.0-core CPU.
Errors and testing
Section titled “Errors and testing”Unhandled exceptions return a 500 with an error message; timeouts return 408. Use the Preview/Test tab to run sample payloads before publishing.