ByteRun Python SDK
The official Python SDK for ByteRun, an AI infrastructure platform that provides execution environments for Python, SQL and AI agents.
Early preview. Version
0.0.xis a preview:byterun login, and a first client that starts a project and runs Python in it. The API may still change between0.0.xreleases. Try ByteRun in the playground on byterun.io, and follow the roadmap for what comes next.
What is ByteRun?
ByteRun gives developers managed environments to run code and AI agents without operating the infrastructure themselves. Today that covers Python, SQL and agent execution; the platform roadmap also includes headless jobs, workflows and inference. See the platform overview for details.
What this SDK is for
This SDK is meant to be the single Python entry point to ByteRun, so you can work with the platform from your own code, scripts and services. AI agent execution comes first; other platform capabilities will be added to the same package rather than split into separate ones.
Available today: projects (start, stop, status), running Python code in them, uploading and downloading files, SQL on your data connections, and checking what a key is. Planned, in no fixed order and subject to change: headless jobs, workflows and inference.
Installation
Requires Python 3.10 or newer.
pip install byterun
Check that it installed:
python -c "import byterun; print(byterun.__version__)"
Running code
from byterun import ByteRun
with ByteRun() as client:
project = client.project() # the key's default project
result = project.exec("x = 6 * 7; print(x)")
print(result.stdout) # 42
print(project.exec("print(x + 1)").stdout) # 43: state is kept until the project stops
project.stop()
exec()starts the project if it is stopped and waits until it is ready (auto_start=Falseto refuse instead). A Python exception or a timeout comes back as a result: checkresult.ok,result.statusandresult.error. Problems with the request itself raiseByteRunError.- A run is safe to wait for.
exec()submits it with a key made for that call and polls until it finishes, so a dropped connection, a rate limit or a gateway error is retried without running your code twice. Only two cases are unknown: the backend restarted mid-run (ExecutionOutcomeUnknownError,reason="lost") or nothing answered before the deadline. Both carryexecution_id. If the run finished but its result is no longer stored, you getExecutionExpiredError. - Ctrl-C asks ByteRun to cancel the run, then raises
KeyboardInterruptas usual with a note saying whether the run may still be going.cancel_on_interrupt=Falseleaves the run alone. exec_file("script.py")runs one local file's text asexec(text); nothing else is uploaded.client.project("name")picks a project by name, and creates it if the key may create projects.project.start(),project.stop()andproject.status()manage the project.stop()is never done for you: a running project uses your plan's compute hours.
ByteRun() finds a key in this order: the api_key= argument, then the BYTERUN_API_KEY
environment variable, then the key byterun login saved. For CI, servers and containers, create a
key in Settings, API keys on byterun.io and set BYTERUN_API_KEY.
Files
from pathlib import Path
from byterun import ByteRun
with ByteRun() as client:
project = client.project()
project.upload("data/in.csv", Path("in.csv")) # a Path is streamed from disk
project.upload("data/note.txt", b"hello") # or pass the bytes
project.exec("open('out.txt', 'w').write(open('data/note.txt').read())")
project.download("out.txt", "out.txt") # write a local file
content = project.download("out.txt") # or get the bytes
- Paths are relative to the project's workspace, which is where your code runs. One file per call.
- Nothing is overwritten unless you say
overwrite=True: a taken name is aConflictErroron upload and aFileExistsErrorfor the local file on download. A download is complete or not there at all. - Accepted types are common data, text, image and archive formats; notebooks, pickles and executables
are refused. Size and storage limits depend on your plan (
PlanLimitExceededErrorwhen storage is full). They are checked on uploads; files your code writes in the project are not capped by them. - The key needs the files permission.
byterun loginincludes it; if you logged in before, runbyterun login --force. Files do not need the project to be running.
SQL
with ByteRun() as client:
project = client.project()
for connection in project.connections():
print(connection.name, connection.type)
print(project.schema("warehouse").tables) # schema -> table -> columns
result = project.sql("warehouse", "select region, count(*) from sales group by 1", limit=100)
print(result.columns, result.rows, result.truncated)
project.exec(f"df = byterun.load_result('{result.result_id}')") # within about 10 minutes
- Data connections are set up in ByteRun. The SDK sees their names and types, never hosts or credentials.
- SQL does not need the project to be running. A query the database refuses is a result with
ok == Falseanderror. A query is never repeated; if no answer comes back,ServiceErrorsays it may have run. - Values are text. SQL
NULLisNone, and an empty string stays"".
What is my key?
me = ByteRun().whoami()
me.require_scopes("exec", "sql") # fail early, with the missing permission named
print(me.org_id, sorted(me.scopes), me.expires_at, me.allowance)
byterun status (or byterun whoami) prints the same, says which key is used, and warns when it is
about to expire or when BYTERUN_API_KEY overrides your saved login.
Logging in from the command line
pip install byterun
byterun login # opens your browser; approve the request, and a key is saved on this machine
byterun logout # revokes this machine's key and deletes the saved credentials
byterun login prints a short code and a link, opens the link in your browser and waits. Check
that the code on the page matches the one in your terminal before you approve, and only approve a
login you started. Each machine gets its own key (limited to your starter project, 90 days), so
revoking one never affects another. You can see and revoke keys in Settings on byterun.io.
--no-browseronly prints the link, for SSH and headless machines: open it on any device.--forcelogs in again even if this machine is already logged in. The new key is saved first, then the old one is revoked.byterun logout --local-onlyonly deletes the local file; the key stays valid until revoked.- Exit codes:
0success,1failure (denied, expired, network),2usage error,130Ctrl+C.
The key is stored in ~/.config/byterun/credentials.json (or under $XDG_CONFIG_HOME), a 0600
file in a 0700 directory, and is never printed. The SDK talks to https://api.byterun.io; set
BYTERUN_API_URL only to point at another deployment. A key is accepted on the API host only.
A key lets code run in your project's container with that project's privileges. ByteRun is not a sandbox for untrusted code: treat the key like a password.
Naming
| Where | Name |
|---|---|
| PyPI package | byterun |
| Python import | byterun |
| GitHub repository | byterun-python |
Feedback and contributions
Questions, ideas and bug reports are welcome as GitHub issues. The API is still being designed, so please open an issue to discuss before sending a large pull request.
Links
- Website: https://byterun.io/
- Platform: https://byterun.io/platform
- Roadmap: https://byterun.io/roadmap
- PyPI: https://pypi.org/project/byterun/
- Source: https://github.com/byterunio/byterun-python
License
Licensed under the Apache License, Version 2.0. Unless required by applicable law or agreed to in writing, the software is distributed on an "AS IS" basis, without warranties or conditions of any kind.
Metadata
Release files for byterun 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| byterun-0.0.6.tar.gz | 52.9 kB | With provenance | Details for byterun-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| byterun-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for byterun-0.0.6-py3-none-any.whl |
Total release size: 92.8 kB
Release files / byterun-0.0.6.tar.gz
| Download URL | byterun-0.0.6.tar.gz |
|---|---|
| Size | 52.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
938beca8f9569acaa7019ee2571d6630fd8f8af33c4f55c49e1d24673d292e4f
|
|
BLAKE2b-256 checksum How to use checksums |
87da149c55a2dbfd9e0a10937479248bd3396f0082d59751ecf94b3ee1503401
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / byterun-0.0.6-py3-none-any.whl
| Download URL | byterun-0.0.6-py3-none-any.whl |
|---|---|
| Size | 39.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de4f6200489f09e62f0978e6808196120b1d14870569d53f2415bf0d29df3f12
|
|
BLAKE2b-256 checksum How to use checksums |
2970bfd39972835e0fcb70c272b8ee10f92722d15de93dc51065c56b95f0494b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for byterun 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for byterun-0.0.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.