Skip to main content

ByteRover Python SDK

The official Python SDK for the ByteRover API: search your team's drives and manage their documents.

pip install byterover

Python 3.11 or later · sync and thread-safe · typed

Upgrading from byterover 0.1.x? Version 0.2 is a new SDK with a different API. To keep the old client, pin byterover<0.2.

Quick start

Create an API key in ByteRover (Team → API keys → Create key) and set it as BYTEROVER_API_KEY. See Authentication.

from byterover import ByteRover

client = ByteRover()  # reads BYTEROVER_API_KEY

found = client.search(
    query="How long do refunds take in the EU?",
    drive_ids=["drv_…"],
    effort="medium",
)

for result in found.results:
    print(result.text)

Use the client in a with block, or call client.close() when you're done.

Configuration

client = ByteRover(timeout=30.0, max_retries=2)  # api_key= overrides BYTEROVER_API_KEY
Option Default
api_key BYTEROVER_API_KEY (required)
base_url BYTEROVER_BASE_URL, then https://byterover.ai/api
timeout 60 s per network step; 105 s for a medium search, 135 s for high
max_retries 2
http_client a new httpx.Client
logger none

The key is never printed in full: logs, errors and repr show only brv_ and four characters.

Usage

Resource Methods
client.search search one or more drives
client.key retrieve
client.drives list, retrieve
client.folders list, create, move, delete
client.documents list, retrieve, list_revisions, read, content, put_text, update, copy, delete, upload, upload_directory
client.uploads create, list_parts, put_part, complete, resume
client.operations retrieve, wait
client.request any other /v1/ endpoint

Field names match the API (drive_ids, next_cursor). Responses are pydantic models.

To rename a document or move it within its drive, use documents.update(document_id, path=...); documents.copy(..., move=True) moves it into another drive.

Pagination

for document in client.documents.list(drive_id, folder="/policies"):
    print(document.path)

Raw responses

answered = client.with_raw_response.documents.retrieve(document_id)
print(answered.status, answered.trace_id)

Uploads

Upload a file

result = client.documents.upload(drive_id, "/reports/q3.pdf", "q3.pdf", wait="searchable")
print(result.document.id)

The SDK hashes the file, sends it in parts, retries failed parts and completes the upload. The source can be a file path, bytes, a binary file opened with open(path, "rb"), or an object with size and read(start, end).

Resume after a crash

from byterover import UploadIncompleteError

try:
    client.documents.upload(drive_id, path, file, on_upload_created=lambda saved: store.put(path, saved))
except UploadIncompleteError:
    client.uploads.resume(store.get(path), file)

If the upload already completed, resume answers UPLOAD_CLOSED: look for the path with documents.list.

Upload a folder

result = client.documents.upload_directory(drive_id, "handbook", prefix="/handbook")
print(len(result.succeeded), len(result.uploaded_not_ready), len(result.failed), len(result.skipped))

Hidden files, empty files and symbolic links are skipped. uploaded_not_ready files were uploaded but their wait failed: don't upload them again. Send the failed ones again.

Wait for processing

result = client.documents.upload(drive_id, "/reports/q3.pdf", "q3.pdf")
client.operations.wait(result.operation.id)

More: Uploads guide.

Errors

Every error extends ByteRoverError. API errors extend APIStatusError and carry status, code, message and trace_id.

from byterover import NotFoundError, RateLimitError

try:
    client.documents.retrieve(document_id)
except NotFoundError:
    print("not found")
except RateLimitError:
    print("slow down")
Status Error
400 BadRequestError
401 AuthenticationError
402 InsufficientBalanceError
403 PermissionDeniedError
404 NotFoundError
409 ConflictError
429 RateLimitError
500 InternalServerError
503, 504 ServiceUnavailableError
no response APIConnectionError, APITimeoutError

Quote the trace_id when you contact support.

Retries

Reads are retried on connection errors, timeouts, 429 and 5xx. Writes and searches are retried only when they are known not to have run (the connection failed before sending, or the API's own 429), so nothing runs twice.

After a write's outcome is unknown, check the state first, then send it again with the same idempotency_key. The API answers a repeated key with the first result for 24 hours:

client.documents.put_text(drive_id, path="/notes/today.txt", text=text, idempotency_key="notes-2026-11-15")

Requirements

Supported
Python 3.11, 3.12, 3.13
Dependencies httpx (BSD-3-Clause), pydantic (MIT)

Versioning

This SDK is at 0.x: a minor version (0.2 → 0.3) may include breaking changes; a patch version doesn't. Pin a minor version, such as byterover>=0.2,<0.3. See Versioning and support and the changelog.

License

MIT

Metadata

Release files for byterover 0.2.2

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

Source distribution (sdist)

Source distribution for byterover 0.2.2
File Size Uploaded Provenance Actions
byterover-0.2.2.tar.gz 51.8 kB Without provenance Details for byterover-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 119.1 kB

Release files / byterover-0.2.2.tar.gz

Download URL byterover-0.2.2.tar.gz
Size 51.8 kB
Tags Source
SHA-256 checksum
How to use checksums
36dc3cff92787d513ffd37c26e0685f0e5492b12b9012a90318ac2e14bbb0025
BLAKE2b-256 checksum
How to use checksums
ce4991cb9d3038cd0344297d0a8d5c851d31ad9844d0f4d0c9aab111067b9c37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / byterover-0.2.2-py3-none-any.whl

Download URL byterover-0.2.2-py3-none-any.whl
Size 67.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ecf6588b89bf8d6eab416b20ded9971114ebe70eb07aa6926f84e6eb8028fd93
BLAKE2b-256 checksum
How to use checksums
ad3df1d6c7418ec92db22a33fcafe51210bba61ab41deabc45879115c954d0ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for byterover 0.2.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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