Skip to main content

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.x is a preview: byterun login, and a first client that starts a project and runs Python in it. The API may still change between 0.0.x releases. 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) and running Python code in them. Planned, in no fixed order and subject to change: files, SQL, 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=False to refuse instead). A Python exception or a timeout comes back as a result: check result.ok, result.status and result.error. Problems with the request itself raise ByteRunError.
  • 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 carry execution_id. If the run finished but its result is no longer stored, you get ExecutionExpiredError.
  • Ctrl-C asks ByteRun to cancel the run, then raises KeyboardInterrupt as usual with a note saying whether the run may still be going. cancel_on_interrupt=False leaves the run alone.
  • exec_file("script.py") runs one local file's text as exec(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() and project.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.

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-browser only prints the link, for SSH and headless machines: open it on any device.
  • --force logs 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-only only deletes the local file; the key stays valid until revoked.
  • Exit codes: 0 success, 1 failure (denied, expired, network), 2 usage error, 130 Ctrl+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.

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.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for byterun 0.0.5
File Size Uploaded Provenance Actions
byterun-0.0.5.tar.gz 39.3 kB With provenance Details for byterun-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for byterun 0.0.5
File Interpreter ABI Platform Actions
byterun-0.0.5-py3-none-any.whl Python 3 none any Details for byterun-0.0.5-py3-none-any.whl

Total release size: 68.8 kB

Release files / byterun-0.0.5.tar.gz

Download URL byterun-0.0.5.tar.gz
Size 39.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d0d9cfad20787876e109e33077e6b9d1b4e2c3511a742220d5f2f69f82bba133
BLAKE2b-256 checksum
How to use checksums
1ff22b113e91d403c381cd3c324d3e76d5a29a06673afdc21e8c43cc287e24f6
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 log

Release files / byterun-0.0.5-py3-none-any.whl

Download URL byterun-0.0.5-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
268d5f785b8fff54985bb9a246eee9d23d37b1cf9e4ebb87963e867d5da59eef
BLAKE2b-256 checksum
How to use checksums
5abc9352fcaaa08ceca0de2c07f405bbe1fd7ee88aa25b02719d65857775d7bd
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 log

Security for byterun 0.0.5

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.

Select from 2 files

Attestation for byterun-0.0.5.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page