diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml
new file mode 100644
index 00000000..069decb9
--- /dev/null
+++ b/.github/workflows/create-releases.yml
@@ -0,0 +1,29 @@
+name: Create releases
+on:
+ schedule:
+ - cron: '0 5 * * *' # every day at 5am UTC
+ push:
+ branches:
+ - main
+
+jobs:
+ release:
+ name: release
+ if: github.ref == 'refs/heads/main' && github.repository == 'openai/openai-go'
+ runs-on: ubuntu-latest
+ environment: publish
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: stainless-api/trigger-release-please@v1
+ id: release
+ with:
+ repo: ${{ github.event.repository.full_name }}
+ stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
+
+ - name: Generate godocs
+ if: ${{ steps.release.outputs.releases_created }}
+ run: |
+ version=$(jq -r '. | to_entries[0] | .value' .release-please-manifest.json)
+ curl -X POST https://pkg.go.dev/fetch/github.com/openai/openai-go@v${version}
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 2601677b..d0ab6645 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "1.1.0"
+ ".": "1.2.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 3735f4d2..c6d6f636 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 97
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fc64d7c2c8f51f750813375356c3f3fdfc7fc1b1b34f19c20a5410279d445d37.yml
-openapi_spec_hash: 618285fc70199ee32b9ebe4bf72f7e4c
-config_hash: c497f6b750cc89c0bf2eefc0bc839c70
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d4bcffecf0cdadf746faa6708ed1ec81fac451f9b857deabbab26f0a343b9314.yml
+openapi_spec_hash: 7c54a18b4381248bda7cc34c52142615
+config_hash: d23f847b9ebb3f427d0f198035bd3e9f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 72c6f686..59f19c26 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## 1.2.0 (2025-05-29)
+
+Full Changelog: [v1.1.0...v1.2.0](https://github.com/openai/openai-go/compare/v1.1.0...v1.2.0)
+
+### Features
+
+* **api:** Config update for pakrym-stream-param ([84d59d5](https://github.com/openai/openai-go/commit/84d59d5cbc7521ddcc04435317903fd4ec3d17f6))
+
+
+### Bug Fixes
+
+* **client:** return binary content from `get /containers/{container_id}/files/{file_id}/content` ([f8c8de1](https://github.com/openai/openai-go/commit/f8c8de18b720b224267d54da53d7d919ed0fdff3))
+
+
+### Chores
+
+* deprecate Assistants API ([027470e](https://github.com/openai/openai-go/commit/027470e066ea6bbca1aeeb4fb9a8a3430babb84c))
+* **internal:** fix release workflows ([fd46533](https://github.com/openai/openai-go/commit/fd4653316312755ccab7435fca9fb0a2d8bf8fbb))
+
## 1.1.0 (2025-05-22)
Full Changelog: [v1.0.0...v1.1.0](https://github.com/openai/openai-go/compare/v1.0.0...v1.1.0)
diff --git a/README.md b/README.md
index f9a53abb..18256b9c 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ Or to pin the version:
```sh
-go get -u 'github.com/openai/openai-go@v1.1.0'
+go get -u 'github.com/openai/openai-go@v1.2.0'
```
diff --git a/api.md b/api.md
index 01ad7981..d8851a03 100644
--- a/api.md
+++ b/api.md
@@ -747,4 +747,4 @@ Methods:
Methods:
-- client.Containers.Files.Content.Get(ctx context.Context, containerID string, fileID string) error
+- client.Containers.Files.Content.Get(ctx context.Context, containerID string, fileID string) (http.Response, error)
diff --git a/beta.go b/beta.go
index c426f355..79fb960a 100644
--- a/beta.go
+++ b/beta.go
@@ -15,7 +15,8 @@ import (
type BetaService struct {
Options []option.RequestOption
Assistants BetaAssistantService
- Threads BetaThreadService
+ // Deprecated: The Assistants API is deprecated in favor of the Responses API
+ Threads BetaThreadService
}
// NewBetaService generates a new service that applies the given options to each
diff --git a/betathread.go b/betathread.go
index 783c7e96..df8da489 100644
--- a/betathread.go
+++ b/betathread.go
@@ -25,9 +25,13 @@ import (
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaThreadService] method instead.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
type BetaThreadService struct {
- Options []option.RequestOption
- Runs BetaThreadRunService
+ Options []option.RequestOption
+ // Deprecated: The Assistants API is deprecated in favor of the Responses API
+ Runs BetaThreadRunService
+ // Deprecated: The Assistants API is deprecated in favor of the Responses API
Messages BetaThreadMessageService
}
@@ -43,6 +47,8 @@ func NewBetaThreadService(opts ...option.RequestOption) (r BetaThreadService) {
}
// Create a thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -52,6 +58,8 @@ func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, o
}
// Retrieves a thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -65,6 +73,8 @@ func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...op
}
// Modifies a thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) Update(ctx context.Context, threadID string, body BetaThreadUpdateParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -78,6 +88,8 @@ func (r *BetaThreadService) Update(ctx context.Context, threadID string, body Be
}
// Delete a thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ...option.RequestOption) (res *ThreadDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -91,6 +103,8 @@ func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ..
}
// Create a thread and run it in one request.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) NewAndRun(ctx context.Context, body BetaThreadNewAndRunParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -100,6 +114,8 @@ func (r *BetaThreadService) NewAndRun(ctx context.Context, body BetaThreadNewAnd
}
// Create a thread and run it in one request.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadService) NewAndRunStreaming(ctx context.Context, body BetaThreadNewAndRunParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEventUnion]) {
var (
raw *http.Response
diff --git a/betathreadmessage.go b/betathreadmessage.go
index 69d2fe96..f02b3936 100644
--- a/betathreadmessage.go
+++ b/betathreadmessage.go
@@ -27,6 +27,8 @@ import (
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaThreadMessageService] method instead.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
type BetaThreadMessageService struct {
Options []option.RequestOption
}
@@ -41,6 +43,8 @@ func NewBetaThreadMessageService(opts ...option.RequestOption) (r BetaThreadMess
}
// Create a message.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, body BetaThreadMessageNewParams, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -54,6 +58,8 @@ func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, bod
}
// Retrieve a message.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -71,6 +77,8 @@ func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, mes
}
// Modifies a message.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string, messageID string, body BetaThreadMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -88,6 +96,8 @@ func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string,
}
// Returns a list of messages for a given thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) List(ctx context.Context, threadID string, query BetaThreadMessageListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Message], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
@@ -110,11 +120,15 @@ func (r *BetaThreadMessageService) List(ctx context.Context, threadID string, qu
}
// Returns a list of messages for a given thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) ListAutoPaging(ctx context.Context, threadID string, query BetaThreadMessageListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[Message] {
return pagination.NewCursorPageAutoPager(r.List(ctx, threadID, query, opts...))
}
// Deletes a message.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *MessageDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
diff --git a/betathreadrun.go b/betathreadrun.go
index 18419734..32c235a5 100644
--- a/betathreadrun.go
+++ b/betathreadrun.go
@@ -27,9 +27,12 @@ import (
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaThreadRunService] method instead.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
type BetaThreadRunService struct {
Options []option.RequestOption
- Steps BetaThreadRunStepService
+ // Deprecated: The Assistants API is deprecated in favor of the Responses API
+ Steps BetaThreadRunStepService
}
// NewBetaThreadRunService generates a new service that applies the given options
@@ -43,6 +46,8 @@ func NewBetaThreadRunService(opts ...option.RequestOption) (r BetaThreadRunServi
}
// Create a run.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) New(ctx context.Context, threadID string, params BetaThreadRunNewParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -56,6 +61,8 @@ func (r *BetaThreadRunService) New(ctx context.Context, threadID string, params
}
// Create a run.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string, params BetaThreadRunNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEventUnion]) {
var (
raw *http.Response
@@ -73,6 +80,8 @@ func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string
}
// Retrieves a run.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -90,6 +99,8 @@ func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID s
}
// Modifies a run.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runID string, body BetaThreadRunUpdateParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -107,6 +118,8 @@ func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runI
}
// Returns a list of runs belonging to a thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) List(ctx context.Context, threadID string, query BetaThreadRunListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Run], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
@@ -129,11 +142,15 @@ func (r *BetaThreadRunService) List(ctx context.Context, threadID string, query
}
// Returns a list of runs belonging to a thread.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) ListAutoPaging(ctx context.Context, threadID string, query BetaThreadRunListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[Run] {
return pagination.NewCursorPageAutoPager(r.List(ctx, threadID, query, opts...))
}
// Cancels a run that is `in_progress`.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -154,6 +171,8 @@ func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runI
// `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
// tool calls once they're all completed. All outputs must be submitted in a single
// request.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -174,6 +193,8 @@ func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID s
// `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
// tool calls once they're all completed. All outputs must be submitted in a single
// request.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunService) SubmitToolOutputsStreaming(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEventUnion]) {
var (
raw *http.Response
diff --git a/betathreadrunstep.go b/betathreadrunstep.go
index e3466e1b..1ae783e5 100644
--- a/betathreadrunstep.go
+++ b/betathreadrunstep.go
@@ -27,6 +27,8 @@ import (
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaThreadRunStepService] method instead.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
type BetaThreadRunStepService struct {
Options []option.RequestOption
}
@@ -41,6 +43,8 @@ func NewBetaThreadRunStepService(opts ...option.RequestOption) (r BetaThreadRunS
}
// Retrieves a run step.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, query BetaThreadRunStepGetParams, opts ...option.RequestOption) (res *RunStep, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
@@ -62,6 +66,8 @@ func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, run
}
// Returns a list of run steps belonging to a run.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunStepService) List(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) (res *pagination.CursorPage[RunStep], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
@@ -88,6 +94,8 @@ func (r *BetaThreadRunStepService) List(ctx context.Context, threadID string, ru
}
// Returns a list of run steps belonging to a run.
+//
+// Deprecated: The Assistants API is deprecated in favor of the Responses API
func (r *BetaThreadRunStepService) ListAutoPaging(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[RunStep] {
return pagination.NewCursorPageAutoPager(r.List(ctx, threadID, runID, query, opts...))
}
diff --git a/containerfilecontent.go b/containerfilecontent.go
index 15805389..0fb0fa9f 100644
--- a/containerfilecontent.go
+++ b/containerfilecontent.go
@@ -32,9 +32,9 @@ func NewContainerFileContentService(opts ...option.RequestOption) (r ContainerFi
}
// Retrieve Container File Content
-func (r *ContainerFileContentService) Get(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (err error) {
+func (r *ContainerFileContentService) Get(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (res *http.Response, err error) {
opts = append(r.Options[:], opts...)
- opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
+ opts = append([]option.RequestOption{option.WithHeader("Accept", "application/binary")}, opts...)
if containerID == "" {
err = errors.New("missing required container_id parameter")
return
@@ -44,6 +44,6 @@ func (r *ContainerFileContentService) Get(ctx context.Context, containerID strin
return
}
path := fmt.Sprintf("containers/%s/files/%s/content", containerID, fileID)
- err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, nil, opts...)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
diff --git a/containerfilecontent_test.go b/containerfilecontent_test.go
index 3f43bceb..10a7bc61 100644
--- a/containerfilecontent_test.go
+++ b/containerfilecontent_test.go
@@ -3,29 +3,30 @@
package openai_test
import (
+ "bytes"
"context"
"errors"
- "os"
+ "io"
+ "net/http"
+ "net/http/httptest"
"testing"
"github.com/openai/openai-go"
- "github.com/openai/openai-go/internal/testutil"
"github.com/openai/openai-go/option"
)
func TestContainerFileContentGet(t *testing.T) {
- baseURL := "http://localhost:4010"
- if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
- baseURL = envURL
- }
- if !testutil.CheckTestServer(t, baseURL) {
- return
- }
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(200)
+ w.Write([]byte("abc"))
+ }))
+ defer server.Close()
+ baseURL := server.URL
client := openai.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
)
- err := client.Containers.Files.Content.Get(
+ resp, err := client.Containers.Files.Content.Get(
context.TODO(),
"container_id",
"file_id",
@@ -37,4 +38,17 @@ func TestContainerFileContentGet(t *testing.T) {
}
t.Fatalf("err should be nil: %s", err.Error())
}
+ defer resp.Body.Close()
+
+ b, err := io.ReadAll(resp.Body)
+ if err != nil {
+ var apierr *openai.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+ if !bytes.Equal(b, []byte("abc")) {
+ t.Fatalf("return value not %s: %s", "abc", b)
+ }
}
diff --git a/internal/version.go b/internal/version.go
index e9357c4e..497a1a04 100644
--- a/internal/version.go
+++ b/internal/version.go
@@ -2,4 +2,4 @@
package internal
-const PackageVersion = "1.1.0" // x-release-please-version
+const PackageVersion = "1.2.0" // x-release-please-version
diff --git a/responses/response.go b/responses/response.go
index 92c1ea62..521c396a 100644
--- a/responses/response.go
+++ b/responses/response.go
@@ -97,6 +97,23 @@ func (r *ResponseService) Get(ctx context.Context, responseID string, query Resp
return
}
+// Retrieves a model response with the given ID.
+func (r *ResponseService) GetStreaming(ctx context.Context, responseID string, query ResponseGetParams, opts ...option.RequestOption) (stream *ssestream.Stream[ResponseStreamEventUnion]) {
+ var (
+ raw *http.Response
+ err error
+ )
+ opts = append(r.Options[:], opts...)
+ opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...)
+ if responseID == "" {
+ err = errors.New("missing required response_id parameter")
+ return
+ }
+ path := fmt.Sprintf("responses/%s", responseID)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &raw, opts...)
+ return ssestream.NewStream[ResponseStreamEventUnion](ssestream.NewDecoder(raw), err)
+}
+
// Deletes a model response with the given ID.
func (r *ResponseService) Delete(ctx context.Context, responseID string, opts ...option.RequestOption) (err error) {
opts = append(r.Options[:], opts...)
@@ -2593,12 +2610,15 @@ type ResponseContentPartAddedEventPartUnion struct {
Text string `json:"text"`
// Any of "output_text", "refusal".
Type string `json:"type"`
+ // This field is from variant [ResponseOutputText].
+ Logprobs []ResponseOutputTextLogprob `json:"logprobs"`
// This field is from variant [ResponseOutputRefusal].
Refusal string `json:"refusal"`
JSON struct {
Annotations respjson.Field
Text respjson.Field
Type respjson.Field
+ Logprobs respjson.Field
Refusal respjson.Field
raw string
} `json:"-"`
@@ -2696,12 +2716,15 @@ type ResponseContentPartDoneEventPartUnion struct {
Text string `json:"text"`
// Any of "output_text", "refusal".
Type string `json:"type"`
+ // This field is from variant [ResponseOutputText].
+ Logprobs []ResponseOutputTextLogprob `json:"logprobs"`
// This field is from variant [ResponseOutputRefusal].
Refusal string `json:"refusal"`
JSON struct {
Annotations respjson.Field
Text respjson.Field
Type respjson.Field
+ Logprobs respjson.Field
Refusal respjson.Field
raw string
} `json:"-"`
@@ -7087,12 +7110,15 @@ type ResponseOutputMessageContentUnion struct {
Text string `json:"text"`
// Any of "output_text", "refusal".
Type string `json:"type"`
+ // This field is from variant [ResponseOutputText].
+ Logprobs []ResponseOutputTextLogprob `json:"logprobs"`
// This field is from variant [ResponseOutputRefusal].
Refusal string `json:"refusal"`
JSON struct {
Annotations respjson.Field
Text respjson.Field
Type respjson.Field
+ Logprobs respjson.Field
Refusal respjson.Field
raw string
} `json:"-"`
@@ -7226,6 +7252,14 @@ func (u ResponseOutputMessageContentUnionParam) GetText() *string {
return nil
}
+// Returns a pointer to the underlying variant's property, if present.
+func (u ResponseOutputMessageContentUnionParam) GetLogprobs() []ResponseOutputTextLogprobParam {
+ if vt := u.OfOutputText; vt != nil {
+ return vt.Logprobs
+ }
+ return nil
+}
+
// Returns a pointer to the underlying variant's property, if present.
func (u ResponseOutputMessageContentUnionParam) GetRefusal() *string {
if vt := u.OfRefusal; vt != nil {
@@ -7310,12 +7344,14 @@ type ResponseOutputText struct {
// The text output from the model.
Text string `json:"text,required"`
// The type of the output text. Always `output_text`.
- Type constant.OutputText `json:"type,required"`
+ Type constant.OutputText `json:"type,required"`
+ Logprobs []ResponseOutputTextLogprob `json:"logprobs"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Annotations respjson.Field
Text respjson.Field
Type respjson.Field
+ Logprobs respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -7502,6 +7538,50 @@ func (r *ResponseOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error
return apijson.UnmarshalRoot(data, r)
}
+// The log probability of a token.
+type ResponseOutputTextLogprob struct {
+ Token string `json:"token,required"`
+ Bytes []int64 `json:"bytes,required"`
+ Logprob float64 `json:"logprob,required"`
+ TopLogprobs []ResponseOutputTextLogprobTopLogprob `json:"top_logprobs,required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Token respjson.Field
+ Bytes respjson.Field
+ Logprob respjson.Field
+ TopLogprobs respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseOutputTextLogprob) RawJSON() string { return r.JSON.raw }
+func (r *ResponseOutputTextLogprob) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The top log probability of a token.
+type ResponseOutputTextLogprobTopLogprob struct {
+ Token string `json:"token,required"`
+ Bytes []int64 `json:"bytes,required"`
+ Logprob float64 `json:"logprob,required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Token respjson.Field
+ Bytes respjson.Field
+ Logprob respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseOutputTextLogprobTopLogprob) RawJSON() string { return r.JSON.raw }
+func (r *ResponseOutputTextLogprobTopLogprob) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// A text output from the model.
//
// The properties Annotations, Text, Type are required.
@@ -7509,7 +7589,8 @@ type ResponseOutputTextParam struct {
// The annotations of the text output.
Annotations []ResponseOutputTextAnnotationUnionParam `json:"annotations,omitzero,required"`
// The text output from the model.
- Text string `json:"text,required"`
+ Text string `json:"text,required"`
+ Logprobs []ResponseOutputTextLogprobParam `json:"logprobs,omitzero"`
// The type of the output text. Always `output_text`.
//
// This field can be elided, and will marshal its zero value as "output_text".
@@ -7699,6 +7780,43 @@ func (r *ResponseOutputTextAnnotationFilePathParam) UnmarshalJSON(data []byte) e
return apijson.UnmarshalRoot(data, r)
}
+// The log probability of a token.
+//
+// The properties Token, Bytes, Logprob, TopLogprobs are required.
+type ResponseOutputTextLogprobParam struct {
+ Token string `json:"token,required"`
+ Bytes []int64 `json:"bytes,omitzero,required"`
+ Logprob float64 `json:"logprob,required"`
+ TopLogprobs []ResponseOutputTextLogprobTopLogprobParam `json:"top_logprobs,omitzero,required"`
+ paramObj
+}
+
+func (r ResponseOutputTextLogprobParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseOutputTextLogprobParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseOutputTextLogprobParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The top log probability of a token.
+//
+// The properties Token, Bytes, Logprob are required.
+type ResponseOutputTextLogprobTopLogprobParam struct {
+ Token string `json:"token,required"`
+ Bytes []int64 `json:"bytes,omitzero,required"`
+ Logprob float64 `json:"logprob,required"`
+ paramObj
+}
+
+func (r ResponseOutputTextLogprobTopLogprobParam) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseOutputTextLogprobTopLogprobParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseOutputTextLogprobTopLogprobParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Emitted when an annotation is added to output text content.
type ResponseOutputTextAnnotationAddedEvent struct {
// The annotation object being added. (See annotation schema for details.)
@@ -8948,11 +9066,15 @@ type ResponseStreamEventUnionPart struct {
Type string `json:"type"`
// This field is from variant [ResponseContentPartAddedEventPartUnion],
// [ResponseContentPartDoneEventPartUnion].
+ Logprobs []ResponseOutputTextLogprob `json:"logprobs"`
+ // This field is from variant [ResponseContentPartAddedEventPartUnion],
+ // [ResponseContentPartDoneEventPartUnion].
Refusal string `json:"refusal"`
JSON struct {
Annotations respjson.Field
Text respjson.Field
Type respjson.Field
+ Logprobs respjson.Field
Refusal respjson.Field
raw string
} `json:"-"`
@@ -11076,6 +11198,8 @@ const (
)
type ResponseGetParams struct {
+ // The sequence number of the event after which to start streaming.
+ StartingAfter param.Opt[int64] `query:"starting_after,omitzero" json:"-"`
// Additional fields to include in the response. See the `include` parameter for
// Response creation above for more information.
Include []ResponseIncludable `query:"include,omitzero" json:"-"`
diff --git a/responses/response_test.go b/responses/response_test.go
index 311dc74f..c92ca443 100644
--- a/responses/response_test.go
+++ b/responses/response_test.go
@@ -96,7 +96,8 @@ func TestResponseGetWithOptionalParams(t *testing.T) {
context.TODO(),
"resp_677efb5139a88190b512bc3fef8e535d",
responses.ResponseGetParams{
- Include: []responses.ResponseIncludable{responses.ResponseIncludableFileSearchCallResults},
+ Include: []responses.ResponseIncludable{responses.ResponseIncludableFileSearchCallResults},
+ StartingAfter: openai.Int(0),
},
)
if err != nil {