Skip to content

Python 3.13 — Fast

Python 3.13 — Fast starts executing immediately — there is no container to spin up between calls. It trades full PyPI availability for the lowest-latency Python execution on the platform.

Choose this runtime when your dependencies are pure-Python or from the supported package set and you want the fastest possible response time.


Handler signature

Your main file must be named cortexone_function.py and must define a function called cortexone_handler:

import json
def cortexone_handler(event, context):
result = {"message": "Hello, World!"}
return {"statusCode": 200, "body": json.dumps(result)}
ParameterTypeDescription
eventdictThe input payload sent by the caller
contextobjectExecution metadata (fn_id, user_id)

The handler returns a dict with statusCode and body. Use json.dumps() for the body.


The event object

event is whatever JSON the caller passes:

import json
def cortexone_handler(event, context):
name = event["name"]
numbers = event["numbers"]
return {
"statusCode": 200,
"body": json.dumps({"greeting": f"Hello, {name}!", "total": sum(numbers)})
}

Multiple files

You can upload multiple files. The main entry file must be cortexone_function.py containing cortexone_handler. Additional .py files are importable with standard imports.

Supported file types: .py, .csv, .md, .txt, .json, .yaml, .yml.

helpers.py
def greet(name):
return f"Hello, {name}!"
cortexone_function.py
import json
from helpers import greet
def cortexone_handler(event, context):
return {"statusCode": 200, "body": json.dumps({"message": greet(event["name"])})}

You can also upload data files and read them with open():

import json
def cortexone_handler(event, context):
with open("/data/config.json") as f:
cfg = json.load(f)
return {"statusCode": 200, "body": json.dumps(cfg)}

Dependencies

requirements.txt

Add a requirements.txt alongside cortexone_function.py:

numpy
pandas==2.2.0
scipy>=1.12
  • Standard version specifiers are supported (==, >=, !=, ~=, etc.)
  • URL-based dependencies (lines starting with https://) are not supported
  • Extras like pandas[excel] are accepted but the extra itself is ignored

Supported packages

283 packages are pre-built and ready to use. See the full list below. If a package you need isn’t there, contact support and we’ll add it.

If a package is unavailable, the error will say so. You can also switch to the standard Python 3.13 runtime to access the full PyPI ecosystem.


Environment Secrets

Environment variables are accessed through process["env"]not os.environ:

import json
def cortexone_handler(event, context):
api_key = process["env"].get("MY_API_KEY", "")
return {"statusCode": 200, "body": json.dumps({"ready": len(api_key) > 0})}

process["env"] is always available without any import. Store credentials as Environment Secrets at /user/secrets and attach them to your tool from the Code step of the Tool Editor. See Environment Variables for the full workflow.


Built-in utilities

These functions are always available without any import:

FunctionDescription
hash_digest(algorithm, data)Hash a string — "sha256", "sha512", "sha1", "md5"
btoa(s)Base64-encode a string
atob(s)Base64-decode a string
crypto.random_uuid()Generate a random UUID v4 string
crypto.get_random_values(n)Return n random bytes as a list of integers (max 65536)
json_encode(obj)Serialize to a compact JSON string
json_decode(s)Parse a JSON string
text_encode(s)Encode a string to UTF-8 bytes (list of ints)
text_decode(byte_list)Decode a UTF-8 byte list to a string
url_parse(url)Parse a URL into components (scheme, host, path, params, etc.)
structured_clone(obj)Deep-copy a dict or list
fetch(url, options)Synchronous HTTP request. options keys: method, headers, body. Returns {status, ok, text, json, headers}.
import json
def cortexone_handler(event, context):
text = event.get("text", "")
return {
"statusCode": 200,
"body": json.dumps({
"sha256": hash_digest("sha256", text),
"base64": btoa(text),
"id": crypto.random_uuid(),
})
}

What is available

FeatureAvailable
Python 3.13 standard libraryYes — math, json, re, datetime, collections, itertools, hashlib, csv, os.path, and more
process["env"]Yes — read environment variables
File I/O (open, read, write)Yes — files are temporary and scoped to the current execution
Built-in utilitiesYes — hash_digest, btoa/atob, crypto, json_encode/json_decode, etc.
fetch(url, options)Yes — synchronous HTTP (see fetch builtin)
subprocess / multiprocessingNo — blocked
shutil, venv, pipNo — blocked
Dangerous os operationsNoos.system, os.popen, os.fork, os.kill, etc. are blocked
os.environNo — use process["env"] instead

Resource limits

LimitDefault
Max memory512 MB
Max runtime300 seconds
CPU limit2.0 cores

Example: Number processing with numpy

import numpy as np
import json
def cortexone_handler(event, context):
arr = np.array(event["numbers"])
return {
"statusCode": 200,
"body": json.dumps({
"mean": float(arr.mean()),
"sum": int(arr.sum()),
"max": float(arr.max()),
})
}

Example: DataFrame analysis with pandas

import pandas as pd
import json
def cortexone_handler(event, context):
df = pd.DataFrame(event["rows"])
return {
"statusCode": 200,
"body": json.dumps({
"shape": list(df.shape),
"columns": list(df.columns),
"mean": df.select_dtypes("number").mean().to_dict(),
})
}

Error responses

If your handler raises an exception, the platform catches it and returns:

{
"statusCode": 500,
"body": "{\"error\": \"Script execution failed\", \"type\": \"ExecutionError\", \"details\": \"...\"}"
}

Timeouts return statusCode: 408. Memory limit exceeded returns statusCode: 507.


Notes

  • The main file must be named cortexone_function.py and must contain cortexone_handler.
  • Each execution gets a completely fresh Python namespace — no state is shared between calls.
  • Files written during one execution are not available in the next.
  • Installed packages are cached for the lifetime of the worker, so repeated calls with the same packages are fast.
  • For outbound HTTP or packages outside the supported set, use the standard Python 3.13 runtime instead.

Available packages

The following 283 packages are pre-built and available to install via requirements.txt. Install them by name — no version pinning required unless you need a specific release.

If you need a package that isn’t listed here, contact us through the Support option in the app and we’ll add it for you.

PackageVersionDescription
affine2.4.0Affine transformation matrices for 2D coordinate transforms
aiohappyeyeballs2.6.1Happy Eyeballs algorithm for async TCP connections
aiohttp3.13.5Async HTTP client/server framework
aiosignal1.4.0Signal/callback list for asyncio
altair6.0.0Declarative statistical visualization library
annotated-doc0.0.4Annotation and documentation utilities
annotated-types0.7.0Type annotation metadata for validation
anyio4.13.0Async I/O compatibility layer (asyncio/trio)
apsw3.51.3.0Another Python SQLite Wrapper — full SQLite API
argon2-cffi23.1.0Argon2 password hashing library
argon2-cffi-bindings25.1.0Low-level CFFI bindings for Argon2
astropy7.2.0Astronomy and astrophysics toolkit
astropy_iers_data0.2026.4.1.15.5.49IERS Earth rotation and time data for Astropy
asttokens3.0.1Maps AST nodes to source code tokens
async-timeout5.0.1Asyncio-compatible timeout context manager
atomicwrites1.4.1Atomic file writing on POSIX systems
attrs26.1.0Boilerplate-free class definitions with validation
audioop-lts0.2.2Audio operations (Python 3.13 LTS backport)
awkward-cpp52C++ backend for Awkward Array (ragged arrays)
b2d0.7.4Box2D 2D rigid body physics engine bindings
bcrypt5.0.0bcrypt password hashing
beautifulsoup44.14.3HTML and XML parsing and scraping
bilby.cython0.5.4Cython extensions for Bilby Bayesian inference
biopython1.87Computational biology and bioinformatics toolkit
bitarray3.8.1Efficient bit array implementation
bitstring4.4.0Bit-level data creation, parsing and manipulation
bleach6.3.0HTML sanitization and text linkification
blosc24.1.2High-performance compressed array storage
bokeh3.9.0Interactive browser-based visualization
boost-histogram1.7.1High-performance histogram filling (Boost.Histogram)
Bottleneck1.6.0Fast NumPy array functions (NaN-aware, Cython)
brotli1.2.0Brotli compression and decompression
cachetools7.0.5Memoization and caching decorators
Cartopy0.25.0Cartographic projections and geospatial visualization
casadi3.7.2Symbolic framework for numerical optimization
cbor-diag1.1.2CBOR (Concise Binary Object Representation) diagnostics
certifi2026.4.22Mozilla CA certificate bundle
cffi2.0.0C Foreign Function Interface for Python
cftime1.6.5Time-handling for netCDF and CF conventions
charset-normalizer3.4.7Character encoding detection
clarabel0.11.1Interior-point conic optimization solver
click8.3.1Composable command-line interface toolkit
cligj0.7.2Click parameter types for GeoJSON
clingo5.8.0Answer Set Programming grounder and solver
cloudpickle3.1.2Extended pickling for closures and lambdas
cmyt2.0.2Scientific colormaps from yt
cobs1.2.2Consistent Overhead Byte Stuffing encoding
colorspacious1.1.2Color space conversions and perceptual distance
contourpy1.3.3Contour line and filled contour computation
coolprop7.2.0Thermodynamic and transport properties of fluids
coverage7.13.5Code coverage measurement
crc32c2.8CRC32C checksum (hardware-accelerated)
crcmod1.7Cyclic redundancy check (CRC) calculation
cryptography47.0.0Cryptographic primitives and recipes
cssselect1.4.0CSS selector parsing and translation to XPath
cvxpy-base1.8.2Convex optimization problem modeling
cycler0.12.1Composable cycles for matplotlib style parameters
cysignals1.12.3Unix signal handling for Cython/C extensions
cytoolz1.1.0Cython-accelerated functional utilities (toolz)
decorator5.2.1Signature-preserving function decorators
demes0.2.3Demographic history model specification
deprecated1.3.1Mark functions/classes as deprecated with warnings
deprecation2.1.0Deprecation helpers and warnings
diskcache5.6.3Disk-backed cache and deque
distlib0.4.0Low-level Python distribution utilities
distro1.9.0Linux OS distribution detection
dnspython2.8.0DNS toolkit — queries, zones, and DNSSEC
docutils0.22.4reStructuredText document processing
donfig0.8.1.post1Configuration management for libraries
duckdb1.5.1In-process analytical SQL database engine
ewah_bool_utils1.3.0EWAH bitmap compression for yt
exceptiongroup1.3.1PEP 654 exception groups (backport)
executing2.2.1Inspect code being executed at runtime
fastapi0.136.1High-performance async web API framework
fastcan0.5.0Fast canonical correlation analysis
fiona1.9.5Pythonic API for OGR vector geospatial data
fonttools4.62.1Read, write and manipulate font files
freesasa2.2.1Solvent-accessible surface area of proteins
frozenlist1.8.0List that can be made immutable
fsspec2026.3.0Filesystem-spec — unified interface to filesystems
future1.0.0Python 2/3 compatibility bridge
galpy1.11.2Galactic dynamics: orbits, potentials, action-angle
geopandas1.1.3Geospatial extensions for pandas
gmpy22.3.0Multiple-precision arithmetic (GMP/MPFR/MPC)
google-crc32c1.8.0CRC32C checksums using Google’s implementation
gsw3.6.21TEOS-10 Gibbs SeaWater oceanographic toolbox
h110.16.0Pure-Python HTTP/1.1 implementation
h34.4.2Uber H3 hexagonal hierarchical geospatial indexing
h5py3.13.0HDF5 binary data format interface
highspy1.13.1Python bindings for HiGHS linear/integer optimizer
html5lib1.1Standards-compliant HTML parser
httpcore1.0.9Minimal HTTP client library
httpx0.28.1Fully featured async/sync HTTP client
idna3.11Internationalized Domain Names in Applications (IDNA)
igraph1.0.0Network analysis and graph algorithms
imageio2.37.3Read and write images, video, and volumetric data
iminuit2.30.1Function minimization and fitting (MINUIT)
iniconfig2.3.0Simple INI-file configuration parser
ipython9.12.0Enhanced interactive Python shell
jedi0.19.2Autocompletion and static analysis for Python
Jinja23.1.6Templating engine for Python
jiter0.13.0Fast iterable JSON parser
joblib1.5.3Lightweight pipelining and parallelism
jsonpatch1.33JSON Patch (RFC 6902) apply and generate
jsonpointer3.1.1JSON Pointer (RFC 6901) resolution
jsonschema4.26.0JSON Schema validation
jsonschema_specifications2025.9.1JSON Schema specification meta-schemas
kiwisolver1.5.0Cassowary constraint solving algorithm
lakers-python0.6.2LAKERS OSCORE+EDHOC protocol implementation
lazy_loader0.5Lazy module attribute loading
lazy-object-proxy1.12.0Lazy initialization of objects
libcst1.8.6Concrete syntax tree for Python source code
lightgbm4.6.0Gradient boosting framework (LightGBM)
logbook1.9.2Logging system for Python
lxml6.0.2Feature-rich XML and HTML processing
lz44.4.5LZ4 fast compression/decompression
MarkupSafe3.0.3Safely handle text with HTML/XML special characters
matplotlib3.10.82D plotting and visualization
matplotlib-inline0.2.1Matplotlib backend for inline display
memory-allocator0.2.0Custom memory allocation utilities
ml_dtypes0.5.4NumPy dtypes for machine learning (bfloat16, float8, etc.)
mmh35.2.1MurmurHash3 non-cryptographic hash
more-itertools11.0.1Extended itertools — additional iterator utilities
mpmath1.4.1Arbitrary-precision floating-point arithmetic
msgpack1.1.2Efficient binary serialization (MessagePack)
msgspec0.20.0High-performance JSON/MessagePack serialization with type validation
msprime1.4.1Ancestral recombination graph simulation
multidict6.7.1Multivalue dictionary (for HTTP headers etc.)
munch4.0.0Dot-access dictionary
mypy1.19.1Static type checker for Python
narwhals2.18.1Dataframe-agnostic API (pandas, polars, modin, etc.)
ndindex1.10.1NumPy-like index types with safe operations
netcdf41.7.4Read/write NetCDF-4 and NetCDF-3 files
networkx3.6.1Network creation, analysis and algorithms
newick1.11.0Newick phylogenetic tree format parser
nh30.3.4HTML sanitization (Rust-based, ammonia)
nlopt2.9.1Nonlinear optimization (many algorithms)
nltk3.9.4Natural language processing toolkit
numcodecs0.15.1Array compression codecs for Zarr and NumPy
numpy2.4.3N-dimensional array computing
openai2.30.0OpenAI API client
opencv-python4.11.0.86Computer vision and image processing (OpenCV)
optlang1.9.0Mathematical programming language for optimization
orjson3.11.8Fast JSON serialization/deserialization
packaging26.1Package version parsing and specifiers
pandas3.0.2Data manipulation and analysis
parso0.8.6Python parser with error recovery
patsy1.0.2Statistical model formula notation (R-style)
pcodec1.0.1Lossless compression for numeric data
peewee4.0.4Lightweight ORM for SQLite, MySQL, PostgreSQL
phispy5.0.6Prophage identification in bacterial genomes
pi-heif1.3.0HEIF/HEIC image format read/write
Pillow12.2.0Image processing (PIL fork)
pillow-heif1.3.0HEIF/HEIC plugin for Pillow
pkgconfig1.6.0Interface to pkg-config
platformdirs4.9.4Platform-specific user/app directories
pluggy1.6.0Plugin management and hook system
ply3.11Python Lex-Yacc parser tools
polars1.33.1High-performance DataFrame library (Rust-based)
prompt_toolkit3.0.52Building interactive command-line applications
propcache0.4.1Property caching decorator
protobuf7.34.1Protocol Buffers serialization
pure-eval0.2.3Safely evaluate simple Python expressions
py1.11.0Python testing and code utilities
pyarrow22.0.0Apache Arrow columnar in-memory data
pyclipper1.4.0Polygon clipping and offsetting (Clipper)
pycparser3.0Complete C99 parser in Python
pycryptodome3.23.0Self-contained cryptographic algorithms
pydantic2.12.5Data validation using Python type hints
pydantic_core2.41.5Core validation engine for Pydantic
pyerfa2.0.1.5Python bindings for ERFA astronomical library
pygame-ce2.5.7Game development framework (community edition)
Pygments2.20.0Syntax highlighting for 300+ languages
pyheif0.8.0Read HEIF/HEIC image files
pyiceberg0.11.1Apache Iceberg table format client
pyinstrument5.1.2Statistical call-stack profiler
pymongo4.16.0MongoDB driver for Python
PyMuPDF1.27.2.2PDF and XPS document processing (MuPDF)
pynacl1.6.2Python bindings to libsodium (NaCl cryptography)
pyparsing3.3.2PEG parsing expression grammar library
pyproj3.7.2Cartographic projections (PROJ library)
pyroaring1.0.4Compressed bitmap sets (Roaring Bitmaps)
pyrodigal3.7.1Gene prediction (Prodigal) Python interface
pyrsistent0.20.0Immutable persistent data structures
pysam0.23.0SAM/BAM/CRAM/VCF/BCF genomics file access
pyshp3.0.3Read/write ESRI Shapefile format
pytaglib3.2.0Audio file metadata reading/writing (TagLib)
pytest9.0.2Testing framework
pytest-asyncio0.25.3Asyncio support for pytest
pytest-benchmark4.0.0Benchmarking fixtures for pytest
pytest_httpx0.36.0Mock httpx requests in pytest
python-calamine0.6.2Excel/ODS file reading (Calamine, Rust)
python-dateutil2.9.0.post0Powerful extensions to datetime
python-flint0.8.0Arbitrary-precision number theory (FLINT)
python-flirt0.9.10Fast Library Identification and Recognition Technology
python-sat1.8.dev26SAT solver toolkit (pysat)
python-solvespace3.0.8Parametric CAD constraint solver
pytz2026.1.post1IANA timezone database for Python
pywavelets1.9.0Discrete wavelet transforms
pyxirr0.10.8Financial functions — IRR, XIRR, NPV, etc.
pyyaml6.0.3YAML parser and emitter
rasterio1.5.0Geospatial raster data I/O (GDAL)
rateslib2.7.1Fixed income and derivatives pricing
rebound4.4.7N-body gravitational dynamics simulator
reboundx4.4.1Additional forces and effects for REBOUND
referencing0.37.0JSON reference resolution
regex2026.3.32Alternative re module with additional features
requests2.33.1HTTP library for humans
retrying1.4.2General retry decorator
rich14.3.3Rich text, tables and progress bars in terminal
RobotRaconteur1.2.7Distributed robotics middleware
rpds-py0.30.0Immutable persistent data structures (Rust)
ruamel.yaml0.19.1YAML 1.2 parser with round-trip preservation
safetensors0.7.0Safe tensor serialization format (Hugging Face)
scikit-image0.25.2Image processing algorithms
scikit-learn1.8.0Machine learning library
scipy1.17.1Scientific computing — optimization, integration, signal processing
screed1.1.3DNA/RNA sequence file reading
sentencepiece0.2.1Unsupervised text tokenizer (BPE/Unigram)
setuptools82.0.1Package building and distribution utilities
shapely2.1.2Geometric objects, predicates and operations
simplejson3.20.2JSON encoder/decoder
sisl0.16.4Electronic structure and transport library
six1.17.0Python 2 and 3 compatibility utilities
smart-open7.5.1Transparent open() for S3, GCS, HDFS and local
sniffio1.3.1Detect which async library is running
sortedcontainers2.4.0Sorted list, dict and set (pure Python, fast)
soundfile0.12.1Read and write sound files (libsndfile)
soupsieve2.8.3CSS selector implementation for BeautifulSoup
sourmash4.8.14Sequence sketching and genome comparison
soxr0.5.0.post1High-quality audio resampling
sparseqr1.2Sparse QR decomposition (SuiteSparseQR)
sqlalchemy2.0.48SQL toolkit and ORM
stack-data0.6.3Extract data from stack frames for tracebacks
starlette1.0.0Lightweight ASGI framework/toolkit
statsmodels0.14.6Statistical models, hypothesis tests and data exploration
strictyaml1.7.3Type-safe, schema-validated YAML parser
svgwrite1.4.3SVG file generation
swiglpk5.0.13SWIG bindings for GLPK linear optimizer
sympy1.14.0Symbolic mathematics
tblib3.2.2Pickle tracebacks and re-raise across processes
termcolor3.3.0ANSI color output in terminal
texttable1.7.0ASCII table formatting
texture2ddecoder1.0.6Decode GPU compressed texture formats
threadpoolctl3.6.0Control thread pool size for native libraries
tiktoken0.12.0Byte-pair encoding tokenizer (OpenAI)
tomli2.4.1TOML parser (read-only)
tomli-w1.2.0TOML file writer
toolz1.1.0Functional utilities — curry, pipe, compose
tqdm4.67.3Fast, extensible progress bar
traitlets5.14.3Type-checked attributes and configuration system
traits7.1.0Observable typed attributes
tree-sitter0.23.2Incremental parser for source code
tree-sitter-go0.23.3Go language grammar for tree-sitter
tree-sitter-java0.23.4Java language grammar for tree-sitter
tree-sitter-python0.23.4Python language grammar for tree-sitter
tskit1.0.2Tree sequence data structures for population genetics
typing-extensions4.15.0Backport of new typing module features
typing-inspection0.4.2Runtime inspection of type annotations
tzdata2025.3IANA timezone database as Python package
ujson5.12.0Ultra-fast JSON encoder/decoder
uncertainties3.2.3Transparent uncertainty propagation (error bars)
unyt3.1.0Unit handling and dimensional analysis
urllib32.6.3HTTP client with connection pooling
vega-datasets0.9.0Sample datasets for Vega/Altair visualization
vrplib2.1.0Vehicle routing problem benchmark instances
wcwidth0.6.0Terminal character width (CJK and wide characters)
webencodings0.5.1Legacy web character encodings
wordcloud1.9.6Word cloud image generation
wrapt2.1.2Module for decorators, wrappers and monkey patching
xarray2026.2.0N-dimensional labeled arrays and datasets
xgboost2.1.4Gradient boosting framework (XGBoost)
xlrd2.0.2Read Excel .xls files
xxhash3.6.0xxHash non-cryptographic hash
xyzservices2026.3.0Tile map service providers for visualization
yarl1.23.0URL parsing and manipulation
yt4.4.0Volumetric data analysis and visualization
zarr3.2.1Chunked, compressed, N-dimensional arrays
zengl2.7.2Minimal OpenGL rendering context
zfpy1.0.1ZFP floating-point array compression
zstandard0.25.0Zstandard (zstd) compression bindings