Skip to main content

Tripo Python Client

Project description

Tripo Python Client

PyPI version

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
    file_token = client.upload_file('path/to/your/image.jpg')
    # Or upload a byte array
    # byte_image = open('path/to/your/image.jpg', "rb").read()
    # file_token = client.upload_file(byte_image)
    print(f"Uploaded file token: {file_token.file_token}")

    # Create a task to generate a model from an image
    success_task = client.image_to_model(
        file_token=file_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.1.tar.gz (32.6 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.2.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tripo-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ce084db37e25d44eda148928b4ed26983ca21f276c6ffadb595123adf84d896d
MD5 e598bf35b5d431fdeec24b6aa5c0124f
BLAKE2b-256 b9c5d6e826087f73c6cbff3a8bc8b5f99b66bc2f84906e0240aebc6749e44f74

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tripo-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d902540ed3e8ddd2b529c98357b24b6a1ced03c6580b935e98f0a5bf24fb26a5
MD5 0e764678a684244d5af57f321c0d78f8
BLAKE2b-256 b8398ee0ef44ecaa400c4b606b120ce4d3836548caa326e864b55f632c47ace7

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