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
When using Friendli Python SDK, you need to provide a Friendli Token for authentication and authorization purposes. A Friendli Token serves as an alternative method of authorization to signing in with an email and a password. You can generate a new Friendli Token through the [Friendli Suite](https://suite.friendli.ai), at your "Personal settings" page by following the steps below.
11
+
When using Friendli Python SDK, you need to provide a Friendli Token for authentication and authorization purposes. A Friendli Token serves as an alternative method of authorization to signing in with an email and a password. You can generate a new Friendli Token through the [Friendli Suite](https://friendli.ai/suite), at your "Personal settings" page by following the steps below.
12
12
13
-
1. Go to the [Friendli Suite](https://suite.friendli.ai) and sign in with your account.
13
+
1. Go to the [Friendli Suite](https://friendli.ai/suite) and sign in with your account.
14
14
2. Click the profile icon at the top-right corner of the page.
15
15
3. Click "Personal settings" menu.
16
16
4. Go to the "Tokens" tab on the navigation bar.
@@ -29,6 +29,7 @@ When using Friendli Python SDK, you need to provide a Friendli Token for authent
29
29
*[Authentication](#authentication)
30
30
*[Available Resources and Operations](#available-resources-and-operations)
<!-- End Server-sent event streaming [eventstream] -->
414
448
449
+
<!-- Start File uploads [file-upload] -->
450
+
## File uploads
451
+
452
+
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
453
+
454
+
> [!TIP]
455
+
>
456
+
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
457
+
>
458
+
459
+
```python
460
+
import os
461
+
462
+
from friendli import SyncFriendli
463
+
464
+
with SyncFriendli(
465
+
token=os.getenv("FRIENDLI_TOKEN", ""),
466
+
) as friendli:
467
+
res = friendli.platform.files.upload(
468
+
file={
469
+
"file_name": "example.file",
470
+
"content": open("example.file", "rb"),
471
+
},
472
+
purpose="batch",
473
+
)
474
+
475
+
# Handle response
476
+
print(res)
477
+
```
478
+
<!-- End File uploads [file-upload] -->
479
+
415
480
<!-- Start Retries [retries] -->
416
481
## Retries
417
482
@@ -492,11 +557,12 @@ By default, an API error will raise a models.SDKError exception, which has the f
492
557
|`.raw_response`|*httpx.Response*| The raw HTTP response |
493
558
|`.body`|*str*| The response content |
494
559
495
-
When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `complete` method may raise the following exceptions:
560
+
When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create` method may raise the following exceptions:
0 commit comments