- Public
- 190 runs
-
CPU
Run andreasjansson/exec-python with an API
Use one of our client libraries to get started quickly. Clicking on a library will take you to the Playground tab where you can tweak different inputs, see the results, and copy the corresponding code to use in your own project.
Input schema
The fields you can use to run this model with an API. If you don't give a value for a field its default value will be used.
Field | Type | Default value | Description |
---|---|---|---|
code |
string
|
Python code to execute in a Python 3.12 environment. You have access to the following external packages that you may import: numpy==2.2.4, scipy==1.15.2, pillow==10.4.0, matplotlib==3.10.1, moviepy==2.1.2, opencv-python==4.11.0.86, uv==0.7.3. You also have access to the following command line system packages that you may subprocess to: imagemagick, ffmpeg, sox. Your code will be executed in a temporary directory. If you provided a zip file, its contents will be extracted to this directory before your code runs. Any file outputs should be written to the current working directory. Only files created in this directory will be returned, along with stdout from the script.
|
|
files_zip |
string
|
Optional ZIP file containing code, data, or other files that will be extracted to the execution directory and available to the script.
|
|
file1 |
string
|
An optional file to be used by the code. Access via `file1` (of type pathlib.Path) in your code (e.g. `Image.open(file1.name)`). Files must be passed through these inputs as the execution environment has no other file access.
|
|
file2 |
string
|
An optional file to be used by the code. Access via `file2` (of type pathlib.Path) in your code (e.g. `Image.open(file2.name)`). Files must be passed through these inputs as the execution environment has no other file access.
|
|
file3 |
string
|
An optional file to be used by the code. Access via `file3` (of type pathlib.Path) in your code (e.g. `Image.open(file3.name)`). Files must be passed through these inputs as the execution environment has no other file access.
|
|
file4 |
string
|
An optional file to be used by the code. Access via `file4` (of type pathlib.Path) in your code (e.g. `Image.open(file4.name)`). Files must be passed through these inputs as the execution environment has no other file access.
|
|
file5 |
string
|
An optional file to be used by the code. Access via `file5` (of type pathlib.Path) in your code (e.g. `Image.open(file5.name)`). Files must be passed through these inputs as the execution environment has no other file access.
|
|
python_packages |
array
|
[]
|
List of additional Python package requirements to install with uv
|
system_packages |
array
|
[]
|
List of additional system packages to install with apt-get
|
timeout |
integer
|
300
Min: 1 Max: 600 |
Script timeout in seconds
|
{
"type": "object",
"title": "Input",
"required": [
"code"
],
"properties": {
"code": {
"type": "string",
"title": "Code",
"x-order": 0,
"description": "Python code to execute in a Python 3.12 environment. You have access to the following external packages that you may import: numpy==2.2.4, scipy==1.15.2, pillow==10.4.0, matplotlib==3.10.1, moviepy==2.1.2, opencv-python==4.11.0.86, uv==0.7.3. You also have access to the following command line system packages that you may subprocess to: imagemagick, ffmpeg, sox. Your code will be executed in a temporary directory. If you provided a zip file, its contents will be extracted to this directory before your code runs. Any file outputs should be written to the current working directory. Only files created in this directory will be returned, along with stdout from the script."
},
"file1": {
"type": "string",
"title": "File1",
"format": "uri",
"x-order": 2,
"description": "An optional file to be used by the code. Access via `file1` (of type pathlib.Path) in your code (e.g. `Image.open(file1.name)`). Files must be passed through these inputs as the execution environment has no other file access."
},
"file2": {
"type": "string",
"title": "File2",
"format": "uri",
"x-order": 3,
"description": "An optional file to be used by the code. Access via `file2` (of type pathlib.Path) in your code (e.g. `Image.open(file2.name)`). Files must be passed through these inputs as the execution environment has no other file access."
},
"file3": {
"type": "string",
"title": "File3",
"format": "uri",
"x-order": 4,
"description": "An optional file to be used by the code. Access via `file3` (of type pathlib.Path) in your code (e.g. `Image.open(file3.name)`). Files must be passed through these inputs as the execution environment has no other file access."
},
"file4": {
"type": "string",
"title": "File4",
"format": "uri",
"x-order": 5,
"description": "An optional file to be used by the code. Access via `file4` (of type pathlib.Path) in your code (e.g. `Image.open(file4.name)`). Files must be passed through these inputs as the execution environment has no other file access."
},
"file5": {
"type": "string",
"title": "File5",
"format": "uri",
"x-order": 6,
"description": "An optional file to be used by the code. Access via `file5` (of type pathlib.Path) in your code (e.g. `Image.open(file5.name)`). Files must be passed through these inputs as the execution environment has no other file access."
},
"timeout": {
"type": "integer",
"title": "Timeout",
"default": 300,
"maximum": 600,
"minimum": 1,
"x-order": 9,
"description": "Script timeout in seconds"
},
"files_zip": {
"type": "string",
"title": "Files Zip",
"format": "uri",
"x-order": 1,
"description": "Optional ZIP file containing code, data, or other files that will be extracted to the execution directory and available to the script."
},
"python_packages": {
"type": "array",
"items": {
"type": "string"
},
"title": "Python Packages",
"default": [],
"x-order": 7,
"description": "List of additional Python package requirements to install with uv"
},
"system_packages": {
"type": "array",
"items": {
"type": "string"
},
"title": "System Packages",
"default": [],
"x-order": 8,
"description": "List of additional system packages to install with apt-get"
}
}
}
Output schema
The shape of the response you’ll get when you run this model with an API.
Schema
{
"type": "object",
"title": "ModelOutput",
"properties": {
"text": {
"type": "string",
"title": "Text"
},
"files": {
"type": "object",
"title": "Files",
"additionalProperties": {
"type": "string",
"format": "uri"
}
}
}
}