Model API
- Welcome
- Get started
- Understand the API
- Tasks
Get started
Install our API libraries and run inference in seconds
You can use the API with any programming language that can make HTTP requests, but we recommend using one of our official SDKs for ease of use and convenience.
We have libraries for Python, JavaScript, and Julia. Using Python 3.9+, JavaScript, or Julia, install the appropriate package:
pip install bytez
Bytez allows you to use open-source and closed-source models with a single API key.
Use open-source models
- Copy your key from the API Dashboard.
- Use your Bytez Key in requests
from bytez import Bytez
sdk = Bytez("BYTEZ_KEY")
You’re now set to use open source models on Bytez!
Use closed-source models
To use a closed-source model, you’ll need an account with the model provider. For example, if you want to use OpenAI
models, you’ll need an OpenAI key. We call your closed source key a “provider key”
- Copy your key from the API Dashboard.
- Use your Bytez Key AND closed-source provider key in requests.
# add a "provider-key" header, and set its value to "{KEY}"
curl -X GET "https://api.bytez.com/models/v2/some-endpoint" \
-H "Authorization: Key BYTEZ_KEY" \
-H "provider-key: {your-key}"
Bytez API Key Security & Usage
We securely route your requests as a pass-through service. Your API keys are never stored or logged by Bytez; they are only used to authenticate directly with the model provider.
Recommendation: Use a dedicated API key for Bytez for maximum security and traceability.
- Billing: No extra Bytez fees for closed-source models; you’re billed directly by the provider based on usage associated with your key.
- Integration: Seamlessly use the same input format for all models (open and closed-source).
If you need help with any of this, please DM us in Discord or submit an issue on GitHub. We’re happy to help.
Running is a model is easy. Just select the model and pass it an input
from bytez import Bytez
sdk = Bytez("BYTEZ_KEY")
model_id = "openai-community/gpt-2"
model = sdk.model(model_id)
output, error = model.run("Once upon a time")
print(output)
Read more about our schema by visiting our HTTP reference.
You can list all the tasks, models, and running models using the API.
Tasks
A task
defines a specific function a model performs (e.g., object-detection). Multiple models might be available for the same task. To list all tasks supported by Bytez, run the following command:
from bytez import Bytez
sdk = Bytez("BYTEZ_KEY")
output, error = sdk.list.tasks()
print(output)
Models
A model
refers to a software function with unique identifier. Models
execute tasks
. For example, the model google/vit-base-patch16-224
executes image-classification
. To list all open-source models supported by Bytez, run the following command:
from bytez import Bytez
sdk = Bytez("BYTEZ_KEY")
output, error = sdk.list.models()
print(output)
Clusters
A cluster
represents the auto-scaling GPU infrastructure Bytez provisions specifically for running an open-source model serverlessly. It’s created automatically when needed and scales with demand. To list your active clusters, run the following command:
from bytez import Bytez
sdk = Bytez("BYTEZ_KEY")
output, error = sdk.list.clusters()
print(output)