You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+147Lines changed: 147 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -710,6 +710,153 @@ output2 = flux_dev(prompt="str") # output2 will be typed as `str`
710
710
711
711
In future we hope to provide tooling to generate and provide these models as packages to make working with them easier. For now you may wish to create your own.
712
712
713
+
### API Reference
714
+
715
+
The Replicate Python Library provides several key classes and functions for working with models in pipelines:
716
+
717
+
#### `use()` Function
718
+
719
+
Creates a callable function wrapper for a Replicate model.
720
+
721
+
```py
722
+
defuse(
723
+
ref: FunctionRef,
724
+
*,
725
+
streaming: bool=False,
726
+
use_async: bool=False
727
+
) -> Function | AsyncFunction
728
+
729
+
def use(
730
+
ref: str,
731
+
*,
732
+
hint: Callable |None=None,
733
+
streaming: bool=False,
734
+
use_async: bool=False
735
+
) -> Function | AsyncFunction
736
+
```
737
+
738
+
**Parameters:**
739
+
740
+
| Parameter | Type | Default | Description |
741
+
|-----------|------|---------|-------------|
742
+
|`ref`|`str \| FunctionRef` | Required | Model reference (e.g., "owner/model" or "owner/model:version") |
743
+
| `hint` | `Callable \| None` | `None` | Function signature for type hints |
744
+
|`streaming`|`bool`|`False`| Return OutputIterator for streaming results |
745
+
|`use_async`|`bool`|`False`| Return AsyncFunction instead of Function |
746
+
747
+
**Returns:**
748
+
-`Function`- Synchronous model wrapper (default)
749
+
-`AsyncFunction`- Asynchronous model wrapper (when `use_async=True`)
750
+
751
+
#### `Function` Class
752
+
753
+
A synchronous wrapper for calling Replicate models.
754
+
755
+
**Methods:**
756
+
757
+
| Method | Signature | Description |
758
+
|--------|-----------|-------------|
759
+
|`__call__()`|`(*args, **inputs) -> Output`| Execute the model andreturn final output |
760
+
|`create()`|`(*args, **inputs) -> Run`| Start a prediction andreturn Run object|
761
+
762
+
**Properties:**
763
+
764
+
| Property | Type | Description |
765
+
|----------|------|-------------|
766
+
|`openapi_schema`|`dict`| Model's OpenAPI schema for inputs/outputs |
0 commit comments