go/resources/uploads/subresources/parts/index.md +0 −117 deleted
File Deleted View Diff
1# Parts
2
3## Add upload part
4
5`client.Uploads.Parts.New(ctx, uploadID, body) (*UploadPart, error)`
6
7**post** `/uploads/{upload_id}/parts`
8
9Adds a [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object. A Part represents a chunk of bytes from the file you are trying to upload.
10
11Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.
12
13It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
14
15### Parameters
16
17- `uploadID string`
18
19- `body UploadPartNewParams`
20
21 - `Data param.Field[Reader]`
22
23 The chunk of bytes for this Part.
24
25### Returns
26
27- `type UploadPart struct{…}`
28
29 The upload Part represents a chunk of bytes we can add to an Upload object.
30
31 - `ID string`
32
33 The upload Part unique identifier, which can be referenced in API endpoints.
34
35 - `CreatedAt int64`
36
37 The Unix timestamp (in seconds) for when the Part was created.
38
39 - `Object UploadPart`
40
41 The object type, which is always `upload.part`.
42
43 - `const UploadPartUploadPart UploadPart = "upload.part"`
44
45 - `UploadID string`
46
47 The ID of the Upload object that this Part was added to.
48
49### Example
50
51```go
52package main
53
54import (
55 "bytes"
56 "context"
57 "fmt"
58 "io"
59
60 "github.com/openai/openai-go"
61 "github.com/openai/openai-go/option"
62)
63
64func main() {
65 client := openai.NewClient(
66 option.WithAPIKey("My API Key"),
67 )
68 uploadPart, err := client.Uploads.Parts.New(
69 context.TODO(),
70 "upload_abc123",
71 openai.UploadPartNewParams{
72 Data: io.Reader(bytes.NewBuffer([]byte("Example data"))),
73 },
74 )
75 if err != nil {
76 panic(err.Error())
77 }
78 fmt.Printf("%+v\n", uploadPart.ID)
79}
80```
81
82#### Response
83
84```json
85{
86 "id": "id",
87 "created_at": 0,
88 "object": "upload.part",
89 "upload_id": "upload_id"
90}
91```
92
93## Domain Types
94
95### Upload Part
96
97- `type UploadPart struct{…}`
98
99 The upload Part represents a chunk of bytes we can add to an Upload object.
100
101 - `ID string`
102
103 The upload Part unique identifier, which can be referenced in API endpoints.
104
105 - `CreatedAt int64`
106
107 The Unix timestamp (in seconds) for when the Part was created.
108
109 - `Object UploadPart`
110
111 The object type, which is always `upload.part`.
112
113 - `const UploadPartUploadPart UploadPart = "upload.part"`
114
115 - `UploadID string`
116
117 The ID of the Upload object that this Part was added to.