Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.4.0"
".": "3.5.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 123
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-104cced8f4c7436a76eea02e26307828166405ccfb296faffb008b72772c11a7.yml
openapi_spec_hash: fdc03ed84a65a31b80da909255e53924
config_hash: 03b48e9b8c7231a902403210dbd7dfa0
configured_endpoints: 122
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f59befea071ed7729cbb7bce219e7f837eccfdb57e01698514e6a0bd6052ff60.yml
openapi_spec_hash: 49da48619d37932b2e257c532078b2bb
config_hash: 1af83449a09a3b4f276444dbcdd3eb67
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 3.5.0 (2025-10-17)

Full Changelog: [v3.4.0...v3.5.0](https://github.com/openai/openai-go/compare/v3.4.0...v3.5.0)

### Features

* **api:** api update ([1aa78dd](https://github.com/openai/openai-go/commit/1aa78dda7aae7b72ce021250b5357ead8db36f46))

## 3.4.0 (2025-10-16)

Full Changelog: [v3.3.0...v3.4.0](https://github.com/openai/openai-go/compare/v3.3.0...v3.4.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/openai/openai-go/v2@v3.4.0'
go get -u 'github.com/openai/openai-go/v2@v3.5.0'
```

<!-- x-release-please-end -->
Expand Down
7 changes: 0 additions & 7 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,6 @@ Methods:
Response Types:

- <a href="https://pkg.go.dev/github.com/openai/openai-go/v3">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/v3#ChatKitWorkflow">ChatKitWorkflow</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go/v3">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/v3#FilePart">FilePart</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go/v3">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/v3#ImagePart">ImagePart</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go/v3">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/v3#BetaChatKitUploadFileResponseUnion">BetaChatKitUploadFileResponseUnion</a>

Methods:

- <code title="post /chatkit/files">client.Beta.ChatKit.<a href="https://pkg.go.dev/github.com/openai/openai-go/v3#BetaChatKitService.UploadFile">UploadFile</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/openai/openai-go/v3">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/v3#BetaChatKitUploadFileParams">BetaChatKitUploadFileParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go/v3">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/v3#BetaChatKitUploadFileResponseUnion">BetaChatKitUploadFileResponseUnion</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

### Sessions

Expand Down
180 changes: 0 additions & 180 deletions betachatkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
package openai

import (
"bytes"
"context"
"encoding/json"
"io"
"mime/multipart"
"net/http"
"slices"

"github.com/openai/openai-go/v3/internal/apiform"
"github.com/openai/openai-go/v3/internal/apijson"
"github.com/openai/openai-go/v3/internal/requestconfig"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/packages/respjson"
"github.com/openai/openai-go/v3/shared/constant"
)

// BetaChatKitService contains methods and other services that help with
Expand All @@ -42,15 +33,6 @@ func NewBetaChatKitService(opts ...option.RequestOption) (r BetaChatKitService)
return
}

// Upload a ChatKit file
func (r *BetaChatKitService) UploadFile(ctx context.Context, body BetaChatKitUploadFileParams, opts ...option.RequestOption) (res *BetaChatKitUploadFileResponseUnion, err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "chatkit_beta=v1")}, opts...)
path := "chatkit/files"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}

// Workflow metadata and state returned for the session.
type ChatKitWorkflow struct {
// Identifier of the workflow backing the session.
Expand Down Expand Up @@ -141,165 +123,3 @@ func (r ChatKitWorkflowTracing) RawJSON() string { return r.JSON.raw }
func (r *ChatKitWorkflowTracing) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// Metadata for a non-image file uploaded through ChatKit.
type FilePart struct {
// Unique identifier for the uploaded file.
ID string `json:"id,required"`
// MIME type reported for the uploaded file. Defaults to null when unknown.
MimeType string `json:"mime_type,required"`
// Original filename supplied by the uploader. Defaults to null when unnamed.
Name string `json:"name,required"`
// Type discriminator that is always `file`.
Type constant.File `json:"type,required"`
// Signed URL for downloading the uploaded file. Defaults to null when no download
// link is available.
UploadURL string `json:"upload_url,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
MimeType respjson.Field
Name respjson.Field
Type respjson.Field
UploadURL respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r FilePart) RawJSON() string { return r.JSON.raw }
func (r *FilePart) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// Metadata for an image uploaded through ChatKit.
type ImagePart struct {
// Unique identifier for the uploaded image.
ID string `json:"id,required"`
// MIME type of the uploaded image.
MimeType string `json:"mime_type,required"`
// Original filename for the uploaded image. Defaults to null when unnamed.
Name string `json:"name,required"`
// Preview URL that can be rendered inline for the image.
PreviewURL string `json:"preview_url,required"`
// Type discriminator that is always `image`.
Type constant.Image `json:"type,required"`
// Signed URL for downloading the uploaded image. Defaults to null when no download
// link is available.
UploadURL string `json:"upload_url,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
MimeType respjson.Field
Name respjson.Field
PreviewURL respjson.Field
Type respjson.Field
UploadURL respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}

// Returns the unmodified JSON received from the API
func (r ImagePart) RawJSON() string { return r.JSON.raw }
func (r *ImagePart) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

// BetaChatKitUploadFileResponseUnion contains all possible properties and values
// from [FilePart], [ImagePart].
//
// Use the [BetaChatKitUploadFileResponseUnion.AsAny] method to switch on the
// variant.
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
type BetaChatKitUploadFileResponseUnion struct {
ID string `json:"id"`
MimeType string `json:"mime_type"`
Name string `json:"name"`
// Any of "file", "image".
Type string `json:"type"`
UploadURL string `json:"upload_url"`
// This field is from variant [ImagePart].
PreviewURL string `json:"preview_url"`
JSON struct {
ID respjson.Field
MimeType respjson.Field
Name respjson.Field
Type respjson.Field
UploadURL respjson.Field
PreviewURL respjson.Field
raw string
} `json:"-"`
}

// anyBetaChatKitUploadFileResponse is implemented by each variant of
// [BetaChatKitUploadFileResponseUnion] to add type safety for the return type of
// [BetaChatKitUploadFileResponseUnion.AsAny]
type anyBetaChatKitUploadFileResponse interface {
implBetaChatKitUploadFileResponseUnion()
}

func (FilePart) implBetaChatKitUploadFileResponseUnion() {}
func (ImagePart) implBetaChatKitUploadFileResponseUnion() {}

// Use the following switch statement to find the correct variant
//
// switch variant := BetaChatKitUploadFileResponseUnion.AsAny().(type) {
// case openai.FilePart:
// case openai.ImagePart:
// default:
// fmt.Errorf("no variant present")
// }
func (u BetaChatKitUploadFileResponseUnion) AsAny() anyBetaChatKitUploadFileResponse {
switch u.Type {
case "file":
return u.AsFile()
case "image":
return u.AsImage()
}
return nil
}

func (u BetaChatKitUploadFileResponseUnion) AsFile() (v FilePart) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}

func (u BetaChatKitUploadFileResponseUnion) AsImage() (v ImagePart) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}

// Returns the unmodified JSON received from the API
func (u BetaChatKitUploadFileResponseUnion) RawJSON() string { return u.JSON.raw }

func (r *BetaChatKitUploadFileResponseUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type BetaChatKitUploadFileParams struct {
// Binary file contents to store with the ChatKit session. Supports PDFs and PNG,
// JPG, JPEG, GIF, or WEBP images.
File io.Reader `json:"file,omitzero,required" format:"binary"`
paramObj
}

func (r BetaChatKitUploadFileParams) MarshalMultipart() (data []byte, contentType string, err error) {
buf := bytes.NewBuffer(nil)
writer := multipart.NewWriter(buf)
err = apiform.MarshalRoot(r, writer)
if err == nil {
err = apiform.WriteExtras(writer, r.ExtraFields())
}
if err != nil {
writer.Close()
return nil, "", err
}
err = writer.Close()
if err != nil {
return nil, "", err
}
return buf.Bytes(), writer.FormDataContentType(), nil
}
40 changes: 0 additions & 40 deletions betachatkit_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "3.4.0" // x-release-please-version
const PackageVersion = "3.5.0" // x-release-please-version
1 change: 0 additions & 1 deletion scripts/detect-breaking-changes
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ TEST_PATHS=(
vectorstorefile_test.go
vectorstorefilebatch_test.go
webhooks/webhook_test.go
betachatkit_test.go
betachatkitsession_test.go
betachatkitthread_test.go
betaassistant_test.go
Expand Down
Loading