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.
Standard library
Within functions you have access to all of the Python 3.12 standard library, including modules likedatetime, 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 longif/elifchains 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:
- 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:| Library | Version | Description |
|---|---|---|
| requests | 2.32.5 | HTTP library for making API requests |
| decorator | 5.2.1 | Function decorator utilities |
| urllib3 | 2.3.0 | Low-level HTTP client |
| jsonschema | 4.25.1 | JSON schema validation |

