go/resources/models/index.md +0 −239 deleted
File Deleted View Diff
1# Models
2
3## List models
4
5`client.Models.List(ctx) (*Page[Model], error)`
6
7**get** `/models`
8
9Lists the currently available models, and provides basic information about each one such as the owner and availability.
10
11### Returns
12
13- `type Model struct{…}`
14
15 Describes an OpenAI model offering that can be used with the API.
16
17 - `ID string`
18
19 The model identifier, which can be referenced in the API endpoints.
20
21 - `Created int64`
22
23 The Unix timestamp (in seconds) when the model was created.
24
25 - `Object Model`
26
27 The object type, which is always "model".
28
29 - `const ModelModel Model = "model"`
30
31 - `OwnedBy string`
32
33 The organization that owns the model.
34
35### Example
36
37```go
38package main
39
40import (
41 "context"
42 "fmt"
43
44 "github.com/openai/openai-go"
45 "github.com/openai/openai-go/option"
46)
47
48func main() {
49 client := openai.NewClient(
50 option.WithAPIKey("My API Key"),
51 )
52 page, err := client.Models.List(context.TODO())
53 if err != nil {
54 panic(err.Error())
55 }
56 fmt.Printf("%+v\n", page)
57}
58```
59
60#### Response
61
62```json
63{
64 "data": [
65 {
66 "id": "id",
67 "created": 0,
68 "object": "model",
69 "owned_by": "owned_by"
70 }
71 ],
72 "object": "list"
73}
74```
75
76## Retrieve model
77
78`client.Models.Get(ctx, model) (*Model, error)`
79
80**get** `/models/{model}`
81
82Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
83
84### Parameters
85
86- `model string`
87
88### Returns
89
90- `type Model struct{…}`
91
92 Describes an OpenAI model offering that can be used with the API.
93
94 - `ID string`
95
96 The model identifier, which can be referenced in the API endpoints.
97
98 - `Created int64`
99
100 The Unix timestamp (in seconds) when the model was created.
101
102 - `Object Model`
103
104 The object type, which is always "model".
105
106 - `const ModelModel Model = "model"`
107
108 - `OwnedBy string`
109
110 The organization that owns the model.
111
112### Example
113
114```go
115package main
116
117import (
118 "context"
119 "fmt"
120
121 "github.com/openai/openai-go"
122 "github.com/openai/openai-go/option"
123)
124
125func main() {
126 client := openai.NewClient(
127 option.WithAPIKey("My API Key"),
128 )
129 model, err := client.Models.Get(context.TODO(), "gpt-4o-mini")
130 if err != nil {
131 panic(err.Error())
132 }
133 fmt.Printf("%+v\n", model.ID)
134}
135```
136
137#### Response
138
139```json
140{
141 "id": "id",
142 "created": 0,
143 "object": "model",
144 "owned_by": "owned_by"
145}
146```
147
148## Delete a fine-tuned model
149
150`client.Models.Delete(ctx, model) (*ModelDeleted, error)`
151
152**delete** `/models/{model}`
153
154Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.
155
156### Parameters
157
158- `model string`
159
160### Returns
161
162- `type ModelDeleted struct{…}`
163
164 - `ID string`
165
166 - `Deleted bool`
167
168 - `Object string`
169
170### Example
171
172```go
173package main
174
175import (
176 "context"
177 "fmt"
178
179 "github.com/openai/openai-go"
180 "github.com/openai/openai-go/option"
181)
182
183func main() {
184 client := openai.NewClient(
185 option.WithAPIKey("My API Key"),
186 )
187 modelDeleted, err := client.Models.Delete(context.TODO(), "ft:gpt-4o-mini:acemeco:suffix:abc123")
188 if err != nil {
189 panic(err.Error())
190 }
191 fmt.Printf("%+v\n", modelDeleted.ID)
192}
193```
194
195#### Response
196
197```json
198{
199 "id": "id",
200 "deleted": true,
201 "object": "object"
202}
203```
204
205## Domain Types
206
207### Model
208
209- `type Model struct{…}`
210
211 Describes an OpenAI model offering that can be used with the API.
212
213 - `ID string`
214
215 The model identifier, which can be referenced in the API endpoints.
216
217 - `Created int64`
218
219 The Unix timestamp (in seconds) when the model was created.
220
221 - `Object Model`
222
223 The object type, which is always "model".
224
225 - `const ModelModel Model = "model"`
226
227 - `OwnedBy string`
228
229 The organization that owns the model.
230
231### Model Deleted
232
233- `type ModelDeleted struct{…}`
234
235 - `ID string`
236
237 - `Deleted bool`
238
239 - `Object string`