Documentation Index
Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
Use this file to discover all available pages before exploring further.
Setup
To get started, sign into Baseten with Truss and then install the Python requests library.
Sign in to Basetenuvx truss login --browser
Pick the model you want to deploy. Each tab is a self-contained recipe.
black-forest-labs/FLUX.1-dev is a 12B-parameter diffusion transformer model.This preset serves FLUX.1 dev on H100 40GB, tuned for text-to-image throughput.Write the config
Create and move into the project directory:mkdir flux1-dev-throughput && cd flux1-dev-throughput
Then create a file named config.yaml and paste the following:external_package_dirs: []
model_metadata:
example_model_input: {"prompt": 'black forest gateau cake spelling out the words "FLUX DEV", tasty, food photography, dynamic shot'}
repo_id: black-forest-labs/FLUX.1-dev
model_name: "model:flux1-dev preset:throughput"
python_version: py311
requirements:
- git+https://github.com/huggingface/diffusers.git@fc6a91e3834c35e57b398ad1c0d99f6f83557e04
- transformers>=4.0.0,<5.0.0
- accelerate
- sentencepiece
- protobuf
weights:
- source: "hf://black-forest-labs/FLUX.1-dev@main"
mount_location: "/models/FLUX.1-dev"
auth_secret_name: "hf_access_token"
resources:
accelerator: H100_40GB
use_gpu: true
secrets:
hf_access_token: null
system_packages:
- ffmpeg
- libsm6
- libxext6
Deploy
Push the config to Baseten:You should see output similar to:✨ Model flux1-dev-throughput was successfully pushed ✨
🪵 View logs for your deployment at https://app.baseten.co/models/abcd1234/logs/wxyz5678
Your model ID is the string after /models/ in the logs URL (abcd1234 in the example). Use it wherever you see {model_id} in the next section.Call the model
Your deployment exposes /predict. Replace {model_id} with your model ID and make sure BASETEN_API_KEY is set.The deployment returns the generated image as base64-encoded bytes. Decode the response to write the image to disk.import base64
import os
import requests
response = requests.post(
"https://model-{model_id}.api.baseten.co/environments/production/sync/predict",
headers={"Authorization": f"Api-Key {os.environ['BASETEN_API_KEY']}"},
json={"prompt": "black forest gateau cake spelling out the words \"FLUX DEV\", tasty, food photography, dynamic shot"},
)
image_b64 = response.json()["data"]
with open("output.png", "wb") as f:
f.write(base64.b64decode(image_b64))
curl -s https://model-{model_id}.api.baseten.co/environments/production/sync/predict \
-H "Content-Type: application/json" \
-H "Authorization: Api-Key $BASETEN_API_KEY" \
-d '{"prompt": "black forest gateau cake spelling out the words \"FLUX DEV\", tasty, food photography, dynamic shot"}' \
| jq -r '.data' | base64 --decode > output.png
black-forest-labs/FLUX.1-schnell is a 12B-parameter diffusion transformer model.This preset serves FLUX.1 schnell on H100 40GB. The step-distilled model delivers the fastest FLUX image generation per dollar.Write the config
Create and move into the project directory:mkdir flux1-schnell-throughput && cd flux1-schnell-throughput
Then create a file named config.yaml and paste the following:external_package_dirs: []
model_metadata:
example_model_input: {"prompt": 'black forest gateau cake spelling out the words "FLUX SCHNELL", tasty, food photography, dynamic shot'}
repo_id: black-forest-labs/FLUX.1-schnell
model_name: "model:flux1-schnell preset:throughput"
python_version: py311
requirements:
- git+https://github.com/huggingface/diffusers.git@fc6a91e3834c35e57b398ad1c0d99f6f83557e04
- transformers>=4.0.0,<5.0.0
- accelerate
- sentencepiece
- protobuf
- b10-transfer
weights:
- source: "hf://black-forest-labs/FLUX.1-schnell@main"
mount_location: "/models/FLUX.1-schnell"
auth_secret_name: "hf_access_token"
resources:
accelerator: H100_40GB
use_gpu: true
secrets:
hf_access_token: null
system_packages:
- ffmpeg
- libsm6
- libxext6
Deploy
Push the config to Baseten:You should see output similar to:✨ Model flux1-schnell-throughput was successfully pushed ✨
🪵 View logs for your deployment at https://app.baseten.co/models/abcd1234/logs/wxyz5678
Your model ID is the string after /models/ in the logs URL (abcd1234 in the example). Use it wherever you see {model_id} in the next section.Call the model
Your deployment exposes /predict. Replace {model_id} with your model ID and make sure BASETEN_API_KEY is set.The deployment returns the generated image as base64-encoded bytes. Decode the response to write the image to disk.import base64
import os
import requests
response = requests.post(
"https://model-{model_id}.api.baseten.co/environments/production/sync/predict",
headers={"Authorization": f"Api-Key {os.environ['BASETEN_API_KEY']}"},
json={"prompt": "black forest gateau cake spelling out the words \"FLUX SCHNELL\", tasty, food photography, dynamic shot"},
)
image_b64 = response.json()["data"]
with open("output.png", "wb") as f:
f.write(base64.b64decode(image_b64))
curl -s https://model-{model_id}.api.baseten.co/environments/production/sync/predict \
-H "Content-Type: application/json" \
-H "Authorization: Api-Key $BASETEN_API_KEY" \
-d '{"prompt": "black forest gateau cake spelling out the words \"FLUX SCHNELL\", tasty, food photography, dynamic shot"}' \
| jq -r '.data' | base64 --decode > output.png