# APIFuture ## *class* [**tinker.APIFuture**](https://github.com/thinking-machines-lab/tinker/blob/main/src/tinker/lib/public_interfaces/api_future.py#L15)(...) Abstract base class for futures that can be awaited or accessed synchronously. APIFuture provides a unified interface for handling async operations that can be accessed both synchronously (via result()) and asynchronously (via await or result_async()). This allows for flexible usage patterns in both sync and async contexts. The future can be awaited directly in async contexts: ```python result = await api_future # Equivalent to await api_future.result_async() ``` **Or accessed synchronously:** ```python result = api_future.result() # Blocks until complete ``` ```python # In async context future = training_client.forward_backward(data, "cross_entropy") result = await future # Or await future.result_async() # In sync context future = training_client.forward_backward(data, "cross_entropy") result = future.result() ``` ### [**result**](https://github.com/thinking-machines-lab/tinker/blob/main/src/tinker/lib/public_interfaces/api_future.py#L63)(*timeout=None*) Get the result synchronously with optional timeout. **Parameters:** - [**timeout**](https://github.com/thinking-machines-lab/tinker/blob/main/src/tinker/lib/public_interfaces/api_future.py#L63) (*float | None*, default: `None`) – Maximum time to wait in seconds. None means wait indefinitely. **Returns:** The result value of type [`T`](https://github.com/thinking-machines-lab/tinker/blob/main/src/tinker/_utils/_proxy.py#L8) *Async variant:* `result_async()` ## Referenced by - [RestClient.get_sampler](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/restclient/#get_sampler) - [RestClient.get_weights_info_by_tinker_path](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/restclient/#get_weights_info_by_tinker_path) - [RestClient.whoami](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/restclient/#whoami) - [TrainingClient.forward](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#forward) - [TrainingClient.forward_backward](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#forward_backward) - [TrainingClient.forward_backward_custom](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#forward_backward_custom) - [TrainingClient.load_state](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#load_state) - [TrainingClient.load_state_with_optimizer](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#load_state_with_optimizer) - [TrainingClient.optim_step](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#optim_step) - [TrainingClient.save_state](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#save_state) - [TrainingClient.save_weights_for_sampler](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/trainingclient/#save_weights_for_sampler)