Python client for modelrunner.ai
Project description
modelrunner.ai Python client
This is a Python client library for interacting with ML models deployed on modelrunner.ai.
Getting started
To install the client, run:
pip install modelrunner-client
To use the client, you need to have an API key. You can get one by signing up at modelrunner.ai. Once you have it, set it as an environment variable:
export MODELRUNNER_KEY=your-api-key
Now you can use the client to interact with your models. Here's an example of how to use it:
import asyncio
import modelrunner_client
async def main():
response = await modelrunner_client.run_async("bytedance/sdxl-lightning-4step", arguments={"prompt": "two friends cooking together"})
print(response["images"][0]["url"])
asyncio.run(main())
Uploading files
If the model requires files as input, you can upload them directly to media.modelrunner.ai (our CDN) and pass the URLs to the client. Here's an example:
import modelrunner_client
input_audio = modelrunner_client.upload_file("path/to/audio.wav")
response = modelrunner_client.run("meta/musicgen", arguments={"input_audio": input_audio})
print(response["text"])
Queuing requests
When you want to send a request and keep receiving updates on its status, you can use the submit method. Here's an example:
import asyncio
import modelrunner_client
async def main():
response = await modelrunner_client.submit_async("bytedance/sdxl-lightning-4step", arguments={"prompt": "two friends cooking together"})
logs_index = 0
async for event in response.iter_events(with_logs=True):
if isinstance(event, modelrunner_client.Queued):
print("Queued. Position:", event.position)
elif isinstance(event, (modelrunner_client.InProgress, modelrunner_client.Completed)):
new_logs = event.logs[logs_index:]
for log in new_logs:
print(log["message"])
logs_index = len(event.logs)
result = await response.get()
print(result["images"][0]["url"])
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modelrunner_ai-0.0.3.tar.gz.
File metadata
- Download URL: modelrunner_ai-0.0.3.tar.gz
- Upload date:
- Size: 135.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64a9db39cbb4a3eedfa932e95287584f6f5819dad7b0e349164572f78f67be6f
|
|
| MD5 |
b85d85554a21b67aad21a2b5121ca607
|
|
| BLAKE2b-256 |
6ffaaaff506103dbc0083050a9e9669a06507c9803dc9d459aa0829467773b79
|
Provenance
The following attestation bundles were made for modelrunner_ai-0.0.3.tar.gz:
Publisher:
release.yaml on modelrunner/modelrunner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
modelrunner_ai-0.0.3.tar.gz -
Subject digest:
64a9db39cbb4a3eedfa932e95287584f6f5819dad7b0e349164572f78f67be6f - Sigstore transparency entry: 601075370
- Sigstore integration time:
-
Permalink:
modelrunner/modelrunner@e136899f10b0d96973a4ed23926ed7489ecb5534 -
Branch / Tag:
refs/tags/modelrunner_client_v0.0.3 - Owner: https://github.com/modelrunner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@e136899f10b0d96973a4ed23926ed7489ecb5534 -
Trigger Event:
release
-
Statement type:
File details
Details for the file modelrunner_ai-0.0.3-py3-none-any.whl.
File metadata
- Download URL: modelrunner_ai-0.0.3-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f07ca732d83490c29fce16aed613b60eb237a7aa95eb8b82da04ee19fe2c9a6
|
|
| MD5 |
191c918ca6cb08fb153e2cfbac91d9d6
|
|
| BLAKE2b-256 |
fd4a97f37541bbbe5909c9901283d927477a4daa385528bec7ae0ed2dc4956a7
|
Provenance
The following attestation bundles were made for modelrunner_ai-0.0.3-py3-none-any.whl:
Publisher:
release.yaml on modelrunner/modelrunner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
modelrunner_ai-0.0.3-py3-none-any.whl -
Subject digest:
1f07ca732d83490c29fce16aed613b60eb237a7aa95eb8b82da04ee19fe2c9a6 - Sigstore transparency entry: 601075371
- Sigstore integration time:
-
Permalink:
modelrunner/modelrunner@e136899f10b0d96973a4ed23926ed7489ecb5534 -
Branch / Tag:
refs/tags/modelrunner_client_v0.0.3 - Owner: https://github.com/modelrunner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@e136899f10b0d96973a4ed23926ed7489ecb5534 -
Trigger Event:
release
-
Statement type: