Skip to content

Commit 5ec73f1

Browse files
feat(api): Change image creation signature to images.generate
BREAKING CHANGE: For the TS SDK the `images.create` is now `images.generate`
1 parent 90871a9 commit 5ec73f1

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 46
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-57c68db188c5a4e69e16f99e7e4968f08f2dbf64e7e7d8f57f54f84669305189.yml
33
openapi_spec_hash: 4e707463a416fd079a6beeff1d1beecb
4-
config_hash: ff6223e5c6a73b836f4d70ea6d1f385f
4+
config_hash: 2fabf9b1cee38923853fcfbad54500ca

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Response Types:
152152

153153
Methods:
154154

155-
- <code title="post /images/generations">client.Images.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#ImageService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#ImageNewParams">ImageNewParams</a>) (<a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#ImageFile">ImageFile</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
155+
- <code title="post /images/generations">client.Images.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#ImageService.Generate">Generate</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#ImageGenerateParams">ImageGenerateParams</a>) (<a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#ImageFile">ImageFile</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
156156

157157
# Videos
158158

image.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func NewImageService(opts ...option.RequestOption) (r ImageService) {
3535
}
3636

3737
// Use an image model to generate an image for a given prompt.
38-
func (r *ImageService) New(ctx context.Context, body ImageNewParams, opts ...option.RequestOption) (res *ImageFile, err error) {
38+
func (r *ImageService) Generate(ctx context.Context, body ImageGenerateParams, opts ...option.RequestOption) (res *ImageFile, err error) {
3939
opts = slices.Concat(r.Options, opts)
4040
path := "images/generations"
4141
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -192,11 +192,11 @@ const (
192192
ImageFileObjectList ImageFileObject = "list"
193193
)
194194

195-
type ImageNewParams struct {
195+
type ImageGenerateParams struct {
196196
// The model to use for image generation.
197197
//
198198
// [See all of Together AI's image models](https://docs.together.ai/docs/serverless-models#image-models)
199-
Model ImageNewParamsModel `json:"model,omitzero,required"`
199+
Model ImageGenerateParamsModel `json:"model,omitzero,required"`
200200
// A description of the desired images. Maximum length varies by model.
201201
Prompt string `json:"prompt,required"`
202202
// If true, disables the safety checker for image generation.
@@ -221,40 +221,40 @@ type ImageNewParams struct {
221221
Width param.Opt[int64] `json:"width,omitzero"`
222222
// An array of objects that define LoRAs (Low-Rank Adaptations) to influence the
223223
// generated image.
224-
ImageLoras []ImageNewParamsImageLora `json:"image_loras,omitzero"`
224+
ImageLoras []ImageGenerateParamsImageLora `json:"image_loras,omitzero"`
225225
// The format of the image response. Can be either be `jpeg` or `png`. Defaults to
226226
// `jpeg`.
227227
//
228228
// Any of "jpeg", "png".
229-
OutputFormat ImageNewParamsOutputFormat `json:"output_format,omitzero"`
229+
OutputFormat ImageGenerateParamsOutputFormat `json:"output_format,omitzero"`
230230
// Format of the image response. Can be either a base64 string or a URL.
231231
//
232232
// Any of "base64", "url".
233-
ResponseFormat ImageNewParamsResponseFormat `json:"response_format,omitzero"`
233+
ResponseFormat ImageGenerateParamsResponseFormat `json:"response_format,omitzero"`
234234
paramObj
235235
}
236236

237-
func (r ImageNewParams) MarshalJSON() (data []byte, err error) {
238-
type shadow ImageNewParams
237+
func (r ImageGenerateParams) MarshalJSON() (data []byte, err error) {
238+
type shadow ImageGenerateParams
239239
return param.MarshalObject(r, (*shadow)(&r))
240240
}
241-
func (r *ImageNewParams) UnmarshalJSON(data []byte) error {
241+
func (r *ImageGenerateParams) UnmarshalJSON(data []byte) error {
242242
return apijson.UnmarshalRoot(data, r)
243243
}
244244

245245
// The model to use for image generation.
246246
//
247247
// [See all of Together AI's image models](https://docs.together.ai/docs/serverless-models#image-models)
248-
type ImageNewParamsModel string
248+
type ImageGenerateParamsModel string
249249

250250
const (
251-
ImageNewParamsModelBlackForestLabsFlux1SchnellFree ImageNewParamsModel = "black-forest-labs/FLUX.1-schnell-Free"
252-
ImageNewParamsModelBlackForestLabsFlux1Schnell ImageNewParamsModel = "black-forest-labs/FLUX.1-schnell"
253-
ImageNewParamsModelBlackForestLabsFlux1_1Pro ImageNewParamsModel = "black-forest-labs/FLUX.1.1-pro"
251+
ImageGenerateParamsModelBlackForestLabsFlux1SchnellFree ImageGenerateParamsModel = "black-forest-labs/FLUX.1-schnell-Free"
252+
ImageGenerateParamsModelBlackForestLabsFlux1Schnell ImageGenerateParamsModel = "black-forest-labs/FLUX.1-schnell"
253+
ImageGenerateParamsModelBlackForestLabsFlux1_1Pro ImageGenerateParamsModel = "black-forest-labs/FLUX.1.1-pro"
254254
)
255255

256256
// The properties Path, Scale are required.
257-
type ImageNewParamsImageLora struct {
257+
type ImageGenerateParamsImageLora struct {
258258
// The URL of the LoRA to apply (e.g.
259259
// https://huggingface.co/strangerzonehf/Flux-Midjourney-Mix2-LoRA).
260260
Path string `json:"path,required"`
@@ -263,27 +263,27 @@ type ImageNewParamsImageLora struct {
263263
paramObj
264264
}
265265

266-
func (r ImageNewParamsImageLora) MarshalJSON() (data []byte, err error) {
267-
type shadow ImageNewParamsImageLora
266+
func (r ImageGenerateParamsImageLora) MarshalJSON() (data []byte, err error) {
267+
type shadow ImageGenerateParamsImageLora
268268
return param.MarshalObject(r, (*shadow)(&r))
269269
}
270-
func (r *ImageNewParamsImageLora) UnmarshalJSON(data []byte) error {
270+
func (r *ImageGenerateParamsImageLora) UnmarshalJSON(data []byte) error {
271271
return apijson.UnmarshalRoot(data, r)
272272
}
273273

274274
// The format of the image response. Can be either be `jpeg` or `png`. Defaults to
275275
// `jpeg`.
276-
type ImageNewParamsOutputFormat string
276+
type ImageGenerateParamsOutputFormat string
277277

278278
const (
279-
ImageNewParamsOutputFormatJpeg ImageNewParamsOutputFormat = "jpeg"
280-
ImageNewParamsOutputFormatPng ImageNewParamsOutputFormat = "png"
279+
ImageGenerateParamsOutputFormatJpeg ImageGenerateParamsOutputFormat = "jpeg"
280+
ImageGenerateParamsOutputFormatPng ImageGenerateParamsOutputFormat = "png"
281281
)
282282

283283
// Format of the image response. Can be either a base64 string or a URL.
284-
type ImageNewParamsResponseFormat string
284+
type ImageGenerateParamsResponseFormat string
285285

286286
const (
287-
ImageNewParamsResponseFormatBase64 ImageNewParamsResponseFormat = "base64"
288-
ImageNewParamsResponseFormatURL ImageNewParamsResponseFormat = "url"
287+
ImageGenerateParamsResponseFormatBase64 ImageGenerateParamsResponseFormat = "base64"
288+
ImageGenerateParamsResponseFormatURL ImageGenerateParamsResponseFormat = "url"
289289
)

image_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/togethercomputer/together-go/option"
1414
)
1515

16-
func TestImageNewWithOptionalParams(t *testing.T) {
16+
func TestImageGenerateWithOptionalParams(t *testing.T) {
1717
baseURL := "http://localhost:4010"
1818
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
1919
baseURL = envURL
@@ -25,21 +25,21 @@ func TestImageNewWithOptionalParams(t *testing.T) {
2525
option.WithBaseURL(baseURL),
2626
option.WithAPIKey("My API Key"),
2727
)
28-
_, err := client.Images.New(context.TODO(), together.ImageNewParams{
29-
Model: together.ImageNewParamsModelBlackForestLabsFlux1SchnellFree,
28+
_, err := client.Images.Generate(context.TODO(), together.ImageGenerateParams{
29+
Model: together.ImageGenerateParamsModelBlackForestLabsFlux1SchnellFree,
3030
Prompt: "cat floating in space, cinematic",
3131
DisableSafetyChecker: together.Bool(true),
3232
GuidanceScale: together.Float(0),
3333
Height: together.Int(0),
34-
ImageLoras: []together.ImageNewParamsImageLora{{
34+
ImageLoras: []together.ImageGenerateParamsImageLora{{
3535
Path: "path",
3636
Scale: 0,
3737
}},
3838
ImageURL: together.String("image_url"),
3939
N: together.Int(0),
4040
NegativePrompt: together.String("negative_prompt"),
41-
OutputFormat: together.ImageNewParamsOutputFormatJpeg,
42-
ResponseFormat: together.ImageNewParamsResponseFormatBase64,
41+
OutputFormat: together.ImageGenerateParamsOutputFormatJpeg,
42+
ResponseFormat: together.ImageGenerateParamsResponseFormatBase64,
4343
Seed: together.Int(0),
4444
Steps: together.Int(0),
4545
Width: together.Int(0),

0 commit comments

Comments
 (0)