Skip to main content

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.

3D Model

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.1.5.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tripo-0.1.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file tripo-0.1.5.tar.gz.

File metadata

  • Download URL: tripo-0.1.5.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for tripo-0.1.5.tar.gz
Algorithm Hash digest
SHA256 754b6b0679feece9fcdb5159bc6115625a2093d1845c5f95523144b714f8fa33
MD5 9b35c6eb93e3b0f0f517b2d2e7a0f47f
BLAKE2b-256 4fec05474504d8940d4e2d9bc500212180f07c9780bb3e6ef3e139856c921891

See more details on using hashes here.

File details

Details for the file tripo-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: tripo-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for tripo-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 506ce739e6171daa832093b2dec343cc28d29d756d8ff9d188ec6919e6bc05fa
MD5 cc9cca1508e49ec5f8adad59169e071c
BLAKE2b-256 20dfbe2fa70f299d2c7bc16b8421786da79cec376a35917c72949a1581b64596

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page