pub struct Client { /* private fields */ }Expand description
Async client for the Tripo 3D Generation API.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Read TRIPO_API_KEY (and optionally TRIPO_REGION) from the environment.
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Start a ClientBuilder.
Sourcepub fn with_api_key(key: impl Into<String>) -> Result<Self>
pub fn with_api_key(key: impl Into<String>) -> Result<Self>
Construct with an explicit key, using defaults for everything else.
Sourcepub fn with_base_url(self, url: Url) -> Self
pub fn with_base_url(self, url: Url) -> Self
Override the base URL (testing or staging).
Sourcepub async fn get_balance(&self) -> Result<Balance>
pub async fn get_balance(&self) -> Result<Balance>
GET /user/balance — current account balance.
Sourcepub async fn get_task(&self, id: &TaskId) -> Result<Task>
pub async fn get_task(&self, id: &TaskId) -> Result<Task>
GET /task/{id} — current state of an existing task.
Sourcepub async fn create_task(&self, req: TaskRequest) -> Result<TaskId>
pub async fn create_task(&self, req: TaskRequest) -> Result<TaskId>
POST /task — submit a task. Any ImageInput::Path in the request is
uploaded first and replaced with a FileToken.
Sourcepub async fn create_task_raw(&self, body: &Value) -> Result<TaskId>
pub async fn create_task_raw(&self, body: &Value) -> Result<TaskId>
Submit an already-built JSON body to /task. Used by create_task and
the CLI’s task create --json <FILE> escape hatch.
Source§impl Client
impl Client
Sourcepub async fn download_task_models(
&self,
task: &Task,
dir: &Path,
opts: DownloadOptions,
) -> Result<DownloadedFiles>
pub async fn download_task_models( &self, task: &Task, dir: &Path, opts: DownloadOptions, ) -> Result<DownloadedFiles>
Download all available outputs of a task into dir. Creates dir if
it does not exist. Atomic writes via .partial + rename.
Source§impl Client
impl Client
Sourcepub async fn upload_file(&self, path: impl AsRef<Path>) -> Result<UploadedFile>
pub async fn upload_file(&self, path: impl AsRef<Path>) -> Result<UploadedFile>
Upload a local file and return a token usable as ImageInput::FileToken.
Source§impl Client
impl Client
Sourcepub async fn wait_for_task(
&self,
id: &TaskId,
opts: WaitOptions,
) -> Result<Task>
pub async fn wait_for_task( &self, id: &TaskId, opts: WaitOptions, ) -> Result<Task>
Poll GET /task/{id} until the status is terminal or opts.timeout is reached.
Returns the final Task even for non-success terminal statuses; callers can check
task.status. Use Error::WaitTimeout if you want an error on timeout (returned here).