Tripo Python Client
Project description
Tripo Python Client
This is a Python client for the Tripo API.
Installation
pip install tripo
export TRIPO_API_KEY="your_api_key"
Usage
This first example is to get the balance.
from tripo import Client
with Client() as client:
balance = client.get_balance()
print(f"Balance: {balance.balance}, Frozen: {balance.frozen}")
This example is to generate a model from text.
import time
from tripo import Client
# Initialize the client
with Client() as client:
# Create a task to generate a model from text
success_task = client.text_to_model(
prompt="A 3D model of a futuristic car",
model_version="v2.0-20240919",
texture=True,
pbr=True
)
print(f"Created task with ID: {success_task.task_id}")
# Get 3d model
print("Waiting for the model to be ready...")
while True:
data = client.try_download_model(success_task.task_id)
if data is not None:
data.save("model.glb")
break
time.sleep(1)
This is the 3D model generated by the previous example.
The next example is to generate a model from an image.
import time
from tripo import Client
# Initialize the client
with Client() as client:
# Upload a file
upload_data = client.upload_file('path/to/your/image.jpg')
# Or upload a byte array
# byte_image = open('path/to/your/image.jpg', "rb").read()
# upload_data = client.upload_file(byte_image)
print(f"Uploaded file token: {upload_data.image_token}")
# Create a task to generate a model from an image
success_task = client.image_to_model(
file_token=upload_data.image_token,
model_version='v1.4-20240625',
texture=True,
pbr=True
)
print(f"Created task with ID: {success_task.task_id}")
# Get 3d model
print("Waiting for the model to be ready...")
while True:
data = client.try_download_model(success_task.task_id)
if data is not None:
data.save("model.glb")
break
time.sleep(1)
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
tripo-0.2.0.tar.gz
(2.3 MB
view details)
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
tripo-0.2.0-py3-none-any.whl
(5.4 kB
view details)
File details
Details for the file tripo-0.2.0.tar.gz.
File metadata
- Download URL: tripo-0.2.0.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
840acb679b63e837ab610f63c645dc6d842831bd393777598f7ac410b61ddb4d
|
|
| MD5 |
1dcd2ba86dc07681c0536e7eca06b010
|
|
| BLAKE2b-256 |
bdfd275275faa969df2e4b7a0bd362b0579be9e7937af1541911948080a1554c
|
File details
Details for the file tripo-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tripo-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
917579f1cd5ec1ce495406c25e2886c7508b2f9e69dc52a0c6c1a08496325bce
|
|
| MD5 |
f26c7a85a1a598de6b1d5b45f2ce714e
|
|
| BLAKE2b-256 |
0bef6d7a0dfc6338a43abd01cdb9ece8d7169f4ee93173962caa98d3bb174570
|