Skip to main content
This page requires Python familiarity. PolyAI’s function runtime uses Python 3.12. Only the standard library and the packages listed below are available. You cannot install additional packages.

Execution environment

Functions run in a sandboxed cloud environment. This means:
  • No local file system access — you cannot read or write files from your machine (e.g., CSV files, text files, or databases stored locally).
  • No package installation — only the standard library and the pre-installed packages listed below are available.
  • Network access — you can make outbound HTTP requests using the requests library to call external APIs or fetch hosted data.
If you need to use data from a file, host it externally (e.g., on a web server or cloud storage) and fetch it at runtime using requests.

Standard library

Within functions you have access to all of the Python 3.12 standard library, including modules like datetime, json, re, urllib, hashlib, and more.

Notable features available in the runtime

If you’re coming from Python 3.9, the following features are available in your functions:
  • Structural pattern matching (match/case, introduced in Python 3.10) — a cleaner alternative to long if/elif chains for branching on values or structures. See the Python docs on match statements.
  • Parenthesized context managers (Python 3.10+) — you can use parentheses to split multiple context managers across lines:
    with (
        open("input.json") as infile,
        open("output.json", "w") as outfile,
    ):
        ...
    
  • Exception Groups and except* (Python 3.11+) — handle multiple exceptions raised concurrently. Useful when your function makes parallel API calls. See PEP 654.

Non-standard libraries

The following packages are pre-installed:
LibraryVersionDescription
requests2.32.5HTTP library for making API requests
decorator5.2.1Function decorator utilities
urllib32.3.0Low-level HTTP client
jsonschema4.25.1JSON schema validation
If you encounter unexpected behavior with a library, contact your PolyAI representative.
The requests library is the recommended way to make external API calls from your functions. See the requests quickstart guide for usage examples.
Last modified on March 26, 2026