openai

package module
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 26 Imported by: 310

README

OpenAI Go API Library

Go Reference

The OpenAI Go library provides convenient access to the OpenAI REST API from applications written in Go.

[!WARNING] The latest version of this package uses a new design with significant breaking changes. Please refer to the migration guide for more information on how to update your code.

Installation

import (
	"github.com/openai/openai-go" // imported as openai
)

Or to pin the version:

go get -u 'github.com/openai/[email protected]'

Requirements

This library requires Go 1.18+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/openai/openai-go"
	"github.com/openai/openai-go/option"
	"github.com/openai/openai-go/shared"
)

func main() {
	client := openai.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("OPENAI_API_KEY")
	)
	chatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
		Messages: []openai.ChatCompletionMessageParamUnion{
			openai.UserMessage("Say this is a test"),
		},
		Model: openai.ChatModelGPT4o,
	})
	if err != nil {
		panic(err.Error())
	}
	println(chatCompletion.Choices[0].Message.Content)
}

Conversations
param := openai.ChatCompletionNewParams{
	Messages: []openai.ChatCompletionMessageParamUnion{
		openai.UserMessage("What kind of houseplant is easy to take care of?"),
	},
	Seed:     openai.Int(1),
	Model:    openai.ChatModelGPT4o,
}

completion, err := client.Chat.Completions.New(ctx, param)

param.Messages = append(param.Messages, completion.Choices[0].Message.ToParam())
param.Messages = append(param.Messages, openai.UserMessage("How big are those?"))

// continue the conversation
completion, err = client.Chat.Completions.New(ctx, param)
Streaming responses
question := "Write an epic"

stream := client.Chat.Completions.NewStreaming(ctx, openai.ChatCompletionNewParams{
	Messages: []openai.ChatCompletionMessageParamUnion{
		openai.UserMessage(question),
	},
	Seed:  openai.Int(0),
	Model: openai.ChatModelGPT4o,
})

// optionally, an accumulator helper can be used
acc := openai.ChatCompletionAccumulator{}

for stream.Next() {
	chunk := stream.Current()
	acc.AddChunk(chunk)

	if content, ok := acc.JustFinishedContent(); ok {
		println("Content stream finished:", content)
	}

	// if using tool calls
	if tool, ok := acc.JustFinishedToolCall(); ok {
		println("Tool call stream finished:", tool.Index, tool.Name, tool.Arguments)
	}

	if refusal, ok := acc.JustFinishedRefusal(); ok {
		println("Refusal stream finished:", refusal)
	}

	// it's best to use chunks after handling JustFinished events
	if len(chunk.Choices) > 0 {
		println(chunk.Choices[0].Delta.Content)
	}
}

if stream.Err() != nil {
	panic(stream.Err())
}

// After the stream is finished, acc can be used like a ChatCompletion
_ = acc.Choices[0].Message.Content

See the full streaming and accumulation example

Tool calling
import (
	"encoding/json"
	// ...
)

// ...

question := "What is the weather in New York City?"

params := openai.ChatCompletionNewParams{
	Messages: []openai.ChatCompletionMessageParamUnion{
		openai.UserMessage(question),
	},
	Tools: []openai.ChatCompletionToolParam{
		{
			Function: openai.FunctionDefinitionParam{
				Name:        "get_weather",
				Description: openai.String("Get weather at the given location"),
				Parameters: openai.FunctionParameters{
					"type": "object",
					"properties": map[string]interface{}{
						"location": map[string]string{
							"type": "string",
						},
					},
					"required": []string{"location"},
				},
			},
		},
	},
	Model: openai.ChatModelGPT4o,
}

// If there is a was a function call, continue the conversation
params.Messages = append(params.Messages, completion.Choices[0].Message.ToParam())
for _, toolCall := range toolCalls {
	if toolCall.Function.Name == "get_weather" {
		// Extract the location from the function call arguments
		var args map[string]interface{}
		err := json.Unmarshal([]byte(toolCall.Function.Arguments), &args)
		if err != nil {
			panic(err)
		}
		location := args["location"].(string)

		// Simulate getting weather data
		weatherData := getWeather(location)

		// Print the weather data
		fmt.Printf("Weather in %s: %s\n", location, weatherData)

		params.Messages = append(params.Messages, openai.ToolMessage(weatherData, toolCall.ID))
	}
}

// ... continue the conversation with the information provided by the tool

See the full tool calling example

Structured outputs
import (
	"encoding/json"
	"github.com/invopop/jsonschema"
	// ...
)

// A struct that will be converted to a Structured Outputs response schema
type HistoricalComputer struct {
	Origin       Origin   `json:"origin" jsonschema_description:"The origin of the computer"`
	Name         string   `json:"full_name" jsonschema_description:"The name of the device model"`
	Legacy       string   `json:"legacy" jsonschema:"enum=positive,enum=neutral,enum=negative" jsonschema_description:"Its influence on the field of computing"`
	NotableFacts []string `json:"notable_facts" jsonschema_description:"A few key facts about the computer"`
}

type Origin struct {
	YearBuilt    int64  `json:"year_of_construction" jsonschema_description:"The year it was made"`
	Organization string `json:"organization" jsonschema_description:"The organization that was in charge of its development"`
}

func GenerateSchema[T any]() interface{} {
	// Structured Outputs uses a subset of JSON schema
	// These flags are necessary to comply with the subset
	reflector := jsonschema.Reflector{
		AllowAdditionalProperties: false,
		DoNotReference:            true,
	}
	var v T
	schema := reflector.Reflect(v)
	return schema
}

// Generate the JSON schema at initialization time
var HistoricalComputerResponseSchema = GenerateSchema[HistoricalComputer]()

func main() {

	// ...

	question := "What computer ran the first neural network?"

	schemaParam := openai.ResponseFormatJSONSchemaJSONSchemaParam{
		Name:        "historical_computer",
		Description: openai.String("Notable information about a computer"),
		Schema:      HistoricalComputerResponseSchema,
		Strict:      openai.Bool(true),
	}

	chat, _ := client.Chat.Completions.New(ctx, openai.ChatCompletionNewParams{
		// ...
		ResponseFormat: openai.ChatCompletionNewParamsResponseFormatUnion{
			OfJSONSchema: &openai.ResponseFormatJSONSchemaParam{
				JSONSchema: schemaParam,
			},
		},
		// only certain models can perform structured outputs
		Model: openai.ChatModelGPT4o2024_08_06,
	})

	// extract into a well-typed struct
	var historicalComputer HistoricalComputer
	_ = json.Unmarshal([]byte(chat.Choices[0].Message.Content), &historicalComputer)

	historicalComputer.Name
	historicalComputer.Origin.YearBuilt
	historicalComputer.Origin.Organization
	for i, fact := range historicalComputer.NotableFacts {
		// ...
	}
}

See the full structured outputs example

Request fields

The openai library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, openai.String(string), openai.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := openai.ExampleParams{
	ID:   "id_xxx",             // required property
	Name: openai.String("..."), // optional property

	Point: openai.Point{
		X: 0,             // required field will serialize as 0
		Y: openai.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: openai.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[openai.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of it's variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := openai.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Chat.Completions.New(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

iter := client.FineTuning.Jobs.ListAutoPaging(context.TODO(), openai.FineTuningJobListParams{
	Limit: openai.Int(20),
})
// Automatically fetches more pages as needed.
for iter.Next() {
	fineTuningJob := iter.Current()
	fmt.Printf("%+v\n", fineTuningJob)
}
if err := iter.Err(); err != nil {
	panic(err.Error())
}

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

page, err := client.FineTuning.Jobs.List(context.TODO(), openai.FineTuningJobListParams{
	Limit: openai.Int(20),
})
for page != nil {
	for _, job := range page.Data {
		fmt.Printf("%+v\n", job)
	}
	page, err = page.GetNextPage()
}
if err != nil {
	panic(err.Error())
}
Errors

When the API returns a non-success status code, we return an error with type *openai.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.FineTuning.Jobs.New(context.TODO(), openai.FineTuningJobNewParams{
	Model:        openai.FineTuningJobNewParamsModelBabbage002,
	TrainingFile: "file-abc123",
})
if err != nil {
	var apierr *openai.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/fine_tuning/jobs": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Chat.Completions.New(
	ctx,
	openai.ChatCompletionNewParams{
		Messages: []openai.ChatCompletionMessageParamUnion{{
			OfUser: &openai.ChatCompletionUserMessageParam{
				Content: openai.ChatCompletionUserMessageParamContentUnion{
					OfString: openai.String("How can I list all files in a directory using Python?"),
				},
			},
		}},
		Model: shared.ChatModelGPT4_1,
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper openai.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

// A file from the file system
file, err := os.Open("input.jsonl")
openai.FileNewParams{
	File:    file,
	Purpose: openai.FilePurposeFineTune,
}

// A file from a string
openai.FileNewParams{
	File:    strings.NewReader("my file contents"),
	Purpose: openai.FilePurposeFineTune,
}

// With a custom filename and contentType
openai.FileNewParams{
	File:    openai.File(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),
	Purpose: openai.FilePurposeFineTune,
}
Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := openai.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Chat.Completions.New(
	context.TODO(),
	openai.ChatCompletionNewParams{
		Messages: []openai.ChatCompletionMessageParamUnion{{
			OfUser: &openai.ChatCompletionUserMessageParam{
				Content: openai.ChatCompletionUserMessageParamContentUnion{
					OfString: openai.String("How can I get the name of the current day in JavaScript?"),
				},
			},
		}},
		Model: shared.ChatModelGPT4_1,
	},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
chatCompletion, err := client.Chat.Completions.New(
	context.TODO(),
	openai.ChatCompletionNewParams{
		Messages: []openai.ChatCompletionMessageParamUnion{{
			OfUser: &openai.ChatCompletionUserMessageParam{
				Content: openai.ChatCompletionUserMessageParamContentUnion{
					OfString: openai.String("Say this is a test"),
				},
			},
		}},
		Model: shared.ChatModelGPT4_1,
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", chatCompletion)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: openai.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := openai.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Microsoft Azure OpenAI

To use this library with [Azure OpenAI]https://learn.microsoft.com/azure/ai-services/openai/overview), use the option.RequestOption functions in the azure package.

package main

import (
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/openai/openai-go"
	"github.com/openai/openai-go/azure"
)

func main() {
	const azureOpenAIEndpoint = "https://<azure-openai-resource>.openai.azure.com"

	// The latest API versions, including previews, can be found here:
	// ttps://learn.microsoft.com/en-us/azure/ai-services/openai/reference#rest-api-versionng
	const azureOpenAIAPIVersion = "2024-06-01"

	tokenCredential, err := azidentity.NewDefaultAzureCredential(nil)

	if err != nil {
		fmt.Printf("Failed to create the DefaultAzureCredential: %s", err)
		os.Exit(1)
	}

	client := openai.NewClient(
		azure.WithEndpoint(azureOpenAIEndpoint, azureOpenAIAPIVersion),

		// Choose between authenticating using a TokenCredential or an API Key
		azure.WithTokenCredential(tokenCredential),
		// or azure.WithAPIKey(azureOpenAIAPIKey),
	)
}

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

View Source
const ChatModelChatgpt4oLatest = shared.ChatModelChatgpt4oLatest

Equals "chatgpt-4o-latest"

View Source
const ChatModelCodexMiniLatest = shared.ChatModelCodexMiniLatest

Equals "codex-mini-latest"

View Source
const ChatModelGPT3_5Turbo = shared.ChatModelGPT3_5Turbo

Equals "gpt-3.5-turbo"

View Source
const ChatModelGPT3_5Turbo0125 = shared.ChatModelGPT3_5Turbo0125

Equals "gpt-3.5-turbo-0125"

View Source
const ChatModelGPT3_5Turbo0301 = shared.ChatModelGPT3_5Turbo0301

Equals "gpt-3.5-turbo-0301"

View Source
const ChatModelGPT3_5Turbo0613 = shared.ChatModelGPT3_5Turbo0613

Equals "gpt-3.5-turbo-0613"

View Source
const ChatModelGPT3_5Turbo1106 = shared.ChatModelGPT3_5Turbo1106

Equals "gpt-3.5-turbo-1106"

View Source
const ChatModelGPT3_5Turbo16k = shared.ChatModelGPT3_5Turbo16k

Equals "gpt-3.5-turbo-16k"

View Source
const ChatModelGPT3_5Turbo16k0613 = shared.ChatModelGPT3_5Turbo16k0613

Equals "gpt-3.5-turbo-16k-0613"

View Source
const ChatModelGPT4 = shared.ChatModelGPT4

Equals "gpt-4"

View Source
const ChatModelGPT4Turbo = shared.ChatModelGPT4Turbo

Equals "gpt-4-turbo"

View Source
const ChatModelGPT4Turbo2024_04_09 = shared.ChatModelGPT4Turbo2024_04_09

Equals "gpt-4-turbo-2024-04-09"

View Source
const ChatModelGPT4TurboPreview = shared.ChatModelGPT4TurboPreview

Equals "gpt-4-turbo-preview"

View Source
const ChatModelGPT4VisionPreview = shared.ChatModelGPT4VisionPreview

Equals "gpt-4-vision-preview"

View Source
const ChatModelGPT4_0125Preview = shared.ChatModelGPT4_0125Preview

Equals "gpt-4-0125-preview"

View Source
const ChatModelGPT4_0314 = shared.ChatModelGPT4_0314

Equals "gpt-4-0314"

View Source
const ChatModelGPT4_0613 = shared.ChatModelGPT4_0613

Equals "gpt-4-0613"

View Source
const ChatModelGPT4_1 = shared.ChatModelGPT4_1

Equals "gpt-4.1"

View Source
const ChatModelGPT4_1106Preview = shared.ChatModelGPT4_1106Preview

Equals "gpt-4-1106-preview"

View Source
const ChatModelGPT4_1Mini = shared.ChatModelGPT4_1Mini

Equals "gpt-4.1-mini"

View Source
const ChatModelGPT4_1Mini2025_04_14 = shared.ChatModelGPT4_1Mini2025_04_14

Equals "gpt-4.1-mini-2025-04-14"

View Source
const ChatModelGPT4_1Nano = shared.ChatModelGPT4_1Nano

Equals "gpt-4.1-nano"

View Source
const ChatModelGPT4_1Nano2025_04_14 = shared.ChatModelGPT4_1Nano2025_04_14

Equals "gpt-4.1-nano-2025-04-14"

View Source
const ChatModelGPT4_1_2025_04_14 = shared.ChatModelGPT4_1_2025_04_14

Equals "gpt-4.1-2025-04-14"

View Source
const ChatModelGPT4_32k = shared.ChatModelGPT4_32k

Equals "gpt-4-32k"

View Source
const ChatModelGPT4_32k0314 = shared.ChatModelGPT4_32k0314

Equals "gpt-4-32k-0314"

View Source
const ChatModelGPT4_32k0613 = shared.ChatModelGPT4_32k0613

Equals "gpt-4-32k-0613"

View Source
const ChatModelGPT4o = shared.ChatModelGPT4o

Equals "gpt-4o"

View Source
const ChatModelGPT4o2024_05_13 = shared.ChatModelGPT4o2024_05_13

Equals "gpt-4o-2024-05-13"

View Source
const ChatModelGPT4o2024_08_06 = shared.ChatModelGPT4o2024_08_06

Equals "gpt-4o-2024-08-06"

View Source
const ChatModelGPT4o2024_11_20 = shared.ChatModelGPT4o2024_11_20

Equals "gpt-4o-2024-11-20"

View Source
const ChatModelGPT4oAudioPreview = shared.ChatModelGPT4oAudioPreview

Equals "gpt-4o-audio-preview"

View Source
const ChatModelGPT4oAudioPreview2024_10_01 = shared.ChatModelGPT4oAudioPreview2024_10_01

Equals "gpt-4o-audio-preview-2024-10-01"

View Source
const ChatModelGPT4oAudioPreview2024_12_17 = shared.ChatModelGPT4oAudioPreview2024_12_17

Equals "gpt-4o-audio-preview-2024-12-17"

View Source
const ChatModelGPT4oAudioPreview2025_06_03 = shared.ChatModelGPT4oAudioPreview2025_06_03

Equals "gpt-4o-audio-preview-2025-06-03"

View Source
const ChatModelGPT4oMini = shared.ChatModelGPT4oMini

Equals "gpt-4o-mini"

View Source
const ChatModelGPT4oMini2024_07_18 = shared.ChatModelGPT4oMini2024_07_18

Equals "gpt-4o-mini-2024-07-18"

View Source
const ChatModelGPT4oMiniAudioPreview = shared.ChatModelGPT4oMiniAudioPreview

Equals "gpt-4o-mini-audio-preview"

View Source
const ChatModelGPT4oMiniAudioPreview2024_12_17 = shared.ChatModelGPT4oMiniAudioPreview2024_12_17

Equals "gpt-4o-mini-audio-preview-2024-12-17"

View Source
const ChatModelGPT4oMiniSearchPreview = shared.ChatModelGPT4oMiniSearchPreview

Equals "gpt-4o-mini-search-preview"

View Source
const ChatModelGPT4oMiniSearchPreview2025_03_11 = shared.ChatModelGPT4oMiniSearchPreview2025_03_11

Equals "gpt-4o-mini-search-preview-2025-03-11"

View Source
const ChatModelGPT4oSearchPreview = shared.ChatModelGPT4oSearchPreview

Equals "gpt-4o-search-preview"

View Source
const ChatModelGPT4oSearchPreview2025_03_11 = shared.ChatModelGPT4oSearchPreview2025_03_11

Equals "gpt-4o-search-preview-2025-03-11"

View Source
const ChatModelO1 = shared.ChatModelO1

Equals "o1"

View Source
const ChatModelO1Mini = shared.ChatModelO1Mini

Equals "o1-mini"

View Source
const ChatModelO1Mini2024_09_12 = shared.ChatModelO1Mini2024_09_12

Equals "o1-mini-2024-09-12"

View Source
const ChatModelO1Preview = shared.ChatModelO1Preview

Equals "o1-preview"

View Source
const ChatModelO1Preview2024_09_12 = shared.ChatModelO1Preview2024_09_12

Equals "o1-preview-2024-09-12"

View Source
const ChatModelO1_2024_12_17 = shared.ChatModelO1_2024_12_17

Equals "o1-2024-12-17"

View Source
const ChatModelO3 = shared.ChatModelO3

Equals "o3"

View Source
const ChatModelO3Mini = shared.ChatModelO3Mini

Equals "o3-mini"

View Source
const ChatModelO3Mini2025_01_31 = shared.ChatModelO3Mini2025_01_31

Equals "o3-mini-2025-01-31"

View Source
const ChatModelO3_2025_04_16 = shared.ChatModelO3_2025_04_16

Equals "o3-2025-04-16"

View Source
const ChatModelO4Mini = shared.ChatModelO4Mini

Equals "o4-mini"

View Source
const ChatModelO4Mini2025_04_16 = shared.ChatModelO4Mini2025_04_16

Equals "o4-mini-2025-04-16"

View Source
const ComparisonFilterTypeEq = shared.ComparisonFilterTypeEq

Equals "eq"

View Source
const ComparisonFilterTypeGt = shared.ComparisonFilterTypeGt

Equals "gt"

View Source
const ComparisonFilterTypeGte = shared.ComparisonFilterTypeGte

Equals "gte"

View Source
const ComparisonFilterTypeLt = shared.ComparisonFilterTypeLt

Equals "lt"

View Source
const ComparisonFilterTypeLte = shared.ComparisonFilterTypeLte

Equals "lte"

View Source
const ComparisonFilterTypeNe = shared.ComparisonFilterTypeNe

Equals "ne"

View Source
const CompoundFilterTypeAnd = shared.CompoundFilterTypeAnd

Equals "and"

View Source
const CompoundFilterTypeOr = shared.CompoundFilterTypeOr

Equals "or"

View Source
const ReasoningEffortHigh = shared.ReasoningEffortHigh

Equals "high"

View Source
const ReasoningEffortLow = shared.ReasoningEffortLow

Equals "low"

View Source
const ReasoningEffortMedium = shared.ReasoningEffortMedium

Equals "medium"

View Source
const ReasoningGenerateSummaryAuto = shared.ReasoningGenerateSummaryAuto

Equals "auto"

View Source
const ReasoningGenerateSummaryConcise = shared.ReasoningGenerateSummaryConcise

Equals "concise"

View Source
const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed

Equals "detailed"

View Source
const ReasoningSummaryAuto = shared.ReasoningSummaryAuto

Equals "auto"

View Source
const ReasoningSummaryConcise = shared.ReasoningSummaryConcise

Equals "concise"

View Source
const ReasoningSummaryDetailed = shared.ReasoningSummaryDetailed

Equals "detailed"

View Source
const ResponsesModelComputerUsePreview = shared.ResponsesModelComputerUsePreview

Equals "computer-use-preview"

View Source
const ResponsesModelComputerUsePreview2025_03_11 = shared.ResponsesModelComputerUsePreview2025_03_11

Equals "computer-use-preview-2025-03-11"

View Source
const ResponsesModelO1Pro = shared.ResponsesModelO1Pro

Equals "o1-pro"

View Source
const ResponsesModelO1Pro2025_03_19 = shared.ResponsesModelO1Pro2025_03_19

Equals "o1-pro-2025-03-19"

View Source
const ResponsesModelO3Pro = shared.ResponsesModelO3Pro

Equals "o3-pro"

View Source
const ResponsesModelO3Pro2025_06_10 = shared.ResponsesModelO3Pro2025_06_10

Equals "o3-pro-2025-06-10"

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (OPENAI_API_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID, OPENAI_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type AnnotationDeltaUnion added in v1.1.0

type AnnotationDeltaUnion struct {
	Index int64 `json:"index"`
	// Any of "file_citation", "file_path".
	Type     string `json:"type"`
	EndIndex int64  `json:"end_index"`
	// This field is from variant [FileCitationDeltaAnnotation].
	FileCitation FileCitationDeltaAnnotationFileCitation `json:"file_citation"`
	StartIndex   int64                                   `json:"start_index"`
	Text         string                                  `json:"text"`
	// This field is from variant [FilePathDeltaAnnotation].
	FilePath FilePathDeltaAnnotationFilePath `json:"file_path"`
	JSON     struct {
		Index        respjson.Field
		Type         respjson.Field
		EndIndex     respjson.Field
		FileCitation respjson.Field
		StartIndex   respjson.Field
		Text         respjson.Field
		FilePath     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AnnotationDeltaUnion contains all possible properties and values from FileCitationDeltaAnnotation, FilePathDeltaAnnotation.

Use the AnnotationDeltaUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (AnnotationDeltaUnion) AsAny added in v1.1.0

func (u AnnotationDeltaUnion) AsAny() anyAnnotationDelta

Use the following switch statement to find the correct variant

switch variant := AnnotationDeltaUnion.AsAny().(type) {
case openai.FileCitationDeltaAnnotation:
case openai.FilePathDeltaAnnotation:
default:
  fmt.Errorf("no variant present")
}

func (AnnotationDeltaUnion) AsFileCitation added in v1.1.0

func (u AnnotationDeltaUnion) AsFileCitation() (v FileCitationDeltaAnnotation)

func (AnnotationDeltaUnion) AsFilePath added in v1.1.0

func (u AnnotationDeltaUnion) AsFilePath() (v FilePathDeltaAnnotation)

func (AnnotationDeltaUnion) RawJSON added in v1.1.0

func (u AnnotationDeltaUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*AnnotationDeltaUnion) UnmarshalJSON added in v1.1.0

func (r *AnnotationDeltaUnion) UnmarshalJSON(data []byte) error

type AnnotationUnion added in v1.1.0

type AnnotationUnion struct {
	EndIndex int64 `json:"end_index"`
	// This field is from variant [FileCitationAnnotation].
	FileCitation FileCitationAnnotationFileCitation `json:"file_citation"`
	StartIndex   int64                              `json:"start_index"`
	Text         string                             `json:"text"`
	// Any of "file_citation", "file_path".
	Type string `json:"type"`
	// This field is from variant [FilePathAnnotation].
	FilePath FilePathAnnotationFilePath `json:"file_path"`
	JSON     struct {
		EndIndex     respjson.Field
		FileCitation respjson.Field
		StartIndex   respjson.Field
		Text         respjson.Field
		Type         respjson.Field
		FilePath     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AnnotationUnion contains all possible properties and values from FileCitationAnnotation, FilePathAnnotation.

Use the AnnotationUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (AnnotationUnion) AsAny added in v1.1.0

func (u AnnotationUnion) AsAny() anyAnnotation

Use the following switch statement to find the correct variant

switch variant := AnnotationUnion.AsAny().(type) {
case openai.FileCitationAnnotation:
case openai.FilePathAnnotation:
default:
  fmt.Errorf("no variant present")
}

func (AnnotationUnion) AsFileCitation added in v1.1.0

func (u AnnotationUnion) AsFileCitation() (v FileCitationAnnotation)

func (AnnotationUnion) AsFilePath added in v1.1.0

func (u AnnotationUnion) AsFilePath() (v FilePathAnnotation)

func (AnnotationUnion) RawJSON added in v1.1.0

func (u AnnotationUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*AnnotationUnion) UnmarshalJSON added in v1.1.0

func (r *AnnotationUnion) UnmarshalJSON(data []byte) error

type Assistant added in v1.1.0

type Assistant struct {
	// The identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the assistant was created.
	CreatedAt int64 `json:"created_at,required"`
	// The description of the assistant. The maximum length is 512 characters.
	Description string `json:"description,required"`
	// The system instructions that the assistant uses. The maximum length is 256,000
	// characters.
	Instructions string `json:"instructions,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,required"`
	// ID of the model to use. You can use the
	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
	// see all of your available models, or see our
	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
	// them.
	Model string `json:"model,required"`
	// The name of the assistant. The maximum length is 256 characters.
	Name string `json:"name,required"`
	// The object type, which is always `assistant`.
	Object constant.Assistant `json:"object,required"`
	// A list of tool enabled on the assistant. There can be a maximum of 128 tools per
	// assistant. Tools can be of types `code_interpreter`, `file_search`, or
	// `function`.
	Tools []AssistantToolUnion `json:"tools,required"`
	// Specifies the format that the model must output. Compatible with
	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
	//
	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
	// Outputs which ensures the model will match your supplied JSON schema. Learn more
	// in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
	// message the model generates is valid JSON.
	//
	// **Important:** when using JSON mode, you **must** also instruct the model to
	// produce JSON yourself via a system or user message. Without this, the model may
	// generate an unending stream of whitespace until the generation reaches the token
	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
	// the message content may be partially cut off if `finish_reason="length"`, which
	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
	// max context length.
	ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format,nullable"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic.
	Temperature float64 `json:"temperature,nullable"`
	// A set of resources that are used by the assistant's tools. The resources are
	// specific to the type of tool. For example, the `code_interpreter` tool requires
	// a list of file IDs, while the `file_search` tool requires a list of vector store
	// IDs.
	ToolResources AssistantToolResources `json:"tool_resources,nullable"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or temperature but not both.
	TopP float64 `json:"top_p,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID             respjson.Field
		CreatedAt      respjson.Field
		Description    respjson.Field
		Instructions   respjson.Field
		Metadata       respjson.Field
		Model          respjson.Field
		Name           respjson.Field
		Object         respjson.Field
		Tools          respjson.Field
		ResponseFormat respjson.Field
		Temperature    respjson.Field
		ToolResources  respjson.Field
		TopP           respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents an `assistant` that can call the model and use tools.

func (Assistant) RawJSON added in v1.1.0

func (r Assistant) RawJSON() string

Returns the unmodified JSON received from the API

func (*Assistant) UnmarshalJSON added in v1.1.0

func (r *Assistant) UnmarshalJSON(data []byte) error

type AssistantDeleted added in v1.1.0

type AssistantDeleted struct {
	ID      string                    `json:"id,required"`
	Deleted bool                      `json:"deleted,required"`
	Object  constant.AssistantDeleted `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AssistantDeleted) RawJSON added in v1.1.0

func (r AssistantDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*AssistantDeleted) UnmarshalJSON added in v1.1.0

func (r *AssistantDeleted) UnmarshalJSON(data []byte) error

type AssistantResponseFormatOptionUnion added in v1.1.0

type AssistantResponseFormatOptionUnion struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	Type   string        `json:"type"`
	// This field is from variant [shared.ResponseFormatJSONSchema].
	JSONSchema shared.ResponseFormatJSONSchemaJSONSchema `json:"json_schema"`
	JSON       struct {
		OfAuto     respjson.Field
		Type       respjson.Field
		JSONSchema respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantResponseFormatOptionUnion contains all possible properties and values from constant.Auto, shared.ResponseFormatText, shared.ResponseFormatJSONObject, shared.ResponseFormatJSONSchema.

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto]

func (AssistantResponseFormatOptionUnion) AsAuto added in v1.1.0

func (AssistantResponseFormatOptionUnion) AsJSONObject added in v1.1.0

func (AssistantResponseFormatOptionUnion) AsJSONSchema added in v1.1.0

func (AssistantResponseFormatOptionUnion) AsText added in v1.1.0

func (AssistantResponseFormatOptionUnion) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (AssistantResponseFormatOptionUnion) ToParam added in v1.1.0

ToParam converts this AssistantResponseFormatOptionUnion to a AssistantResponseFormatOptionUnionParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with AssistantResponseFormatOptionUnionParam.Overrides()

func (*AssistantResponseFormatOptionUnion) UnmarshalJSON added in v1.1.0

func (r *AssistantResponseFormatOptionUnion) UnmarshalJSON(data []byte) error

type AssistantResponseFormatOptionUnionParam added in v1.1.0

type AssistantResponseFormatOptionUnionParam struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto       constant.Auto                         `json:",omitzero,inline"`
	OfText       *shared.ResponseFormatTextParam       `json:",omitzero,inline"`
	OfJSONObject *shared.ResponseFormatJSONObjectParam `json:",omitzero,inline"`
	OfJSONSchema *shared.ResponseFormatJSONSchemaParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func AssistantResponseFormatOptionParamOfAuto added in v1.1.0

func AssistantResponseFormatOptionParamOfAuto() AssistantResponseFormatOptionUnionParam

func AssistantResponseFormatOptionParamOfJSONSchema added in v1.1.0

func AssistantResponseFormatOptionParamOfJSONSchema(jsonSchema shared.ResponseFormatJSONSchemaJSONSchemaParam) AssistantResponseFormatOptionUnionParam

func (AssistantResponseFormatOptionUnionParam) GetJSONSchema added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (AssistantResponseFormatOptionUnionParam) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (AssistantResponseFormatOptionUnionParam) MarshalJSON added in v1.1.0

func (u AssistantResponseFormatOptionUnionParam) MarshalJSON() ([]byte, error)

func (*AssistantResponseFormatOptionUnionParam) UnmarshalJSON added in v1.1.0

func (u *AssistantResponseFormatOptionUnionParam) UnmarshalJSON(data []byte) error

type AssistantStreamEventErrorEvent added in v1.1.0

type AssistantStreamEventErrorEvent struct {
	Data  shared.ErrorObject `json:"data,required"`
	Event constant.Error     `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when an [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout.

func (AssistantStreamEventErrorEvent) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventErrorEvent) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventErrorEvent) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadCreated added in v1.1.0

type AssistantStreamEventThreadCreated struct {
	// Represents a thread that contains
	// [messages](https://platform.openai.com/docs/api-reference/messages).
	Data  Thread                 `json:"data,required"`
	Event constant.ThreadCreated `json:"event,required"`
	// Whether to enable input audio transcription.
	Enabled bool `json:"enabled"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		Enabled     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created.

func (AssistantStreamEventThreadCreated) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadCreated) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadCreated) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadMessageCompleted added in v1.1.0

type AssistantStreamEventThreadMessageCompleted struct {
	// Represents a message within a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Message                         `json:"data,required"`
	Event constant.ThreadMessageCompleted `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed.

func (AssistantStreamEventThreadMessageCompleted) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadMessageCompleted) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadMessageCompleted) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadMessageCreated added in v1.1.0

type AssistantStreamEventThreadMessageCreated struct {
	// Represents a message within a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Message                       `json:"data,required"`
	Event constant.ThreadMessageCreated `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created.

func (AssistantStreamEventThreadMessageCreated) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadMessageCreated) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadMessageCreated) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadMessageDelta added in v1.1.0

type AssistantStreamEventThreadMessageDelta struct {
	// Represents a message delta i.e. any changed fields on a message during
	// streaming.
	Data  MessageDeltaEvent           `json:"data,required"`
	Event constant.ThreadMessageDelta `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when parts of a Message(https://platform.openai.com/docs/api-reference/messages/object) are being streamed.

func (AssistantStreamEventThreadMessageDelta) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadMessageDelta) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadMessageDelta) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadMessageInProgress added in v1.1.0

type AssistantStreamEventThreadMessageInProgress struct {
	// Represents a message within a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Message                          `json:"data,required"`
	Event constant.ThreadMessageInProgress `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state.

func (AssistantStreamEventThreadMessageInProgress) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadMessageInProgress) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadMessageInProgress) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadMessageIncomplete added in v1.1.0

type AssistantStreamEventThreadMessageIncomplete struct {
	// Represents a message within a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Message                          `json:"data,required"`
	Event constant.ThreadMessageIncomplete `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed.

func (AssistantStreamEventThreadMessageIncomplete) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadMessageIncomplete) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadMessageIncomplete) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunCancelled added in v1.1.0

type AssistantStreamEventThreadRunCancelled struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                         `json:"data,required"`
	Event constant.ThreadRunCancelled `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled.

func (AssistantStreamEventThreadRunCancelled) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunCancelled) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunCancelled) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunCancelling added in v1.1.0

type AssistantStreamEventThreadRunCancelling struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                          `json:"data,required"`
	Event constant.ThreadRunCancelling `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status.

func (AssistantStreamEventThreadRunCancelling) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunCancelling) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunCancelling) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunCompleted added in v1.1.0

type AssistantStreamEventThreadRunCompleted struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                         `json:"data,required"`
	Event constant.ThreadRunCompleted `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed.

func (AssistantStreamEventThreadRunCompleted) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunCompleted) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunCompleted) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunCreated added in v1.1.0

type AssistantStreamEventThreadRunCreated struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                       `json:"data,required"`
	Event constant.ThreadRunCreated `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created.

func (AssistantStreamEventThreadRunCreated) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunCreated) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunCreated) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunExpired added in v1.1.0

type AssistantStreamEventThreadRunExpired struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                       `json:"data,required"`
	Event constant.ThreadRunExpired `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires.

func (AssistantStreamEventThreadRunExpired) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunExpired) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunExpired) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunFailed added in v1.1.0

type AssistantStreamEventThreadRunFailed struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                      `json:"data,required"`
	Event constant.ThreadRunFailed `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails.

func (AssistantStreamEventThreadRunFailed) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunFailed) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunFailed) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunInProgress added in v1.1.0

type AssistantStreamEventThreadRunInProgress struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                          `json:"data,required"`
	Event constant.ThreadRunInProgress `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status.

func (AssistantStreamEventThreadRunInProgress) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunInProgress) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunInProgress) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunIncomplete added in v1.1.0

type AssistantStreamEventThreadRunIncomplete struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                          `json:"data,required"`
	Event constant.ThreadRunIncomplete `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`.

func (AssistantStreamEventThreadRunIncomplete) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunIncomplete) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunIncomplete) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunQueued added in v1.1.0

type AssistantStreamEventThreadRunQueued struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                      `json:"data,required"`
	Event constant.ThreadRunQueued `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status.

func (AssistantStreamEventThreadRunQueued) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunQueued) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunQueued) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunRequiresAction added in v1.1.0

type AssistantStreamEventThreadRunRequiresAction struct {
	// Represents an execution run on a
	// [thread](https://platform.openai.com/docs/api-reference/threads).
	Data  Run                              `json:"data,required"`
	Event constant.ThreadRunRequiresAction `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status.

func (AssistantStreamEventThreadRunRequiresAction) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunRequiresAction) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunRequiresAction) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunStepCancelled added in v1.1.0

type AssistantStreamEventThreadRunStepCancelled struct {
	// Represents a step in execution of a run.
	Data  RunStep                         `json:"data,required"`
	Event constant.ThreadRunStepCancelled `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is cancelled.

func (AssistantStreamEventThreadRunStepCancelled) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunStepCancelled) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunStepCancelled) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunStepCompleted added in v1.1.0

type AssistantStreamEventThreadRunStepCompleted struct {
	// Represents a step in execution of a run.
	Data  RunStep                         `json:"data,required"`
	Event constant.ThreadRunStepCompleted `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is completed.

func (AssistantStreamEventThreadRunStepCompleted) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunStepCompleted) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunStepCompleted) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunStepCreated added in v1.1.0

type AssistantStreamEventThreadRunStepCreated struct {
	// Represents a step in execution of a run.
	Data  RunStep                       `json:"data,required"`
	Event constant.ThreadRunStepCreated `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is created.

func (AssistantStreamEventThreadRunStepCreated) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunStepCreated) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunStepCreated) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunStepDelta added in v1.1.0

type AssistantStreamEventThreadRunStepDelta struct {
	// Represents a run step delta i.e. any changed fields on a run step during
	// streaming.
	Data  RunStepDeltaEvent           `json:"data,required"`
	Event constant.ThreadRunStepDelta `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when parts of a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) are being streamed.

func (AssistantStreamEventThreadRunStepDelta) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunStepDelta) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunStepDelta) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunStepExpired added in v1.1.0

type AssistantStreamEventThreadRunStepExpired struct {
	// Represents a step in execution of a run.
	Data  RunStep                       `json:"data,required"`
	Event constant.ThreadRunStepExpired `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) expires.

func (AssistantStreamEventThreadRunStepExpired) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunStepExpired) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunStepExpired) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunStepFailed added in v1.1.0

type AssistantStreamEventThreadRunStepFailed struct {
	// Represents a step in execution of a run.
	Data  RunStep                      `json:"data,required"`
	Event constant.ThreadRunStepFailed `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) fails.

func (AssistantStreamEventThreadRunStepFailed) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunStepFailed) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunStepFailed) UnmarshalJSON(data []byte) error

type AssistantStreamEventThreadRunStepInProgress added in v1.1.0

type AssistantStreamEventThreadRunStepInProgress struct {
	// Represents a step in execution of a run.
	Data  RunStep                          `json:"data,required"`
	Event constant.ThreadRunStepInProgress `json:"event,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Event       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) moves to an `in_progress` state.

func (AssistantStreamEventThreadRunStepInProgress) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantStreamEventThreadRunStepInProgress) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventThreadRunStepInProgress) UnmarshalJSON(data []byte) error

type AssistantStreamEventUnion added in v1.1.0

type AssistantStreamEventUnion struct {
	// This field is a union of [Thread], [Run], [RunStep], [RunStepDeltaEvent],
	// [Message], [MessageDeltaEvent], [shared.ErrorObject]
	Data AssistantStreamEventUnionData `json:"data"`
	// Any of "thread.created", "thread.run.created", "thread.run.queued",
	// "thread.run.in_progress", "thread.run.requires_action", "thread.run.completed",
	// "thread.run.incomplete", "thread.run.failed", "thread.run.cancelling",
	// "thread.run.cancelled", "thread.run.expired", "thread.run.step.created",
	// "thread.run.step.in_progress", "thread.run.step.delta",
	// "thread.run.step.completed", "thread.run.step.failed",
	// "thread.run.step.cancelled", "thread.run.step.expired",
	// "thread.message.created", "thread.message.in_progress", "thread.message.delta",
	// "thread.message.completed", "thread.message.incomplete", "error".
	Event string `json:"event"`
	// This field is from variant [AssistantStreamEventThreadCreated].
	Enabled bool `json:"enabled"`
	JSON    struct {
		Data    respjson.Field
		Event   respjson.Field
		Enabled respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantStreamEventUnion contains all possible properties and values from AssistantStreamEventThreadCreated, AssistantStreamEventThreadRunCreated, AssistantStreamEventThreadRunQueued, AssistantStreamEventThreadRunInProgress, AssistantStreamEventThreadRunRequiresAction, AssistantStreamEventThreadRunCompleted, AssistantStreamEventThreadRunIncomplete, AssistantStreamEventThreadRunFailed, AssistantStreamEventThreadRunCancelling, AssistantStreamEventThreadRunCancelled, AssistantStreamEventThreadRunExpired, AssistantStreamEventThreadRunStepCreated, AssistantStreamEventThreadRunStepInProgress, AssistantStreamEventThreadRunStepDelta, AssistantStreamEventThreadRunStepCompleted, AssistantStreamEventThreadRunStepFailed, AssistantStreamEventThreadRunStepCancelled, AssistantStreamEventThreadRunStepExpired, AssistantStreamEventThreadMessageCreated, AssistantStreamEventThreadMessageInProgress, AssistantStreamEventThreadMessageDelta, AssistantStreamEventThreadMessageCompleted, AssistantStreamEventThreadMessageIncomplete, AssistantStreamEventErrorEvent.

Use the AssistantStreamEventUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (AssistantStreamEventUnion) AsAny added in v1.1.0

func (u AssistantStreamEventUnion) AsAny() anyAssistantStreamEvent

Use the following switch statement to find the correct variant

switch variant := AssistantStreamEventUnion.AsAny().(type) {
case openai.AssistantStreamEventThreadCreated:
case openai.AssistantStreamEventThreadRunCreated:
case openai.AssistantStreamEventThreadRunQueued:
case openai.AssistantStreamEventThreadRunInProgress:
case openai.AssistantStreamEventThreadRunRequiresAction:
case openai.AssistantStreamEventThreadRunCompleted:
case openai.AssistantStreamEventThreadRunIncomplete:
case openai.AssistantStreamEventThreadRunFailed:
case openai.AssistantStreamEventThreadRunCancelling:
case openai.AssistantStreamEventThreadRunCancelled:
case openai.AssistantStreamEventThreadRunExpired:
case openai.AssistantStreamEventThreadRunStepCreated:
case openai.AssistantStreamEventThreadRunStepInProgress:
case openai.AssistantStreamEventThreadRunStepDelta:
case openai.AssistantStreamEventThreadRunStepCompleted:
case openai.AssistantStreamEventThreadRunStepFailed:
case openai.AssistantStreamEventThreadRunStepCancelled:
case openai.AssistantStreamEventThreadRunStepExpired:
case openai.AssistantStreamEventThreadMessageCreated:
case openai.AssistantStreamEventThreadMessageInProgress:
case openai.AssistantStreamEventThreadMessageDelta:
case openai.AssistantStreamEventThreadMessageCompleted:
case openai.AssistantStreamEventThreadMessageIncomplete:
case openai.AssistantStreamEventErrorEvent:
default:
  fmt.Errorf("no variant present")
}

func (AssistantStreamEventUnion) AsErrorEvent added in v1.1.0

func (AssistantStreamEventUnion) AsThreadCreated added in v1.1.0

func (AssistantStreamEventUnion) AsThreadMessageCompleted added in v1.1.0

func (AssistantStreamEventUnion) AsThreadMessageCreated added in v1.1.0

func (AssistantStreamEventUnion) AsThreadMessageDelta added in v1.1.0

func (AssistantStreamEventUnion) AsThreadMessageInProgress added in v1.1.0

func (AssistantStreamEventUnion) AsThreadMessageIncomplete added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunCancelled added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunCancelling added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunCompleted added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunCreated added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunExpired added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunFailed added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunInProgress added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunIncomplete added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunQueued added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunRequiresAction added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunStepCancelled added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunStepCompleted added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunStepCreated added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunStepDelta added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunStepExpired added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunStepFailed added in v1.1.0

func (AssistantStreamEventUnion) AsThreadRunStepInProgress added in v1.1.0

func (AssistantStreamEventUnion) RawJSON added in v1.1.0

func (u AssistantStreamEventUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*AssistantStreamEventUnion) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventUnion) UnmarshalJSON(data []byte) error

type AssistantStreamEventUnionData added in v1.1.0

type AssistantStreamEventUnionData struct {
	ID        string `json:"id"`
	CreatedAt int64  `json:"created_at"`
	// This field is from variant [Thread].
	Metadata shared.Metadata `json:"metadata"`
	Object   string          `json:"object"`
	// This field is from variant [Thread].
	ToolResources ThreadToolResources `json:"tool_resources"`
	AssistantID   string              `json:"assistant_id"`
	CancelledAt   int64               `json:"cancelled_at"`
	CompletedAt   int64               `json:"completed_at"`
	// This field is from variant [Run].
	ExpiresAt int64 `json:"expires_at"`
	FailedAt  int64 `json:"failed_at"`
	// This field is a union of [RunIncompleteDetails], [MessageIncompleteDetails]
	IncompleteDetails AssistantStreamEventUnionDataIncompleteDetails `json:"incomplete_details"`
	// This field is from variant [Run].
	Instructions string `json:"instructions"`
	// This field is a union of [RunLastError], [RunStepLastError]
	LastError AssistantStreamEventUnionDataLastError `json:"last_error"`
	// This field is from variant [Run].
	MaxCompletionTokens int64 `json:"max_completion_tokens"`
	// This field is from variant [Run].
	MaxPromptTokens int64 `json:"max_prompt_tokens"`
	// This field is from variant [Run].
	Model string `json:"model"`
	// This field is from variant [Run].
	ParallelToolCalls bool `json:"parallel_tool_calls"`
	// This field is from variant [Run].
	RequiredAction RunRequiredAction `json:"required_action"`
	// This field is from variant [Run].
	ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format"`
	// This field is from variant [Run].
	StartedAt int64  `json:"started_at"`
	Status    string `json:"status"`
	ThreadID  string `json:"thread_id"`
	// This field is from variant [Run].
	ToolChoice AssistantToolChoiceOptionUnion `json:"tool_choice"`
	// This field is from variant [Run].
	Tools []AssistantToolUnion `json:"tools"`
	// This field is from variant [Run].
	TruncationStrategy RunTruncationStrategy `json:"truncation_strategy"`
	// This field is a union of [RunUsage], [RunStepUsage]
	Usage AssistantStreamEventUnionDataUsage `json:"usage"`
	// This field is from variant [Run].
	Temperature float64 `json:"temperature"`
	// This field is from variant [Run].
	TopP float64 `json:"top_p"`
	// This field is from variant [RunStep].
	ExpiredAt int64  `json:"expired_at"`
	RunID     string `json:"run_id"`
	// This field is from variant [RunStep].
	StepDetails RunStepStepDetailsUnion `json:"step_details"`
	Type        string                  `json:"type"`
	// This field is a union of [RunStepDelta], [MessageDelta]
	Delta AssistantStreamEventUnionDataDelta `json:"delta"`
	// This field is from variant [Message].
	Attachments []MessageAttachment `json:"attachments"`
	// This field is from variant [Message].
	Content []MessageContentUnion `json:"content"`
	// This field is from variant [Message].
	IncompleteAt int64 `json:"incomplete_at"`
	// This field is from variant [Message].
	Role MessageRole `json:"role"`
	// This field is from variant [shared.ErrorObject].
	Code string `json:"code"`
	// This field is from variant [shared.ErrorObject].
	Message string `json:"message"`
	// This field is from variant [shared.ErrorObject].
	Param string `json:"param"`
	JSON  struct {
		ID                  respjson.Field
		CreatedAt           respjson.Field
		Metadata            respjson.Field
		Object              respjson.Field
		ToolResources       respjson.Field
		AssistantID         respjson.Field
		CancelledAt         respjson.Field
		CompletedAt         respjson.Field
		ExpiresAt           respjson.Field
		FailedAt            respjson.Field
		IncompleteDetails   respjson.Field
		Instructions        respjson.Field
		LastError           respjson.Field
		MaxCompletionTokens respjson.Field
		MaxPromptTokens     respjson.Field
		Model               respjson.Field
		ParallelToolCalls   respjson.Field
		RequiredAction      respjson.Field
		ResponseFormat      respjson.Field
		StartedAt           respjson.Field
		Status              respjson.Field
		ThreadID            respjson.Field
		ToolChoice          respjson.Field
		Tools               respjson.Field
		TruncationStrategy  respjson.Field
		Usage               respjson.Field
		Temperature         respjson.Field
		TopP                respjson.Field
		ExpiredAt           respjson.Field
		RunID               respjson.Field
		StepDetails         respjson.Field
		Type                respjson.Field
		Delta               respjson.Field
		Attachments         respjson.Field
		Content             respjson.Field
		IncompleteAt        respjson.Field
		Role                respjson.Field
		Code                respjson.Field
		Message             respjson.Field
		Param               respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantStreamEventUnionData is an implicit subunion of AssistantStreamEventUnion. AssistantStreamEventUnionData provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the AssistantStreamEventUnion.

func (*AssistantStreamEventUnionData) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventUnionData) UnmarshalJSON(data []byte) error

type AssistantStreamEventUnionDataDelta added in v1.1.0

type AssistantStreamEventUnionDataDelta struct {
	// This field is from variant [RunStepDelta].
	StepDetails RunStepDeltaStepDetailsUnion `json:"step_details"`
	// This field is from variant [MessageDelta].
	Content []MessageContentDeltaUnion `json:"content"`
	// This field is from variant [MessageDelta].
	Role MessageDeltaRole `json:"role"`
	JSON struct {
		StepDetails respjson.Field
		Content     respjson.Field
		Role        respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantStreamEventUnionDataDelta is an implicit subunion of AssistantStreamEventUnion. AssistantStreamEventUnionDataDelta provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the AssistantStreamEventUnion.

func (*AssistantStreamEventUnionDataDelta) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventUnionDataDelta) UnmarshalJSON(data []byte) error

type AssistantStreamEventUnionDataIncompleteDetails added in v1.1.0

type AssistantStreamEventUnionDataIncompleteDetails struct {
	Reason string `json:"reason"`
	JSON   struct {
		Reason respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantStreamEventUnionDataIncompleteDetails is an implicit subunion of AssistantStreamEventUnion. AssistantStreamEventUnionDataIncompleteDetails provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the AssistantStreamEventUnion.

func (*AssistantStreamEventUnionDataIncompleteDetails) UnmarshalJSON added in v1.1.0

type AssistantStreamEventUnionDataLastError added in v1.1.0

type AssistantStreamEventUnionDataLastError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	JSON    struct {
		Code    respjson.Field
		Message respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantStreamEventUnionDataLastError is an implicit subunion of AssistantStreamEventUnion. AssistantStreamEventUnionDataLastError provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the AssistantStreamEventUnion.

func (*AssistantStreamEventUnionDataLastError) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventUnionDataLastError) UnmarshalJSON(data []byte) error

type AssistantStreamEventUnionDataUsage added in v1.1.0

type AssistantStreamEventUnionDataUsage struct {
	CompletionTokens int64 `json:"completion_tokens"`
	PromptTokens     int64 `json:"prompt_tokens"`
	TotalTokens      int64 `json:"total_tokens"`
	JSON             struct {
		CompletionTokens respjson.Field
		PromptTokens     respjson.Field
		TotalTokens      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantStreamEventUnionDataUsage is an implicit subunion of AssistantStreamEventUnion. AssistantStreamEventUnionDataUsage provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the AssistantStreamEventUnion.

func (*AssistantStreamEventUnionDataUsage) UnmarshalJSON added in v1.1.0

func (r *AssistantStreamEventUnionDataUsage) UnmarshalJSON(data []byte) error

type AssistantToolChoice added in v1.1.0

type AssistantToolChoice struct {
	// The type of the tool. If type is `function`, the function name must be set
	//
	// Any of "function", "code_interpreter", "file_search".
	Type     AssistantToolChoiceType     `json:"type,required"`
	Function AssistantToolChoiceFunction `json:"function"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Function    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Specifies a tool the model should use. Use to force the model to call a specific tool.

func (AssistantToolChoice) RawJSON added in v1.1.0

func (r AssistantToolChoice) RawJSON() string

Returns the unmodified JSON received from the API

func (AssistantToolChoice) ToParam added in v1.1.0

ToParam converts this AssistantToolChoice to a AssistantToolChoiceParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with AssistantToolChoiceParam.Overrides()

func (*AssistantToolChoice) UnmarshalJSON added in v1.1.0

func (r *AssistantToolChoice) UnmarshalJSON(data []byte) error

type AssistantToolChoiceFunction added in v1.1.0

type AssistantToolChoiceFunction struct {
	// The name of the function to call.
	Name string `json:"name,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AssistantToolChoiceFunction) RawJSON added in v1.1.0

func (r AssistantToolChoiceFunction) RawJSON() string

Returns the unmodified JSON received from the API

func (AssistantToolChoiceFunction) ToParam added in v1.1.0

ToParam converts this AssistantToolChoiceFunction to a AssistantToolChoiceFunctionParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with AssistantToolChoiceFunctionParam.Overrides()

func (*AssistantToolChoiceFunction) UnmarshalJSON added in v1.1.0

func (r *AssistantToolChoiceFunction) UnmarshalJSON(data []byte) error

type AssistantToolChoiceFunctionParam added in v1.1.0

type AssistantToolChoiceFunctionParam struct {
	// The name of the function to call.
	Name string `json:"name,required"`
	// contains filtered or unexported fields
}

The property Name is required.

func (AssistantToolChoiceFunctionParam) MarshalJSON added in v1.1.0

func (r AssistantToolChoiceFunctionParam) MarshalJSON() (data []byte, err error)

func (*AssistantToolChoiceFunctionParam) UnmarshalJSON added in v1.1.0

func (r *AssistantToolChoiceFunctionParam) UnmarshalJSON(data []byte) error

type AssistantToolChoiceOptionAuto added in v1.1.0

type AssistantToolChoiceOptionAuto string

`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.

const (
	AssistantToolChoiceOptionAutoNone     AssistantToolChoiceOptionAuto = "none"
	AssistantToolChoiceOptionAutoAuto     AssistantToolChoiceOptionAuto = "auto"
	AssistantToolChoiceOptionAutoRequired AssistantToolChoiceOptionAuto = "required"
)

type AssistantToolChoiceOptionUnion added in v1.1.0

type AssistantToolChoiceOptionUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfAuto string `json:",inline"`
	// This field is from variant [AssistantToolChoice].
	Type AssistantToolChoiceType `json:"type"`
	// This field is from variant [AssistantToolChoice].
	Function AssistantToolChoiceFunction `json:"function"`
	JSON     struct {
		OfAuto   respjson.Field
		Type     respjson.Field
		Function respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantToolChoiceOptionUnion contains all possible properties and values from [string], AssistantToolChoice.

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto]

func (AssistantToolChoiceOptionUnion) AsAssistantToolChoice added in v1.1.0

func (u AssistantToolChoiceOptionUnion) AsAssistantToolChoice() (v AssistantToolChoice)

func (AssistantToolChoiceOptionUnion) AsAuto added in v1.1.0

func (u AssistantToolChoiceOptionUnion) AsAuto() (v string)

func (AssistantToolChoiceOptionUnion) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (AssistantToolChoiceOptionUnion) ToParam added in v1.1.0

ToParam converts this AssistantToolChoiceOptionUnion to a AssistantToolChoiceOptionUnionParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with AssistantToolChoiceOptionUnionParam.Overrides()

func (*AssistantToolChoiceOptionUnion) UnmarshalJSON added in v1.1.0

func (r *AssistantToolChoiceOptionUnion) UnmarshalJSON(data []byte) error

type AssistantToolChoiceOptionUnionParam added in v1.1.0

type AssistantToolChoiceOptionUnionParam struct {
	// Check if union is this variant with !param.IsOmitted(union.OfAuto)
	OfAuto                param.Opt[string]         `json:",omitzero,inline"`
	OfAssistantToolChoice *AssistantToolChoiceParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func AssistantToolChoiceOptionParamOfAssistantToolChoice added in v1.1.0

func AssistantToolChoiceOptionParamOfAssistantToolChoice(type_ AssistantToolChoiceType) AssistantToolChoiceOptionUnionParam

func (AssistantToolChoiceOptionUnionParam) MarshalJSON added in v1.1.0

func (u AssistantToolChoiceOptionUnionParam) MarshalJSON() ([]byte, error)

func (*AssistantToolChoiceOptionUnionParam) UnmarshalJSON added in v1.1.0

func (u *AssistantToolChoiceOptionUnionParam) UnmarshalJSON(data []byte) error

type AssistantToolChoiceParam added in v1.1.0

type AssistantToolChoiceParam struct {
	// The type of the tool. If type is `function`, the function name must be set
	//
	// Any of "function", "code_interpreter", "file_search".
	Type     AssistantToolChoiceType          `json:"type,omitzero,required"`
	Function AssistantToolChoiceFunctionParam `json:"function,omitzero"`
	// contains filtered or unexported fields
}

Specifies a tool the model should use. Use to force the model to call a specific tool.

The property Type is required.

func (AssistantToolChoiceParam) MarshalJSON added in v1.1.0

func (r AssistantToolChoiceParam) MarshalJSON() (data []byte, err error)

func (*AssistantToolChoiceParam) UnmarshalJSON added in v1.1.0

func (r *AssistantToolChoiceParam) UnmarshalJSON(data []byte) error

type AssistantToolChoiceType added in v1.1.0

type AssistantToolChoiceType string

The type of the tool. If type is `function`, the function name must be set

const (
	AssistantToolChoiceTypeFunction        AssistantToolChoiceType = "function"
	AssistantToolChoiceTypeCodeInterpreter AssistantToolChoiceType = "code_interpreter"
	AssistantToolChoiceTypeFileSearch      AssistantToolChoiceType = "file_search"
)

type AssistantToolResources added in v1.1.0

type AssistantToolResources struct {
	CodeInterpreter AssistantToolResourcesCodeInterpreter `json:"code_interpreter"`
	FileSearch      AssistantToolResourcesFileSearch      `json:"file_search"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CodeInterpreter respjson.Field
		FileSearch      respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (AssistantToolResources) RawJSON added in v1.1.0

func (r AssistantToolResources) RawJSON() string

Returns the unmodified JSON received from the API

func (*AssistantToolResources) UnmarshalJSON added in v1.1.0

func (r *AssistantToolResources) UnmarshalJSON(data []byte) error

type AssistantToolResourcesCodeInterpreter added in v1.1.0

type AssistantToolResourcesCodeInterpreter struct {
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
	// available to the `code_interpreter“ tool. There can be a maximum of 20 files
	// associated with the tool.
	FileIDs []string `json:"file_ids"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileIDs     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AssistantToolResourcesCodeInterpreter) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

func (r *AssistantToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error

type AssistantToolResourcesFileSearch added in v1.1.0

type AssistantToolResourcesFileSearch struct {
	// The ID of the
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this assistant. There can be a maximum of 1 vector store attached to
	// the assistant.
	VectorStoreIDs []string `json:"vector_store_ids"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		VectorStoreIDs respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AssistantToolResourcesFileSearch) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*AssistantToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

func (r *AssistantToolResourcesFileSearch) UnmarshalJSON(data []byte) error

type AssistantToolUnion added in v1.1.0

type AssistantToolUnion struct {
	// Any of "code_interpreter", "file_search", "function".
	Type string `json:"type"`
	// This field is from variant [FileSearchTool].
	FileSearch FileSearchToolFileSearch `json:"file_search"`
	// This field is from variant [FunctionTool].
	Function shared.FunctionDefinition `json:"function"`
	JSON     struct {
		Type       respjson.Field
		FileSearch respjson.Field
		Function   respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

AssistantToolUnion contains all possible properties and values from CodeInterpreterTool, FileSearchTool, FunctionTool.

Use the AssistantToolUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (AssistantToolUnion) AsAny added in v1.1.0

func (u AssistantToolUnion) AsAny() anyAssistantTool

Use the following switch statement to find the correct variant

switch variant := AssistantToolUnion.AsAny().(type) {
case openai.CodeInterpreterTool:
case openai.FileSearchTool:
case openai.FunctionTool:
default:
  fmt.Errorf("no variant present")
}

func (AssistantToolUnion) AsCodeInterpreter added in v1.1.0

func (u AssistantToolUnion) AsCodeInterpreter() (v CodeInterpreterTool)

func (AssistantToolUnion) AsFileSearch added in v1.1.0

func (u AssistantToolUnion) AsFileSearch() (v FileSearchTool)

func (AssistantToolUnion) AsFunction added in v1.1.0

func (u AssistantToolUnion) AsFunction() (v FunctionTool)

func (AssistantToolUnion) RawJSON added in v1.1.0

func (u AssistantToolUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (AssistantToolUnion) ToParam added in v1.1.0

ToParam converts this AssistantToolUnion to a AssistantToolUnionParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with AssistantToolUnionParam.Overrides()

func (*AssistantToolUnion) UnmarshalJSON added in v1.1.0

func (r *AssistantToolUnion) UnmarshalJSON(data []byte) error

type AssistantToolUnionParam added in v1.1.0

type AssistantToolUnionParam struct {
	OfCodeInterpreter *CodeInterpreterToolParam `json:",omitzero,inline"`
	OfFileSearch      *FileSearchToolParam      `json:",omitzero,inline"`
	OfFunction        *FunctionToolParam        `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func AssistantToolParamOfFunction added in v1.1.0

func AssistantToolParamOfFunction(function shared.FunctionDefinitionParam) AssistantToolUnionParam

func (AssistantToolUnionParam) GetFileSearch added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (AssistantToolUnionParam) GetFunction added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (AssistantToolUnionParam) GetType added in v1.1.0

func (u AssistantToolUnionParam) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (AssistantToolUnionParam) MarshalJSON added in v1.1.0

func (u AssistantToolUnionParam) MarshalJSON() ([]byte, error)

func (*AssistantToolUnionParam) UnmarshalJSON added in v1.1.0

func (u *AssistantToolUnionParam) UnmarshalJSON(data []byte) error

type AudioModel

type AudioModel = string
const (
	AudioModelWhisper1            AudioModel = "whisper-1"
	AudioModelGPT4oTranscribe     AudioModel = "gpt-4o-transcribe"
	AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe"
)

type AudioResponseFormat

type AudioResponseFormat string

The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`.

const (
	AudioResponseFormatJSON        AudioResponseFormat = "json"
	AudioResponseFormatText        AudioResponseFormat = "text"
	AudioResponseFormatSRT         AudioResponseFormat = "srt"
	AudioResponseFormatVerboseJSON AudioResponseFormat = "verbose_json"
	AudioResponseFormatVTT         AudioResponseFormat = "vtt"
)

type AudioService

type AudioService struct {
	Options        []option.RequestOption
	Transcriptions AudioTranscriptionService
	Translations   AudioTranslationService
	Speech         AudioSpeechService
}

AudioService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAudioService method instead.

func NewAudioService

func NewAudioService(opts ...option.RequestOption) (r AudioService)

NewAudioService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type AudioSpeechNewParams

type AudioSpeechNewParams struct {
	// The text to generate audio for. The maximum length is 4096 characters.
	Input string `json:"input,required"`
	// One of the available [TTS models](https://platform.openai.com/docs/models#tts):
	// `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
	Model SpeechModel `json:"model,omitzero,required"`
	// The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
	// `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
	// `verse`. Previews of the voices are available in the
	// [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
	Voice AudioSpeechNewParamsVoice `json:"voice,omitzero,required"`
	// Control the voice of your generated audio with additional instructions. Does not
	// work with `tts-1` or `tts-1-hd`.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
	// the default.
	Speed param.Opt[float64] `json:"speed,omitzero"`
	// The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
	// `wav`, and `pcm`.
	//
	// Any of "mp3", "opus", "aac", "flac", "wav", "pcm".
	ResponseFormat AudioSpeechNewParamsResponseFormat `json:"response_format,omitzero"`
	// The format to stream the audio in. Supported formats are `sse` and `audio`.
	// `sse` is not supported for `tts-1` or `tts-1-hd`.
	//
	// Any of "sse", "audio".
	StreamFormat AudioSpeechNewParamsStreamFormat `json:"stream_format,omitzero"`
	// contains filtered or unexported fields
}

func (AudioSpeechNewParams) MarshalJSON

func (r AudioSpeechNewParams) MarshalJSON() (data []byte, err error)

func (*AudioSpeechNewParams) UnmarshalJSON

func (r *AudioSpeechNewParams) UnmarshalJSON(data []byte) error

type AudioSpeechNewParamsResponseFormat

type AudioSpeechNewParamsResponseFormat string

The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.

const (
	AudioSpeechNewParamsResponseFormatMP3  AudioSpeechNewParamsResponseFormat = "mp3"
	AudioSpeechNewParamsResponseFormatOpus AudioSpeechNewParamsResponseFormat = "opus"
	AudioSpeechNewParamsResponseFormatAAC  AudioSpeechNewParamsResponseFormat = "aac"
	AudioSpeechNewParamsResponseFormatFLAC AudioSpeechNewParamsResponseFormat = "flac"
	AudioSpeechNewParamsResponseFormatWAV  AudioSpeechNewParamsResponseFormat = "wav"
	AudioSpeechNewParamsResponseFormatPCM  AudioSpeechNewParamsResponseFormat = "pcm"
)

type AudioSpeechNewParamsStreamFormat added in v1.7.0

type AudioSpeechNewParamsStreamFormat string

The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.

const (
	AudioSpeechNewParamsStreamFormatSSE   AudioSpeechNewParamsStreamFormat = "sse"
	AudioSpeechNewParamsStreamFormatAudio AudioSpeechNewParamsStreamFormat = "audio"
)

type AudioSpeechNewParamsVoice

type AudioSpeechNewParamsVoice string

The voice to use when generating the audio. Supported voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and `verse`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

const (
	AudioSpeechNewParamsVoiceAlloy   AudioSpeechNewParamsVoice = "alloy"
	AudioSpeechNewParamsVoiceAsh     AudioSpeechNewParamsVoice = "ash"
	AudioSpeechNewParamsVoiceBallad  AudioSpeechNewParamsVoice = "ballad"
	AudioSpeechNewParamsVoiceCoral   AudioSpeechNewParamsVoice = "coral"
	AudioSpeechNewParamsVoiceEcho    AudioSpeechNewParamsVoice = "echo"
	AudioSpeechNewParamsVoiceFable   AudioSpeechNewParamsVoice = "fable"
	AudioSpeechNewParamsVoiceOnyx    AudioSpeechNewParamsVoice = "onyx"
	AudioSpeechNewParamsVoiceNova    AudioSpeechNewParamsVoice = "nova"
	AudioSpeechNewParamsVoiceSage    AudioSpeechNewParamsVoice = "sage"
	AudioSpeechNewParamsVoiceShimmer AudioSpeechNewParamsVoice = "shimmer"
	AudioSpeechNewParamsVoiceVerse   AudioSpeechNewParamsVoice = "verse"
)

type AudioSpeechService

type AudioSpeechService struct {
	Options []option.RequestOption
}

AudioSpeechService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAudioSpeechService method instead.

func NewAudioSpeechService

func NewAudioSpeechService(opts ...option.RequestOption) (r AudioSpeechService)

NewAudioSpeechService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AudioSpeechService) New

Generates audio from the input text.

type AudioTranscriptionNewParams

type AudioTranscriptionNewParams struct {
	// The audio file object (not file name) to transcribe, in one of these formats:
	// flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
	File io.Reader `json:"file,omitzero,required" format:"binary"`
	// ID of the model to use. The options are `gpt-4o-transcribe`,
	// `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
	// Whisper V2 model).
	Model AudioModel `json:"model,omitzero,required"`
	// The language of the input audio. Supplying the input language in
	// [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
	// format will improve accuracy and latency.
	Language param.Opt[string] `json:"language,omitzero"`
	// An optional text to guide the model's style or continue a previous audio
	// segment. The
	// [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
	// should match the audio language.
	Prompt param.Opt[string] `json:"prompt,omitzero"`
	// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
	// output more random, while lower values like 0.2 will make it more focused and
	// deterministic. If set to 0, the model will use
	// [log probability](https://en.wikipedia.org/wiki/Log_probability) to
	// automatically increase the temperature until certain thresholds are hit.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// Controls how the audio is cut into chunks. When set to `"auto"`, the server
	// first normalizes loudness and then uses voice activity detection (VAD) to choose
	// boundaries. `server_vad` object can be provided to tweak VAD detection
	// parameters manually. If unset, the audio is transcribed as a single block.
	ChunkingStrategy AudioTranscriptionNewParamsChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
	// Additional information to include in the transcription response. `logprobs` will
	// return the log probabilities of the tokens in the response to understand the
	// model's confidence in the transcription. `logprobs` only works with
	// response_format set to `json` and only with the models `gpt-4o-transcribe` and
	// `gpt-4o-mini-transcribe`.
	Include []TranscriptionInclude `json:"include,omitzero"`
	// The format of the output, in one of these options: `json`, `text`, `srt`,
	// `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
	// the only supported format is `json`.
	//
	// Any of "json", "text", "srt", "verbose_json", "vtt".
	ResponseFormat AudioResponseFormat `json:"response_format,omitzero"`
	// The timestamp granularities to populate for this transcription.
	// `response_format` must be set `verbose_json` to use timestamp granularities.
	// Either or both of these options are supported: `word`, or `segment`. Note: There
	// is no additional latency for segment timestamps, but generating word timestamps
	// incurs additional latency.
	//
	// Any of "word", "segment".
	TimestampGranularities []string `json:"timestamp_granularities,omitzero"`
	// contains filtered or unexported fields
}

func (AudioTranscriptionNewParams) MarshalMultipart

func (r AudioTranscriptionNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type AudioTranscriptionNewParamsChunkingStrategyUnion

type AudioTranscriptionNewParamsChunkingStrategyUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto                                            constant.Auto                                         `json:",omitzero,inline"`
	OfAudioTranscriptionNewsChunkingStrategyVadConfig *AudioTranscriptionNewParamsChunkingStrategyVadConfig `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (AudioTranscriptionNewParamsChunkingStrategyUnion) MarshalJSON

func (*AudioTranscriptionNewParamsChunkingStrategyUnion) UnmarshalJSON

type AudioTranscriptionNewParamsChunkingStrategyVadConfig

type AudioTranscriptionNewParamsChunkingStrategyVadConfig struct {
	// Must be set to `server_vad` to enable manual chunking using server side VAD.
	//
	// Any of "server_vad".
	Type string `json:"type,omitzero,required"`
	// Amount of audio to include before the VAD detected speech (in milliseconds).
	PrefixPaddingMs param.Opt[int64] `json:"prefix_padding_ms,omitzero"`
	// Duration of silence to detect speech stop (in milliseconds). With shorter values
	// the model will respond more quickly, but may jump in on short pauses from the
	// user.
	SilenceDurationMs param.Opt[int64] `json:"silence_duration_ms,omitzero"`
	// Sensitivity threshold (0.0 to 1.0) for voice activity detection. A higher
	// threshold will require louder audio to activate the model, and thus might
	// perform better in noisy environments.
	Threshold param.Opt[float64] `json:"threshold,omitzero"`
	// contains filtered or unexported fields
}

The property Type is required.

func (AudioTranscriptionNewParamsChunkingStrategyVadConfig) MarshalJSON

func (r AudioTranscriptionNewParamsChunkingStrategyVadConfig) MarshalJSON() (data []byte, err error)

func (*AudioTranscriptionNewParamsChunkingStrategyVadConfig) UnmarshalJSON

type AudioTranscriptionService

type AudioTranscriptionService struct {
	Options []option.RequestOption
}

AudioTranscriptionService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAudioTranscriptionService method instead.

func NewAudioTranscriptionService

func NewAudioTranscriptionService(opts ...option.RequestOption) (r AudioTranscriptionService)

NewAudioTranscriptionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AudioTranscriptionService) New

Transcribes audio into the input language.

func (*AudioTranscriptionService) NewStreaming

Transcribes audio into the input language.

type AudioTranslationNewParams

type AudioTranslationNewParams struct {
	// The audio file object (not file name) translate, in one of these formats: flac,
	// mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
	File io.Reader `json:"file,omitzero,required" format:"binary"`
	// ID of the model to use. Only `whisper-1` (which is powered by our open source
	// Whisper V2 model) is currently available.
	Model AudioModel `json:"model,omitzero,required"`
	// An optional text to guide the model's style or continue a previous audio
	// segment. The
	// [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
	// should be in English.
	Prompt param.Opt[string] `json:"prompt,omitzero"`
	// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
	// output more random, while lower values like 0.2 will make it more focused and
	// deterministic. If set to 0, the model will use
	// [log probability](https://en.wikipedia.org/wiki/Log_probability) to
	// automatically increase the temperature until certain thresholds are hit.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// The format of the output, in one of these options: `json`, `text`, `srt`,
	// `verbose_json`, or `vtt`.
	//
	// Any of "json", "text", "srt", "verbose_json", "vtt".
	ResponseFormat AudioTranslationNewParamsResponseFormat `json:"response_format,omitzero"`
	// contains filtered or unexported fields
}

func (AudioTranslationNewParams) MarshalMultipart

func (r AudioTranslationNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type AudioTranslationNewParamsResponseFormat

type AudioTranslationNewParamsResponseFormat string

The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.

const (
	AudioTranslationNewParamsResponseFormatJSON        AudioTranslationNewParamsResponseFormat = "json"
	AudioTranslationNewParamsResponseFormatText        AudioTranslationNewParamsResponseFormat = "text"
	AudioTranslationNewParamsResponseFormatSRT         AudioTranslationNewParamsResponseFormat = "srt"
	AudioTranslationNewParamsResponseFormatVerboseJSON AudioTranslationNewParamsResponseFormat = "verbose_json"
	AudioTranslationNewParamsResponseFormatVTT         AudioTranslationNewParamsResponseFormat = "vtt"
)

type AudioTranslationService

type AudioTranslationService struct {
	Options []option.RequestOption
}

AudioTranslationService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAudioTranslationService method instead.

func NewAudioTranslationService

func NewAudioTranslationService(opts ...option.RequestOption) (r AudioTranslationService)

NewAudioTranslationService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AudioTranslationService) New

Translates audio into English.

type AutoFileChunkingStrategyParam

type AutoFileChunkingStrategyParam struct {
	// Always `auto`.
	Type constant.Auto `json:"type,required"`
	// contains filtered or unexported fields
}

The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.

This struct has a constant value, construct it with NewAutoFileChunkingStrategyParam.

func NewAutoFileChunkingStrategyParam

func NewAutoFileChunkingStrategyParam() AutoFileChunkingStrategyParam

func (AutoFileChunkingStrategyParam) MarshalJSON

func (r AutoFileChunkingStrategyParam) MarshalJSON() (data []byte, err error)

func (*AutoFileChunkingStrategyParam) UnmarshalJSON

func (r *AutoFileChunkingStrategyParam) UnmarshalJSON(data []byte) error

type Batch

type Batch struct {
	ID string `json:"id,required"`
	// The time frame within which the batch should be processed.
	CompletionWindow string `json:"completion_window,required"`
	// The Unix timestamp (in seconds) for when the batch was created.
	CreatedAt int64 `json:"created_at,required"`
	// The OpenAI API endpoint used by the batch.
	Endpoint string `json:"endpoint,required"`
	// The ID of the input file for the batch.
	InputFileID string `json:"input_file_id,required"`
	// The object type, which is always `batch`.
	Object constant.Batch `json:"object,required"`
	// The current status of the batch.
	//
	// Any of "validating", "failed", "in_progress", "finalizing", "completed",
	// "expired", "cancelling", "cancelled".
	Status BatchStatus `json:"status,required"`
	// The Unix timestamp (in seconds) for when the batch was cancelled.
	CancelledAt int64 `json:"cancelled_at"`
	// The Unix timestamp (in seconds) for when the batch started cancelling.
	CancellingAt int64 `json:"cancelling_at"`
	// The Unix timestamp (in seconds) for when the batch was completed.
	CompletedAt int64 `json:"completed_at"`
	// The ID of the file containing the outputs of requests with errors.
	ErrorFileID string      `json:"error_file_id"`
	Errors      BatchErrors `json:"errors"`
	// The Unix timestamp (in seconds) for when the batch expired.
	ExpiredAt int64 `json:"expired_at"`
	// The Unix timestamp (in seconds) for when the batch will expire.
	ExpiresAt int64 `json:"expires_at"`
	// The Unix timestamp (in seconds) for when the batch failed.
	FailedAt int64 `json:"failed_at"`
	// The Unix timestamp (in seconds) for when the batch started finalizing.
	FinalizingAt int64 `json:"finalizing_at"`
	// The Unix timestamp (in seconds) for when the batch started processing.
	InProgressAt int64 `json:"in_progress_at"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,nullable"`
	// The ID of the file containing the outputs of successfully executed requests.
	OutputFileID string `json:"output_file_id"`
	// The request counts for different statuses within the batch.
	RequestCounts BatchRequestCounts `json:"request_counts"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID               respjson.Field
		CompletionWindow respjson.Field
		CreatedAt        respjson.Field
		Endpoint         respjson.Field
		InputFileID      respjson.Field
		Object           respjson.Field
		Status           respjson.Field
		CancelledAt      respjson.Field
		CancellingAt     respjson.Field
		CompletedAt      respjson.Field
		ErrorFileID      respjson.Field
		Errors           respjson.Field
		ExpiredAt        respjson.Field
		ExpiresAt        respjson.Field
		FailedAt         respjson.Field
		FinalizingAt     respjson.Field
		InProgressAt     respjson.Field
		Metadata         respjson.Field
		OutputFileID     respjson.Field
		RequestCounts    respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Batch) RawJSON

func (r Batch) RawJSON() string

Returns the unmodified JSON received from the API

func (*Batch) UnmarshalJSON

func (r *Batch) UnmarshalJSON(data []byte) error

type BatchError

type BatchError struct {
	// An error code identifying the error type.
	Code string `json:"code"`
	// The line number of the input file where the error occurred, if applicable.
	Line int64 `json:"line,nullable"`
	// A human-readable message providing more details about the error.
	Message string `json:"message"`
	// The name of the parameter that caused the error, if applicable.
	Param string `json:"param,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Line        respjson.Field
		Message     respjson.Field
		Param       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BatchError) RawJSON

func (r BatchError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BatchError) UnmarshalJSON

func (r *BatchError) UnmarshalJSON(data []byte) error

type BatchErrors

type BatchErrors struct {
	Data []BatchError `json:"data"`
	// The object type, which is always `list`.
	Object string `json:"object"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BatchErrors) RawJSON

func (r BatchErrors) RawJSON() string

Returns the unmodified JSON received from the API

func (*BatchErrors) UnmarshalJSON

func (r *BatchErrors) UnmarshalJSON(data []byte) error

type BatchListParams

type BatchListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BatchListParams) URLQuery

func (r BatchListParams) URLQuery() (v url.Values, err error)

URLQuery serializes BatchListParams's query parameters as `url.Values`.

type BatchNewParams

type BatchNewParams struct {
	// The time frame within which the batch should be processed. Currently only `24h`
	// is supported.
	//
	// Any of "24h".
	CompletionWindow BatchNewParamsCompletionWindow `json:"completion_window,omitzero,required"`
	// The endpoint to be used for all requests in the batch. Currently
	// `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions`
	// are supported. Note that `/v1/embeddings` batches are also restricted to a
	// maximum of 50,000 embedding inputs across all requests in the batch.
	//
	// Any of "/v1/responses", "/v1/chat/completions", "/v1/embeddings",
	// "/v1/completions".
	Endpoint BatchNewParamsEndpoint `json:"endpoint,omitzero,required"`
	// The ID of an uploaded file that contains requests for the new batch.
	//
	// See [upload file](https://platform.openai.com/docs/api-reference/files/create)
	// for how to upload a file.
	//
	// Your input file must be formatted as a
	// [JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
	// and must be uploaded with the purpose `batch`. The file can contain up to 50,000
	// requests, and can be up to 200 MB in size.
	InputFileID string `json:"input_file_id,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

func (BatchNewParams) MarshalJSON

func (r BatchNewParams) MarshalJSON() (data []byte, err error)

func (*BatchNewParams) UnmarshalJSON

func (r *BatchNewParams) UnmarshalJSON(data []byte) error

type BatchNewParamsCompletionWindow

type BatchNewParamsCompletionWindow string

The time frame within which the batch should be processed. Currently only `24h` is supported.

const (
	BatchNewParamsCompletionWindow24h BatchNewParamsCompletionWindow = "24h"
)

type BatchNewParamsEndpoint

type BatchNewParamsEndpoint string

The endpoint to be used for all requests in the batch. Currently `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.

const (
	BatchNewParamsEndpointV1Responses       BatchNewParamsEndpoint = "/v1/responses"
	BatchNewParamsEndpointV1ChatCompletions BatchNewParamsEndpoint = "/v1/chat/completions"
	BatchNewParamsEndpointV1Embeddings      BatchNewParamsEndpoint = "/v1/embeddings"
	BatchNewParamsEndpointV1Completions     BatchNewParamsEndpoint = "/v1/completions"
)

type BatchRequestCounts

type BatchRequestCounts struct {
	// Number of requests that have been completed successfully.
	Completed int64 `json:"completed,required"`
	// Number of requests that have failed.
	Failed int64 `json:"failed,required"`
	// Total number of requests in the batch.
	Total int64 `json:"total,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Completed   respjson.Field
		Failed      respjson.Field
		Total       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The request counts for different statuses within the batch.

func (BatchRequestCounts) RawJSON

func (r BatchRequestCounts) RawJSON() string

Returns the unmodified JSON received from the API

func (*BatchRequestCounts) UnmarshalJSON

func (r *BatchRequestCounts) UnmarshalJSON(data []byte) error

type BatchService

type BatchService struct {
	Options []option.RequestOption
}

BatchService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBatchService method instead.

func NewBatchService

func NewBatchService(opts ...option.RequestOption) (r BatchService)

NewBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BatchService) Cancel

func (r *BatchService) Cancel(ctx context.Context, batchID string, opts ...option.RequestOption) (res *Batch, err error)

Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file.

func (*BatchService) Get

func (r *BatchService) Get(ctx context.Context, batchID string, opts ...option.RequestOption) (res *Batch, err error)

Retrieves a batch.

func (*BatchService) List

func (r *BatchService) List(ctx context.Context, query BatchListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Batch], err error)

List your organization's batches.

func (*BatchService) ListAutoPaging

List your organization's batches.

func (*BatchService) New

func (r *BatchService) New(ctx context.Context, body BatchNewParams, opts ...option.RequestOption) (res *Batch, err error)

Creates and executes a batch from an uploaded file of requests

type BatchStatus

type BatchStatus string

The current status of the batch.

const (
	BatchStatusValidating BatchStatus = "validating"
	BatchStatusFailed     BatchStatus = "failed"
	BatchStatusInProgress BatchStatus = "in_progress"
	BatchStatusFinalizing BatchStatus = "finalizing"
	BatchStatusCompleted  BatchStatus = "completed"
	BatchStatusExpired    BatchStatus = "expired"
	BatchStatusCancelling BatchStatus = "cancelling"
	BatchStatusCancelled  BatchStatus = "cancelled"
)

type BetaAssistantListParams added in v1.1.0

type BetaAssistantListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A cursor for use in pagination. `before` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// starting with obj_foo, your subsequent call can include before=obj_foo in order
	// to fetch the previous page of the list.
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order BetaAssistantListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaAssistantListParams) URLQuery added in v1.1.0

func (r BetaAssistantListParams) URLQuery() (v url.Values, err error)

URLQuery serializes BetaAssistantListParams's query parameters as `url.Values`.

type BetaAssistantListParamsOrder added in v1.1.0

type BetaAssistantListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	BetaAssistantListParamsOrderAsc  BetaAssistantListParamsOrder = "asc"
	BetaAssistantListParamsOrderDesc BetaAssistantListParamsOrder = "desc"
)

type BetaAssistantNewParams added in v1.1.0

type BetaAssistantNewParams struct {
	// ID of the model to use. You can use the
	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
	// see all of your available models, or see our
	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
	// them.
	Model shared.ChatModel `json:"model,omitzero,required"`
	// The description of the assistant. The maximum length is 512 characters.
	Description param.Opt[string] `json:"description,omitzero"`
	// The system instructions that the assistant uses. The maximum length is 256,000
	// characters.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// The name of the assistant. The maximum length is 256 characters.
	Name param.Opt[string] `json:"name,omitzero"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or temperature but not both.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// **o-series models only**
	//
	// Constrains effort on reasoning for
	// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
	// supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
	// result in faster responses and fewer tokens used on reasoning in a response.
	//
	// Any of "low", "medium", "high".
	ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
	// A set of resources that are used by the assistant's tools. The resources are
	// specific to the type of tool. For example, the `code_interpreter` tool requires
	// a list of file IDs, while the `file_search` tool requires a list of vector store
	// IDs.
	ToolResources BetaAssistantNewParamsToolResources `json:"tool_resources,omitzero"`
	// Specifies the format that the model must output. Compatible with
	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
	//
	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
	// Outputs which ensures the model will match your supplied JSON schema. Learn more
	// in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
	// message the model generates is valid JSON.
	//
	// **Important:** when using JSON mode, you **must** also instruct the model to
	// produce JSON yourself via a system or user message. Without this, the model may
	// generate an unending stream of whitespace until the generation reaches the token
	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
	// the message content may be partially cut off if `finish_reason="length"`, which
	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
	// max context length.
	ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
	// A list of tool enabled on the assistant. There can be a maximum of 128 tools per
	// assistant. Tools can be of types `code_interpreter`, `file_search`, or
	// `function`.
	Tools []AssistantToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (BetaAssistantNewParams) MarshalJSON added in v1.1.0

func (r BetaAssistantNewParams) MarshalJSON() (data []byte, err error)

func (*BetaAssistantNewParams) UnmarshalJSON added in v1.1.0

func (r *BetaAssistantNewParams) UnmarshalJSON(data []byte) error

type BetaAssistantNewParamsToolResources added in v1.1.0

type BetaAssistantNewParamsToolResources struct {
	CodeInterpreter BetaAssistantNewParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
	FileSearch      BetaAssistantNewParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
	// contains filtered or unexported fields
}

A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (BetaAssistantNewParamsToolResources) MarshalJSON added in v1.1.0

func (r BetaAssistantNewParamsToolResources) MarshalJSON() (data []byte, err error)

func (*BetaAssistantNewParamsToolResources) UnmarshalJSON added in v1.1.0

func (r *BetaAssistantNewParamsToolResources) UnmarshalJSON(data []byte) error

type BetaAssistantNewParamsToolResourcesCodeInterpreter added in v1.1.0

type BetaAssistantNewParamsToolResourcesCodeInterpreter struct {
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
	// available to the `code_interpreter` tool. There can be a maximum of 20 files
	// associated with the tool.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaAssistantNewParamsToolResourcesCodeInterpreter) MarshalJSON added in v1.1.0

func (r BetaAssistantNewParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error)

func (*BetaAssistantNewParamsToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearch added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearch struct {
	// The
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this assistant. There can be a maximum of 1 vector store attached to
	// the assistant.
	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
	// A helper to create a
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// with file_ids and attach it to this assistant. There can be a maximum of 1
	// vector store attached to the assistant.
	VectorStores []BetaAssistantNewParamsToolResourcesFileSearchVectorStore `json:"vector_stores,omitzero"`
	// contains filtered or unexported fields
}

func (BetaAssistantNewParamsToolResourcesFileSearch) MarshalJSON added in v1.1.0

func (r BetaAssistantNewParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error)

func (*BetaAssistantNewParamsToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

func (r *BetaAssistantNewParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error

type BetaAssistantNewParamsToolResourcesFileSearchVectorStore added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStore struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
	// strategy.
	ChunkingStrategy BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
	// add to the vector store. There can be a maximum of 10000 files in a vector
	// store.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaAssistantNewParamsToolResourcesFileSearchVectorStore) MarshalJSON added in v1.1.0

func (*BetaAssistantNewParamsToolResourcesFileSearchVectorStore) UnmarshalJSON added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct {
	// Always `auto`.
	Type constant.Auto `json:"type,required"`
	// contains filtered or unexported fields
}

The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.

This struct has a constant value, construct it with NewBetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto.

func NewBetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto added in v1.1.0

func NewBetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto() BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto

func (BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) MarshalJSON added in v1.1.0

func (*BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) UnmarshalJSON added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct {
	Static BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic `json:"static,omitzero,required"`
	// Always `static`.
	//
	// This field can be elided, and will marshal its zero value as "static".
	Type constant.Static `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Static, Type are required.

func (BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) MarshalJSON added in v1.1.0

func (*BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) UnmarshalJSON added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic struct {
	// The number of tokens that overlap between chunks. The default value is `400`.
	//
	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
	// The maximum number of tokens in each chunk. The default value is `800`. The
	// minimum value is `100` and the maximum value is `4096`.
	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
	// contains filtered or unexported fields
}

The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.

func (BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) MarshalJSON added in v1.1.0

func (*BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) UnmarshalJSON added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion added in v1.1.0

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion struct {
	OfAuto   *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto   `json:",omitzero,inline"`
	OfStatic *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetStatic added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) MarshalJSON added in v1.1.0

func (*BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) UnmarshalJSON added in v1.1.0

type BetaAssistantService added in v1.1.0

type BetaAssistantService struct {
	Options []option.RequestOption
}

BetaAssistantService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBetaAssistantService method instead.

func NewBetaAssistantService added in v1.1.0

func NewBetaAssistantService(opts ...option.RequestOption) (r BetaAssistantService)

NewBetaAssistantService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaAssistantService) Delete added in v1.1.0

func (r *BetaAssistantService) Delete(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *AssistantDeleted, err error)

Delete an assistant.

func (*BetaAssistantService) Get added in v1.1.0

func (r *BetaAssistantService) Get(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *Assistant, err error)

Retrieves an assistant.

func (*BetaAssistantService) List added in v1.1.0

Returns a list of assistants.

func (*BetaAssistantService) ListAutoPaging added in v1.1.0

Returns a list of assistants.

func (*BetaAssistantService) New added in v1.1.0

Create an assistant with a model and instructions.

func (*BetaAssistantService) Update added in v1.1.0

func (r *BetaAssistantService) Update(ctx context.Context, assistantID string, body BetaAssistantUpdateParams, opts ...option.RequestOption) (res *Assistant, err error)

Modifies an assistant.

type BetaAssistantUpdateParams added in v1.1.0

type BetaAssistantUpdateParams struct {
	// The description of the assistant. The maximum length is 512 characters.
	Description param.Opt[string] `json:"description,omitzero"`
	// The system instructions that the assistant uses. The maximum length is 256,000
	// characters.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// The name of the assistant. The maximum length is 256 characters.
	Name param.Opt[string] `json:"name,omitzero"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or temperature but not both.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// **o-series models only**
	//
	// Constrains effort on reasoning for
	// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
	// supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
	// result in faster responses and fewer tokens used on reasoning in a response.
	//
	// Any of "low", "medium", "high".
	ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
	// A set of resources that are used by the assistant's tools. The resources are
	// specific to the type of tool. For example, the `code_interpreter` tool requires
	// a list of file IDs, while the `file_search` tool requires a list of vector store
	// IDs.
	ToolResources BetaAssistantUpdateParamsToolResources `json:"tool_resources,omitzero"`
	// ID of the model to use. You can use the
	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
	// see all of your available models, or see our
	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
	// them.
	Model BetaAssistantUpdateParamsModel `json:"model,omitzero"`
	// Specifies the format that the model must output. Compatible with
	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
	//
	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
	// Outputs which ensures the model will match your supplied JSON schema. Learn more
	// in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
	// message the model generates is valid JSON.
	//
	// **Important:** when using JSON mode, you **must** also instruct the model to
	// produce JSON yourself via a system or user message. Without this, the model may
	// generate an unending stream of whitespace until the generation reaches the token
	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
	// the message content may be partially cut off if `finish_reason="length"`, which
	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
	// max context length.
	ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
	// A list of tool enabled on the assistant. There can be a maximum of 128 tools per
	// assistant. Tools can be of types `code_interpreter`, `file_search`, or
	// `function`.
	Tools []AssistantToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (BetaAssistantUpdateParams) MarshalJSON added in v1.1.0

func (r BetaAssistantUpdateParams) MarshalJSON() (data []byte, err error)

func (*BetaAssistantUpdateParams) UnmarshalJSON added in v1.1.0

func (r *BetaAssistantUpdateParams) UnmarshalJSON(data []byte) error

type BetaAssistantUpdateParamsModel added in v1.1.0

type BetaAssistantUpdateParamsModel string

ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

const (
	BetaAssistantUpdateParamsModelGPT4_1                  BetaAssistantUpdateParamsModel = "gpt-4.1"
	BetaAssistantUpdateParamsModelGPT4_1Mini              BetaAssistantUpdateParamsModel = "gpt-4.1-mini"
	BetaAssistantUpdateParamsModelGPT4_1Nano              BetaAssistantUpdateParamsModel = "gpt-4.1-nano"
	BetaAssistantUpdateParamsModelGPT4_1_2025_04_14       BetaAssistantUpdateParamsModel = "gpt-4.1-2025-04-14"
	BetaAssistantUpdateParamsModelGPT4_1Mini2025_04_14    BetaAssistantUpdateParamsModel = "gpt-4.1-mini-2025-04-14"
	BetaAssistantUpdateParamsModelGPT4_1Nano2025_04_14    BetaAssistantUpdateParamsModel = "gpt-4.1-nano-2025-04-14"
	BetaAssistantUpdateParamsModelO3Mini                  BetaAssistantUpdateParamsModel = "o3-mini"
	BetaAssistantUpdateParamsModelO3Mini2025_01_31        BetaAssistantUpdateParamsModel = "o3-mini-2025-01-31"
	BetaAssistantUpdateParamsModelO1                      BetaAssistantUpdateParamsModel = "o1"
	BetaAssistantUpdateParamsModelO1_2024_12_17           BetaAssistantUpdateParamsModel = "o1-2024-12-17"
	BetaAssistantUpdateParamsModelGPT4o                   BetaAssistantUpdateParamsModel = "gpt-4o"
	BetaAssistantUpdateParamsModelGPT4o2024_11_20         BetaAssistantUpdateParamsModel = "gpt-4o-2024-11-20"
	BetaAssistantUpdateParamsModelGPT4o2024_08_06         BetaAssistantUpdateParamsModel = "gpt-4o-2024-08-06"
	BetaAssistantUpdateParamsModelGPT4o2024_05_13         BetaAssistantUpdateParamsModel = "gpt-4o-2024-05-13"
	BetaAssistantUpdateParamsModelGPT4oMini               BetaAssistantUpdateParamsModel = "gpt-4o-mini"
	BetaAssistantUpdateParamsModelGPT4oMini2024_07_18     BetaAssistantUpdateParamsModel = "gpt-4o-mini-2024-07-18"
	BetaAssistantUpdateParamsModelGPT4_5Preview           BetaAssistantUpdateParamsModel = "gpt-4.5-preview"
	BetaAssistantUpdateParamsModelGPT4_5Preview2025_02_27 BetaAssistantUpdateParamsModel = "gpt-4.5-preview-2025-02-27"
	BetaAssistantUpdateParamsModelGPT4Turbo               BetaAssistantUpdateParamsModel = "gpt-4-turbo"
	BetaAssistantUpdateParamsModelGPT4Turbo2024_04_09     BetaAssistantUpdateParamsModel = "gpt-4-turbo-2024-04-09"
	BetaAssistantUpdateParamsModelGPT4_0125Preview        BetaAssistantUpdateParamsModel = "gpt-4-0125-preview"
	BetaAssistantUpdateParamsModelGPT4TurboPreview        BetaAssistantUpdateParamsModel = "gpt-4-turbo-preview"
	BetaAssistantUpdateParamsModelGPT4_1106Preview        BetaAssistantUpdateParamsModel = "gpt-4-1106-preview"
	BetaAssistantUpdateParamsModelGPT4VisionPreview       BetaAssistantUpdateParamsModel = "gpt-4-vision-preview"
	BetaAssistantUpdateParamsModelGPT4                    BetaAssistantUpdateParamsModel = "gpt-4"
	BetaAssistantUpdateParamsModelGPT4_0314               BetaAssistantUpdateParamsModel = "gpt-4-0314"
	BetaAssistantUpdateParamsModelGPT4_0613               BetaAssistantUpdateParamsModel = "gpt-4-0613"
	BetaAssistantUpdateParamsModelGPT4_32k                BetaAssistantUpdateParamsModel = "gpt-4-32k"
	BetaAssistantUpdateParamsModelGPT4_32k0314            BetaAssistantUpdateParamsModel = "gpt-4-32k-0314"
	BetaAssistantUpdateParamsModelGPT4_32k0613            BetaAssistantUpdateParamsModel = "gpt-4-32k-0613"
	BetaAssistantUpdateParamsModelGPT3_5Turbo             BetaAssistantUpdateParamsModel = "gpt-3.5-turbo"
	BetaAssistantUpdateParamsModelGPT3_5Turbo16k          BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-16k"
	BetaAssistantUpdateParamsModelGPT3_5Turbo0613         BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-0613"
	BetaAssistantUpdateParamsModelGPT3_5Turbo1106         BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-1106"
	BetaAssistantUpdateParamsModelGPT3_5Turbo0125         BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-0125"
	BetaAssistantUpdateParamsModelGPT3_5Turbo16k0613      BetaAssistantUpdateParamsModel = "gpt-3.5-turbo-16k-0613"
)

type BetaAssistantUpdateParamsToolResources added in v1.1.0

type BetaAssistantUpdateParamsToolResources struct {
	CodeInterpreter BetaAssistantUpdateParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
	FileSearch      BetaAssistantUpdateParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
	// contains filtered or unexported fields
}

A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (BetaAssistantUpdateParamsToolResources) MarshalJSON added in v1.1.0

func (r BetaAssistantUpdateParamsToolResources) MarshalJSON() (data []byte, err error)

func (*BetaAssistantUpdateParamsToolResources) UnmarshalJSON added in v1.1.0

func (r *BetaAssistantUpdateParamsToolResources) UnmarshalJSON(data []byte) error

type BetaAssistantUpdateParamsToolResourcesCodeInterpreter added in v1.1.0

type BetaAssistantUpdateParamsToolResourcesCodeInterpreter struct {
	// Overrides the list of
	// [file](https://platform.openai.com/docs/api-reference/files) IDs made available
	// to the `code_interpreter` tool. There can be a maximum of 20 files associated
	// with the tool.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaAssistantUpdateParamsToolResourcesCodeInterpreter) MarshalJSON added in v1.1.0

func (*BetaAssistantUpdateParamsToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

type BetaAssistantUpdateParamsToolResourcesFileSearch added in v1.1.0

type BetaAssistantUpdateParamsToolResourcesFileSearch struct {
	// Overrides the
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this assistant. There can be a maximum of 1 vector store attached to
	// the assistant.
	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaAssistantUpdateParamsToolResourcesFileSearch) MarshalJSON added in v1.1.0

func (r BetaAssistantUpdateParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error)

func (*BetaAssistantUpdateParamsToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

type BetaService

type BetaService struct {
	Options    []option.RequestOption
	Assistants BetaAssistantService
	// Deprecated: The Assistants API is deprecated in favor of the Responses API
	Threads BetaThreadService
}

BetaService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBetaService method instead.

func NewBetaService

func NewBetaService(opts ...option.RequestOption) (r BetaService)

NewBetaService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type BetaThreadMessageListParams added in v1.1.0

type BetaThreadMessageListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A cursor for use in pagination. `before` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// starting with obj_foo, your subsequent call can include before=obj_foo in order
	// to fetch the previous page of the list.
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Filter messages by the run ID that generated them.
	RunID param.Opt[string] `query:"run_id,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order BetaThreadMessageListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaThreadMessageListParams) URLQuery added in v1.1.0

func (r BetaThreadMessageListParams) URLQuery() (v url.Values, err error)

URLQuery serializes BetaThreadMessageListParams's query parameters as `url.Values`.

type BetaThreadMessageListParamsOrder added in v1.1.0

type BetaThreadMessageListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	BetaThreadMessageListParamsOrderAsc  BetaThreadMessageListParamsOrder = "asc"
	BetaThreadMessageListParamsOrderDesc BetaThreadMessageListParamsOrder = "desc"
)

type BetaThreadMessageNewParams added in v1.1.0

type BetaThreadMessageNewParams struct {
	// The text contents of the message.
	Content BetaThreadMessageNewParamsContentUnion `json:"content,omitzero,required"`
	// The role of the entity that is creating the message. Allowed values include:
	//
	//   - `user`: Indicates the message is sent by an actual user and should be used in
	//     most cases to represent user-generated messages.
	//   - `assistant`: Indicates the message is generated by the assistant. Use this
	//     value to insert messages from the assistant into the conversation.
	//
	// Any of "user", "assistant".
	Role BetaThreadMessageNewParamsRole `json:"role,omitzero,required"`
	// A list of files attached to the message, and the tools they should be added to.
	Attachments []BetaThreadMessageNewParamsAttachment `json:"attachments,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadMessageNewParams) MarshalJSON added in v1.1.0

func (r BetaThreadMessageNewParams) MarshalJSON() (data []byte, err error)

func (*BetaThreadMessageNewParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadMessageNewParams) UnmarshalJSON(data []byte) error

type BetaThreadMessageNewParamsAttachment added in v1.1.0

type BetaThreadMessageNewParamsAttachment struct {
	// The ID of the file to attach to the message.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The tools to add this file to.
	Tools []BetaThreadMessageNewParamsAttachmentToolUnion `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadMessageNewParamsAttachment) MarshalJSON added in v1.1.0

func (r BetaThreadMessageNewParamsAttachment) MarshalJSON() (data []byte, err error)

func (*BetaThreadMessageNewParamsAttachment) UnmarshalJSON added in v1.1.0

func (r *BetaThreadMessageNewParamsAttachment) UnmarshalJSON(data []byte) error

type BetaThreadMessageNewParamsAttachmentToolFileSearch added in v1.1.0

type BetaThreadMessageNewParamsAttachmentToolFileSearch struct {
	// The type of tool being defined: `file_search`
	Type constant.FileSearch `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaThreadMessageNewParamsAttachmentToolFileSearch.

func NewBetaThreadMessageNewParamsAttachmentToolFileSearch added in v1.1.0

func NewBetaThreadMessageNewParamsAttachmentToolFileSearch() BetaThreadMessageNewParamsAttachmentToolFileSearch

func (BetaThreadMessageNewParamsAttachmentToolFileSearch) MarshalJSON added in v1.1.0

func (r BetaThreadMessageNewParamsAttachmentToolFileSearch) MarshalJSON() (data []byte, err error)

func (*BetaThreadMessageNewParamsAttachmentToolFileSearch) UnmarshalJSON added in v1.1.0

type BetaThreadMessageNewParamsAttachmentToolUnion added in v1.1.0

type BetaThreadMessageNewParamsAttachmentToolUnion struct {
	OfCodeInterpreter *CodeInterpreterToolParam                           `json:",omitzero,inline"`
	OfFileSearch      *BetaThreadMessageNewParamsAttachmentToolFileSearch `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadMessageNewParamsAttachmentToolUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadMessageNewParamsAttachmentToolUnion) MarshalJSON added in v1.1.0

func (*BetaThreadMessageNewParamsAttachmentToolUnion) UnmarshalJSON added in v1.1.0

func (u *BetaThreadMessageNewParamsAttachmentToolUnion) UnmarshalJSON(data []byte) error

type BetaThreadMessageNewParamsContentUnion added in v1.1.0

type BetaThreadMessageNewParamsContentUnion struct {
	OfString              param.Opt[string]              `json:",omitzero,inline"`
	OfArrayOfContentParts []MessageContentPartParamUnion `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadMessageNewParamsContentUnion) MarshalJSON added in v1.1.0

func (u BetaThreadMessageNewParamsContentUnion) MarshalJSON() ([]byte, error)

func (*BetaThreadMessageNewParamsContentUnion) UnmarshalJSON added in v1.1.0

func (u *BetaThreadMessageNewParamsContentUnion) UnmarshalJSON(data []byte) error

type BetaThreadMessageNewParamsRole added in v1.1.0

type BetaThreadMessageNewParamsRole string

The role of the entity that is creating the message. Allowed values include:

  • `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.
  • `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.
const (
	BetaThreadMessageNewParamsRoleUser      BetaThreadMessageNewParamsRole = "user"
	BetaThreadMessageNewParamsRoleAssistant BetaThreadMessageNewParamsRole = "assistant"
)

type BetaThreadMessageService deprecated added in v1.1.0

type BetaThreadMessageService struct {
	Options []option.RequestOption
}

BetaThreadMessageService contains methods and other services that help with interacting with the openai API.

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

func NewBetaThreadMessageService added in v1.1.0

func NewBetaThreadMessageService(opts ...option.RequestOption) (r BetaThreadMessageService)

NewBetaThreadMessageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaThreadMessageService) Delete deprecated added in v1.1.0

func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *MessageDeleted, err error)

Deletes a message.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadMessageService) Get deprecated added in v1.1.0

func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *Message, err error)

Retrieve a message.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadMessageService) List deprecated added in v1.1.0

Returns a list of messages for a given thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadMessageService) ListAutoPaging deprecated added in v1.1.0

Returns a list of messages for a given thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadMessageService) New deprecated added in v1.1.0

Create a message.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadMessageService) Update deprecated added in v1.1.0

func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string, messageID string, body BetaThreadMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error)

Modifies a message.

Deprecated: The Assistants API is deprecated in favor of the Responses API

type BetaThreadMessageUpdateParams added in v1.1.0

type BetaThreadMessageUpdateParams struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadMessageUpdateParams) MarshalJSON added in v1.1.0

func (r BetaThreadMessageUpdateParams) MarshalJSON() (data []byte, err error)

func (*BetaThreadMessageUpdateParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadMessageUpdateParams) UnmarshalJSON(data []byte) error

type BetaThreadNewAndRunParams added in v1.1.0

type BetaThreadNewAndRunParams struct {
	// The ID of the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
	// execute this run.
	AssistantID string `json:"assistant_id,required"`
	// Override the default system message of the assistant. This is useful for
	// modifying the behavior on a per-run basis.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// The maximum number of completion tokens that may be used over the course of the
	// run. The run will make a best effort to use only the number of completion tokens
	// specified, across multiple turns of the run. If the run exceeds the number of
	// completion tokens specified, the run will end with status `incomplete`. See
	// `incomplete_details` for more info.
	MaxCompletionTokens param.Opt[int64] `json:"max_completion_tokens,omitzero"`
	// The maximum number of prompt tokens that may be used over the course of the run.
	// The run will make a best effort to use only the number of prompt tokens
	// specified, across multiple turns of the run. If the run exceeds the number of
	// prompt tokens specified, the run will end with status `incomplete`. See
	// `incomplete_details` for more info.
	MaxPromptTokens param.Opt[int64] `json:"max_prompt_tokens,omitzero"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or temperature but not both.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// Whether to enable
	// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
	// during tool use.
	ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
	// be used to execute this run. If a value is provided here, it will override the
	// model associated with the assistant. If not, the model associated with the
	// assistant will be used.
	Model shared.ChatModel `json:"model,omitzero"`
	// A set of resources that are used by the assistant's tools. The resources are
	// specific to the type of tool. For example, the `code_interpreter` tool requires
	// a list of file IDs, while the `file_search` tool requires a list of vector store
	// IDs.
	ToolResources BetaThreadNewAndRunParamsToolResources `json:"tool_resources,omitzero"`
	// Override the tools the assistant can use for this run. This is useful for
	// modifying the behavior on a per-run basis.
	Tools []AssistantToolUnionParam `json:"tools,omitzero"`
	// Controls for how a thread will be truncated prior to the run. Use this to
	// control the intial context window of the run.
	TruncationStrategy BetaThreadNewAndRunParamsTruncationStrategy `json:"truncation_strategy,omitzero"`
	// Specifies the format that the model must output. Compatible with
	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
	//
	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
	// Outputs which ensures the model will match your supplied JSON schema. Learn more
	// in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
	// message the model generates is valid JSON.
	//
	// **Important:** when using JSON mode, you **must** also instruct the model to
	// produce JSON yourself via a system or user message. Without this, the model may
	// generate an unending stream of whitespace until the generation reaches the token
	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
	// the message content may be partially cut off if `finish_reason="length"`, which
	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
	// max context length.
	ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
	// Options to create a new thread. If no thread is provided when running a request,
	// an empty thread will be created.
	Thread BetaThreadNewAndRunParamsThread `json:"thread,omitzero"`
	// Controls which (if any) tool is called by the model. `none` means the model will
	// not call any tools and instead generates a message. `auto` is the default value
	// and means the model can pick between generating a message or calling one or more
	// tools. `required` means the model must call one or more tools before responding
	// to the user. Specifying a particular tool like `{"type": "file_search"}` or
	// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
	// call that tool.
	ToolChoice AssistantToolChoiceOptionUnionParam `json:"tool_choice,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewAndRunParams) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParams) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewAndRunParams) UnmarshalJSON(data []byte) error

type BetaThreadNewAndRunParamsThread added in v1.1.0

type BetaThreadNewAndRunParamsThread struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// A set of resources that are made available to the assistant's tools in this
	// thread. The resources are specific to the type of tool. For example, the
	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
	// tool requires a list of vector store IDs.
	ToolResources BetaThreadNewAndRunParamsThreadToolResources `json:"tool_resources,omitzero"`
	// A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
	// start the thread with.
	Messages []BetaThreadNewAndRunParamsThreadMessage `json:"messages,omitzero"`
	// contains filtered or unexported fields
}

Options to create a new thread. If no thread is provided when running a request, an empty thread will be created.

func (BetaThreadNewAndRunParamsThread) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParamsThread) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParamsThread) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewAndRunParamsThread) UnmarshalJSON(data []byte) error

type BetaThreadNewAndRunParamsThreadMessage added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessage struct {
	// The text contents of the message.
	Content BetaThreadNewAndRunParamsThreadMessageContentUnion `json:"content,omitzero,required"`
	// The role of the entity that is creating the message. Allowed values include:
	//
	//   - `user`: Indicates the message is sent by an actual user and should be used in
	//     most cases to represent user-generated messages.
	//   - `assistant`: Indicates the message is generated by the assistant. Use this
	//     value to insert messages from the assistant into the conversation.
	//
	// Any of "user", "assistant".
	Role string `json:"role,omitzero,required"`
	// A list of files attached to the message, and the tools they should be added to.
	Attachments []BetaThreadNewAndRunParamsThreadMessageAttachment `json:"attachments,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

The properties Content, Role are required.

func (BetaThreadNewAndRunParamsThreadMessage) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParamsThreadMessage) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParamsThreadMessage) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewAndRunParamsThreadMessage) UnmarshalJSON(data []byte) error

type BetaThreadNewAndRunParamsThreadMessageAttachment added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessageAttachment struct {
	// The ID of the file to attach to the message.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The tools to add this file to.
	Tools []BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewAndRunParamsThreadMessageAttachment) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParamsThreadMessageAttachment) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParamsThreadMessageAttachment) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch struct {
	// The type of tool being defined: `file_search`
	Type constant.FileSearch `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch.

func NewBetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch added in v1.1.0

func NewBetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch() BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch

func (BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion struct {
	OfCodeInterpreter *CodeInterpreterToolParam                                       `json:",omitzero,inline"`
	OfFileSearch      *BetaThreadNewAndRunParamsThreadMessageAttachmentToolFileSearch `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadMessageAttachmentToolUnion) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessageContentUnion added in v1.1.0

type BetaThreadNewAndRunParamsThreadMessageContentUnion struct {
	OfString              param.Opt[string]              `json:",omitzero,inline"`
	OfArrayOfContentParts []MessageContentPartParamUnion `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadNewAndRunParamsThreadMessageContentUnion) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadMessageContentUnion) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResources added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResources struct {
	CodeInterpreter BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
	FileSearch      BetaThreadNewAndRunParamsThreadToolResourcesFileSearch      `json:"file_search,omitzero"`
	// contains filtered or unexported fields
}

A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (BetaThreadNewAndRunParamsThreadToolResources) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParamsThreadToolResources) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParamsThreadToolResources) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewAndRunParamsThreadToolResources) UnmarshalJSON(data []byte) error

type BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter struct {
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
	// available to the `code_interpreter` tool. There can be a maximum of 20 files
	// associated with the tool.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearch added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearch struct {
	// The
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this thread. There can be a maximum of 1 vector store attached to
	// the thread.
	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
	// A helper to create a
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// with file_ids and attach it to this thread. There can be a maximum of 1 vector
	// store attached to the thread.
	VectorStores []BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore `json:"vector_stores,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearch) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
	// strategy.
	ChunkingStrategy BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
	// add to the vector store. There can be a maximum of 10000 files in a vector
	// store.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStore) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct {
	// Always `auto`.
	Type constant.Auto `json:"type,required"`
	// contains filtered or unexported fields
}

The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.

This struct has a constant value, construct it with NewBetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto.

func NewBetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto added in v1.1.0

func NewBetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto() BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct {
	Static BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic `json:"static,omitzero,required"`
	// Always `static`.
	//
	// This field can be elided, and will marshal its zero value as "static".
	Type constant.Static `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Static, Type are required.

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic struct {
	// The number of tokens that overlap between chunks. The default value is `400`.
	//
	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
	// The maximum number of tokens in each chunk. The default value is `800`. The
	// minimum value is `100` and the maximum value is `4096`.
	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
	// contains filtered or unexported fields
}

The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion added in v1.1.0

type BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion struct {
	OfAuto   *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyAuto   `json:",omitzero,inline"`
	OfStatic *BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyStatic `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetStatic added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsThreadToolResourcesFileSearchVectorStoreChunkingStrategyUnion) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsToolResources added in v1.1.0

type BetaThreadNewAndRunParamsToolResources struct {
	CodeInterpreter BetaThreadNewAndRunParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
	FileSearch      BetaThreadNewAndRunParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
	// contains filtered or unexported fields
}

A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (BetaThreadNewAndRunParamsToolResources) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParamsToolResources) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParamsToolResources) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewAndRunParamsToolResources) UnmarshalJSON(data []byte) error

type BetaThreadNewAndRunParamsToolResourcesCodeInterpreter added in v1.1.0

type BetaThreadNewAndRunParamsToolResourcesCodeInterpreter struct {
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
	// available to the `code_interpreter` tool. There can be a maximum of 20 files
	// associated with the tool.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewAndRunParamsToolResourcesCodeInterpreter) MarshalJSON added in v1.1.0

func (*BetaThreadNewAndRunParamsToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsToolResourcesFileSearch added in v1.1.0

type BetaThreadNewAndRunParamsToolResourcesFileSearch struct {
	// The ID of the
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this assistant. There can be a maximum of 1 vector store attached to
	// the assistant.
	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewAndRunParamsToolResourcesFileSearch) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParamsToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

type BetaThreadNewAndRunParamsTruncationStrategy added in v1.1.0

type BetaThreadNewAndRunParamsTruncationStrategy struct {
	// The truncation strategy to use for the thread. The default is `auto`. If set to
	// `last_messages`, the thread will be truncated to the n most recent messages in
	// the thread. When set to `auto`, messages in the middle of the thread will be
	// dropped to fit the context length of the model, `max_prompt_tokens`.
	//
	// Any of "auto", "last_messages".
	Type string `json:"type,omitzero,required"`
	// The number of most recent messages from the thread when constructing the context
	// for the run.
	LastMessages param.Opt[int64] `json:"last_messages,omitzero"`
	// contains filtered or unexported fields
}

Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run.

The property Type is required.

func (BetaThreadNewAndRunParamsTruncationStrategy) MarshalJSON added in v1.1.0

func (r BetaThreadNewAndRunParamsTruncationStrategy) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewAndRunParamsTruncationStrategy) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewAndRunParamsTruncationStrategy) UnmarshalJSON(data []byte) error

type BetaThreadNewParams added in v1.1.0

type BetaThreadNewParams struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// A set of resources that are made available to the assistant's tools in this
	// thread. The resources are specific to the type of tool. For example, the
	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
	// tool requires a list of vector store IDs.
	ToolResources BetaThreadNewParamsToolResources `json:"tool_resources,omitzero"`
	// A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
	// start the thread with.
	Messages []BetaThreadNewParamsMessage `json:"messages,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewParams) MarshalJSON added in v1.1.0

func (r BetaThreadNewParams) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewParams) UnmarshalJSON(data []byte) error

type BetaThreadNewParamsMessage added in v1.1.0

type BetaThreadNewParamsMessage struct {
	// The text contents of the message.
	Content BetaThreadNewParamsMessageContentUnion `json:"content,omitzero,required"`
	// The role of the entity that is creating the message. Allowed values include:
	//
	//   - `user`: Indicates the message is sent by an actual user and should be used in
	//     most cases to represent user-generated messages.
	//   - `assistant`: Indicates the message is generated by the assistant. Use this
	//     value to insert messages from the assistant into the conversation.
	//
	// Any of "user", "assistant".
	Role string `json:"role,omitzero,required"`
	// A list of files attached to the message, and the tools they should be added to.
	Attachments []BetaThreadNewParamsMessageAttachment `json:"attachments,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

The properties Content, Role are required.

func (BetaThreadNewParamsMessage) MarshalJSON added in v1.1.0

func (r BetaThreadNewParamsMessage) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewParamsMessage) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewParamsMessage) UnmarshalJSON(data []byte) error

type BetaThreadNewParamsMessageAttachment added in v1.1.0

type BetaThreadNewParamsMessageAttachment struct {
	// The ID of the file to attach to the message.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The tools to add this file to.
	Tools []BetaThreadNewParamsMessageAttachmentToolUnion `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewParamsMessageAttachment) MarshalJSON added in v1.1.0

func (r BetaThreadNewParamsMessageAttachment) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewParamsMessageAttachment) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewParamsMessageAttachment) UnmarshalJSON(data []byte) error

type BetaThreadNewParamsMessageAttachmentToolFileSearch added in v1.1.0

type BetaThreadNewParamsMessageAttachmentToolFileSearch struct {
	// The type of tool being defined: `file_search`
	Type constant.FileSearch `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaThreadNewParamsMessageAttachmentToolFileSearch.

func NewBetaThreadNewParamsMessageAttachmentToolFileSearch added in v1.1.0

func NewBetaThreadNewParamsMessageAttachmentToolFileSearch() BetaThreadNewParamsMessageAttachmentToolFileSearch

func (BetaThreadNewParamsMessageAttachmentToolFileSearch) MarshalJSON added in v1.1.0

func (r BetaThreadNewParamsMessageAttachmentToolFileSearch) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewParamsMessageAttachmentToolFileSearch) UnmarshalJSON added in v1.1.0

type BetaThreadNewParamsMessageAttachmentToolUnion added in v1.1.0

type BetaThreadNewParamsMessageAttachmentToolUnion struct {
	OfCodeInterpreter *CodeInterpreterToolParam                           `json:",omitzero,inline"`
	OfFileSearch      *BetaThreadNewParamsMessageAttachmentToolFileSearch `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadNewParamsMessageAttachmentToolUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadNewParamsMessageAttachmentToolUnion) MarshalJSON added in v1.1.0

func (*BetaThreadNewParamsMessageAttachmentToolUnion) UnmarshalJSON added in v1.1.0

func (u *BetaThreadNewParamsMessageAttachmentToolUnion) UnmarshalJSON(data []byte) error

type BetaThreadNewParamsMessageContentUnion added in v1.1.0

type BetaThreadNewParamsMessageContentUnion struct {
	OfString              param.Opt[string]              `json:",omitzero,inline"`
	OfArrayOfContentParts []MessageContentPartParamUnion `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadNewParamsMessageContentUnion) MarshalJSON added in v1.1.0

func (u BetaThreadNewParamsMessageContentUnion) MarshalJSON() ([]byte, error)

func (*BetaThreadNewParamsMessageContentUnion) UnmarshalJSON added in v1.1.0

func (u *BetaThreadNewParamsMessageContentUnion) UnmarshalJSON(data []byte) error

type BetaThreadNewParamsToolResources added in v1.1.0

type BetaThreadNewParamsToolResources struct {
	CodeInterpreter BetaThreadNewParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
	FileSearch      BetaThreadNewParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
	// contains filtered or unexported fields
}

A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (BetaThreadNewParamsToolResources) MarshalJSON added in v1.1.0

func (r BetaThreadNewParamsToolResources) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewParamsToolResources) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewParamsToolResources) UnmarshalJSON(data []byte) error

type BetaThreadNewParamsToolResourcesCodeInterpreter added in v1.1.0

type BetaThreadNewParamsToolResourcesCodeInterpreter struct {
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
	// available to the `code_interpreter` tool. There can be a maximum of 20 files
	// associated with the tool.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewParamsToolResourcesCodeInterpreter) MarshalJSON added in v1.1.0

func (r BetaThreadNewParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewParamsToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearch added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearch struct {
	// The
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this thread. There can be a maximum of 1 vector store attached to
	// the thread.
	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
	// A helper to create a
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// with file_ids and attach it to this thread. There can be a maximum of 1 vector
	// store attached to the thread.
	VectorStores []BetaThreadNewParamsToolResourcesFileSearchVectorStore `json:"vector_stores,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewParamsToolResourcesFileSearch) MarshalJSON added in v1.1.0

func (r BetaThreadNewParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error)

func (*BetaThreadNewParamsToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

func (r *BetaThreadNewParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error

type BetaThreadNewParamsToolResourcesFileSearchVectorStore added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStore struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
	// strategy.
	ChunkingStrategy BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
	// add to the vector store. There can be a maximum of 10000 files in a vector
	// store.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadNewParamsToolResourcesFileSearchVectorStore) MarshalJSON added in v1.1.0

func (*BetaThreadNewParamsToolResourcesFileSearchVectorStore) UnmarshalJSON added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct {
	// Always `auto`.
	Type constant.Auto `json:"type,required"`
	// contains filtered or unexported fields
}

The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.

This struct has a constant value, construct it with NewBetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto.

func NewBetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto added in v1.1.0

func NewBetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto() BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto

func (BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) MarshalJSON added in v1.1.0

func (*BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) UnmarshalJSON added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct {
	Static BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic `json:"static,omitzero,required"`
	// Always `static`.
	//
	// This field can be elided, and will marshal its zero value as "static".
	Type constant.Static `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Static, Type are required.

func (BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) MarshalJSON added in v1.1.0

func (*BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) UnmarshalJSON added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic struct {
	// The number of tokens that overlap between chunks. The default value is `400`.
	//
	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
	// The maximum number of tokens in each chunk. The default value is `800`. The
	// minimum value is `100` and the maximum value is `4096`.
	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
	// contains filtered or unexported fields
}

The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.

func (BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) MarshalJSON added in v1.1.0

func (*BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) UnmarshalJSON added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion added in v1.1.0

type BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion struct {
	OfAuto   *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto   `json:",omitzero,inline"`
	OfStatic *BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetStatic added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) MarshalJSON added in v1.1.0

func (*BetaThreadNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) UnmarshalJSON added in v1.1.0

type BetaThreadRunListParams added in v1.1.0

type BetaThreadRunListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A cursor for use in pagination. `before` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// starting with obj_foo, your subsequent call can include before=obj_foo in order
	// to fetch the previous page of the list.
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order BetaThreadRunListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaThreadRunListParams) URLQuery added in v1.1.0

func (r BetaThreadRunListParams) URLQuery() (v url.Values, err error)

URLQuery serializes BetaThreadRunListParams's query parameters as `url.Values`.

type BetaThreadRunListParamsOrder added in v1.1.0

type BetaThreadRunListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	BetaThreadRunListParamsOrderAsc  BetaThreadRunListParamsOrder = "asc"
	BetaThreadRunListParamsOrderDesc BetaThreadRunListParamsOrder = "desc"
)

type BetaThreadRunNewParams added in v1.1.0

type BetaThreadRunNewParams struct {
	// The ID of the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
	// execute this run.
	AssistantID string `json:"assistant_id,required"`
	// Appends additional instructions at the end of the instructions for the run. This
	// is useful for modifying the behavior on a per-run basis without overriding other
	// instructions.
	AdditionalInstructions param.Opt[string] `json:"additional_instructions,omitzero"`
	// Overrides the
	// [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
	// of the assistant. This is useful for modifying the behavior on a per-run basis.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// The maximum number of completion tokens that may be used over the course of the
	// run. The run will make a best effort to use only the number of completion tokens
	// specified, across multiple turns of the run. If the run exceeds the number of
	// completion tokens specified, the run will end with status `incomplete`. See
	// `incomplete_details` for more info.
	MaxCompletionTokens param.Opt[int64] `json:"max_completion_tokens,omitzero"`
	// The maximum number of prompt tokens that may be used over the course of the run.
	// The run will make a best effort to use only the number of prompt tokens
	// specified, across multiple turns of the run. If the run exceeds the number of
	// prompt tokens specified, the run will end with status `incomplete`. See
	// `incomplete_details` for more info.
	MaxPromptTokens param.Opt[int64] `json:"max_prompt_tokens,omitzero"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or temperature but not both.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// Whether to enable
	// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
	// during tool use.
	ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
	// Adds additional messages to the thread before creating the run.
	AdditionalMessages []BetaThreadRunNewParamsAdditionalMessage `json:"additional_messages,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
	// be used to execute this run. If a value is provided here, it will override the
	// model associated with the assistant. If not, the model associated with the
	// assistant will be used.
	Model shared.ChatModel `json:"model,omitzero"`
	// **o-series models only**
	//
	// Constrains effort on reasoning for
	// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
	// supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
	// result in faster responses and fewer tokens used on reasoning in a response.
	//
	// Any of "low", "medium", "high".
	ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
	// Override the tools the assistant can use for this run. This is useful for
	// modifying the behavior on a per-run basis.
	Tools []AssistantToolUnionParam `json:"tools,omitzero"`
	// Controls for how a thread will be truncated prior to the run. Use this to
	// control the intial context window of the run.
	TruncationStrategy BetaThreadRunNewParamsTruncationStrategy `json:"truncation_strategy,omitzero"`
	// A list of additional fields to include in the response. Currently the only
	// supported value is `step_details.tool_calls[*].file_search.results[*].content`
	// to fetch the file search result content.
	//
	// See the
	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
	// for more information.
	Include []RunStepInclude `query:"include,omitzero" json:"-"`
	// Specifies the format that the model must output. Compatible with
	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
	//
	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
	// Outputs which ensures the model will match your supplied JSON schema. Learn more
	// in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
	// message the model generates is valid JSON.
	//
	// **Important:** when using JSON mode, you **must** also instruct the model to
	// produce JSON yourself via a system or user message. Without this, the model may
	// generate an unending stream of whitespace until the generation reaches the token
	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
	// the message content may be partially cut off if `finish_reason="length"`, which
	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
	// max context length.
	ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
	// Controls which (if any) tool is called by the model. `none` means the model will
	// not call any tools and instead generates a message. `auto` is the default value
	// and means the model can pick between generating a message or calling one or more
	// tools. `required` means the model must call one or more tools before responding
	// to the user. Specifying a particular tool like `{"type": "file_search"}` or
	// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
	// call that tool.
	ToolChoice AssistantToolChoiceOptionUnionParam `json:"tool_choice,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadRunNewParams) MarshalJSON added in v1.1.0

func (r BetaThreadRunNewParams) MarshalJSON() (data []byte, err error)

func (BetaThreadRunNewParams) URLQuery added in v1.1.0

func (r BetaThreadRunNewParams) URLQuery() (v url.Values, err error)

URLQuery serializes BetaThreadRunNewParams's query parameters as `url.Values`.

func (*BetaThreadRunNewParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadRunNewParams) UnmarshalJSON(data []byte) error

type BetaThreadRunNewParamsAdditionalMessage added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessage struct {
	// The text contents of the message.
	Content BetaThreadRunNewParamsAdditionalMessageContentUnion `json:"content,omitzero,required"`
	// The role of the entity that is creating the message. Allowed values include:
	//
	//   - `user`: Indicates the message is sent by an actual user and should be used in
	//     most cases to represent user-generated messages.
	//   - `assistant`: Indicates the message is generated by the assistant. Use this
	//     value to insert messages from the assistant into the conversation.
	//
	// Any of "user", "assistant".
	Role string `json:"role,omitzero,required"`
	// A list of files attached to the message, and the tools they should be added to.
	Attachments []BetaThreadRunNewParamsAdditionalMessageAttachment `json:"attachments,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

The properties Content, Role are required.

func (BetaThreadRunNewParamsAdditionalMessage) MarshalJSON added in v1.1.0

func (r BetaThreadRunNewParamsAdditionalMessage) MarshalJSON() (data []byte, err error)

func (*BetaThreadRunNewParamsAdditionalMessage) UnmarshalJSON added in v1.1.0

func (r *BetaThreadRunNewParamsAdditionalMessage) UnmarshalJSON(data []byte) error

type BetaThreadRunNewParamsAdditionalMessageAttachment added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessageAttachment struct {
	// The ID of the file to attach to the message.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The tools to add this file to.
	Tools []BetaThreadRunNewParamsAdditionalMessageAttachmentToolUnion `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadRunNewParamsAdditionalMessageAttachment) MarshalJSON added in v1.1.0

func (r BetaThreadRunNewParamsAdditionalMessageAttachment) MarshalJSON() (data []byte, err error)

func (*BetaThreadRunNewParamsAdditionalMessageAttachment) UnmarshalJSON added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch struct {
	// The type of tool being defined: `file_search`
	Type constant.FileSearch `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch.

func NewBetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch added in v1.1.0

func NewBetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch() BetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch

func (BetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch) MarshalJSON added in v1.1.0

func (*BetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch) UnmarshalJSON added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessageAttachmentToolUnion added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessageAttachmentToolUnion struct {
	OfCodeInterpreter *CodeInterpreterToolParam                                        `json:",omitzero,inline"`
	OfFileSearch      *BetaThreadRunNewParamsAdditionalMessageAttachmentToolFileSearch `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadRunNewParamsAdditionalMessageAttachmentToolUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (BetaThreadRunNewParamsAdditionalMessageAttachmentToolUnion) MarshalJSON added in v1.1.0

func (*BetaThreadRunNewParamsAdditionalMessageAttachmentToolUnion) UnmarshalJSON added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessageContentUnion added in v1.1.0

type BetaThreadRunNewParamsAdditionalMessageContentUnion struct {
	OfString              param.Opt[string]              `json:",omitzero,inline"`
	OfArrayOfContentParts []MessageContentPartParamUnion `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaThreadRunNewParamsAdditionalMessageContentUnion) MarshalJSON added in v1.1.0

func (*BetaThreadRunNewParamsAdditionalMessageContentUnion) UnmarshalJSON added in v1.1.0

type BetaThreadRunNewParamsTruncationStrategy added in v1.1.0

type BetaThreadRunNewParamsTruncationStrategy struct {
	// The truncation strategy to use for the thread. The default is `auto`. If set to
	// `last_messages`, the thread will be truncated to the n most recent messages in
	// the thread. When set to `auto`, messages in the middle of the thread will be
	// dropped to fit the context length of the model, `max_prompt_tokens`.
	//
	// Any of "auto", "last_messages".
	Type string `json:"type,omitzero,required"`
	// The number of most recent messages from the thread when constructing the context
	// for the run.
	LastMessages param.Opt[int64] `json:"last_messages,omitzero"`
	// contains filtered or unexported fields
}

Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run.

The property Type is required.

func (BetaThreadRunNewParamsTruncationStrategy) MarshalJSON added in v1.1.0

func (r BetaThreadRunNewParamsTruncationStrategy) MarshalJSON() (data []byte, err error)

func (*BetaThreadRunNewParamsTruncationStrategy) UnmarshalJSON added in v1.1.0

func (r *BetaThreadRunNewParamsTruncationStrategy) UnmarshalJSON(data []byte) error

type BetaThreadRunService deprecated added in v1.1.0

type BetaThreadRunService struct {
	Options []option.RequestOption
	// Deprecated: The Assistants API is deprecated in favor of the Responses API
	Steps BetaThreadRunStepService
}

BetaThreadRunService contains methods and other services that help with interacting with the openai API.

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

func NewBetaThreadRunService added in v1.1.0

func NewBetaThreadRunService(opts ...option.RequestOption) (r BetaThreadRunService)

NewBetaThreadRunService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaThreadRunService) Cancel deprecated added in v1.1.0

func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error)

Cancels a run that is `in_progress`.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunService) Get deprecated added in v1.1.0

func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error)

Retrieves a run.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunService) List deprecated added in v1.1.0

Returns a list of runs belonging to a thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunService) ListAutoPaging deprecated added in v1.1.0

Returns a list of runs belonging to a thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunService) New deprecated added in v1.1.0

func (r *BetaThreadRunService) New(ctx context.Context, threadID string, params BetaThreadRunNewParams, opts ...option.RequestOption) (res *Run, err error)

Create a run.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunService) NewStreaming deprecated added in v1.1.0

Create a run.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunService) SubmitToolOutputs deprecated added in v1.1.0

func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (res *Run, err error)

When a run has the `status: "requires_action"` and `required_action.type` is `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 (*BetaThreadRunService) SubmitToolOutputsStreaming deprecated added in v1.1.0

func (r *BetaThreadRunService) SubmitToolOutputsStreaming(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEventUnion])

When a run has the `status: "requires_action"` and `required_action.type` is `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 (*BetaThreadRunService) Update deprecated added in v1.1.0

func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runID string, body BetaThreadRunUpdateParams, opts ...option.RequestOption) (res *Run, err error)

Modifies a run.

Deprecated: The Assistants API is deprecated in favor of the Responses API

type BetaThreadRunStepGetParams added in v1.1.0

type BetaThreadRunStepGetParams struct {
	// A list of additional fields to include in the response. Currently the only
	// supported value is `step_details.tool_calls[*].file_search.results[*].content`
	// to fetch the file search result content.
	//
	// See the
	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
	// for more information.
	Include []RunStepInclude `query:"include,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaThreadRunStepGetParams) URLQuery added in v1.1.0

func (r BetaThreadRunStepGetParams) URLQuery() (v url.Values, err error)

URLQuery serializes BetaThreadRunStepGetParams's query parameters as `url.Values`.

type BetaThreadRunStepListParams added in v1.1.0

type BetaThreadRunStepListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A cursor for use in pagination. `before` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// starting with obj_foo, your subsequent call can include before=obj_foo in order
	// to fetch the previous page of the list.
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// A list of additional fields to include in the response. Currently the only
	// supported value is `step_details.tool_calls[*].file_search.results[*].content`
	// to fetch the file search result content.
	//
	// See the
	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
	// for more information.
	Include []RunStepInclude `query:"include,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order BetaThreadRunStepListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaThreadRunStepListParams) URLQuery added in v1.1.0

func (r BetaThreadRunStepListParams) URLQuery() (v url.Values, err error)

URLQuery serializes BetaThreadRunStepListParams's query parameters as `url.Values`.

type BetaThreadRunStepListParamsOrder added in v1.1.0

type BetaThreadRunStepListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	BetaThreadRunStepListParamsOrderAsc  BetaThreadRunStepListParamsOrder = "asc"
	BetaThreadRunStepListParamsOrderDesc BetaThreadRunStepListParamsOrder = "desc"
)

type BetaThreadRunStepService deprecated added in v1.1.0

type BetaThreadRunStepService struct {
	Options []option.RequestOption
}

BetaThreadRunStepService contains methods and other services that help with interacting with the openai API.

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

func NewBetaThreadRunStepService added in v1.1.0

func NewBetaThreadRunStepService(opts ...option.RequestOption) (r BetaThreadRunStepService)

NewBetaThreadRunStepService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaThreadRunStepService) Get deprecated added in v1.1.0

func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, query BetaThreadRunStepGetParams, opts ...option.RequestOption) (res *RunStep, err error)

Retrieves a run step.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunStepService) List deprecated added in v1.1.0

Returns a list of run steps belonging to a run.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadRunStepService) ListAutoPaging deprecated added in v1.1.0

Returns a list of run steps belonging to a run.

Deprecated: The Assistants API is deprecated in favor of the Responses API

type BetaThreadRunSubmitToolOutputsParams added in v1.1.0

type BetaThreadRunSubmitToolOutputsParams struct {
	// A list of tools for which the outputs are being submitted.
	ToolOutputs []BetaThreadRunSubmitToolOutputsParamsToolOutput `json:"tool_outputs,omitzero,required"`
	// contains filtered or unexported fields
}

func (BetaThreadRunSubmitToolOutputsParams) MarshalJSON added in v1.1.0

func (r BetaThreadRunSubmitToolOutputsParams) MarshalJSON() (data []byte, err error)

func (*BetaThreadRunSubmitToolOutputsParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadRunSubmitToolOutputsParams) UnmarshalJSON(data []byte) error

type BetaThreadRunSubmitToolOutputsParamsToolOutput added in v1.1.0

type BetaThreadRunSubmitToolOutputsParamsToolOutput struct {
	// The output of the tool call to be submitted to continue the run.
	Output param.Opt[string] `json:"output,omitzero"`
	// The ID of the tool call in the `required_action` object within the run object
	// the output is being submitted for.
	ToolCallID param.Opt[string] `json:"tool_call_id,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadRunSubmitToolOutputsParamsToolOutput) MarshalJSON added in v1.1.0

func (r BetaThreadRunSubmitToolOutputsParamsToolOutput) MarshalJSON() (data []byte, err error)

func (*BetaThreadRunSubmitToolOutputsParamsToolOutput) UnmarshalJSON added in v1.1.0

type BetaThreadRunUpdateParams added in v1.1.0

type BetaThreadRunUpdateParams struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadRunUpdateParams) MarshalJSON added in v1.1.0

func (r BetaThreadRunUpdateParams) MarshalJSON() (data []byte, err error)

func (*BetaThreadRunUpdateParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadRunUpdateParams) UnmarshalJSON(data []byte) error

type BetaThreadService deprecated added in v1.1.0

type BetaThreadService struct {
	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
}

BetaThreadService contains methods and other services that help with interacting with the openai API.

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

func NewBetaThreadService added in v1.1.0

func NewBetaThreadService(opts ...option.RequestOption) (r BetaThreadService)

NewBetaThreadService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaThreadService) Delete deprecated added in v1.1.0

func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ...option.RequestOption) (res *ThreadDeleted, err error)

Delete a thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadService) Get deprecated added in v1.1.0

func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...option.RequestOption) (res *Thread, err error)

Retrieves a thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadService) New deprecated added in v1.1.0

func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, opts ...option.RequestOption) (res *Thread, err error)

Create a thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadService) NewAndRun deprecated added in v1.1.0

func (r *BetaThreadService) NewAndRun(ctx context.Context, body BetaThreadNewAndRunParams, opts ...option.RequestOption) (res *Run, err error)

Create a thread and run it in one request.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadService) NewAndRunStreaming deprecated added in v1.1.0

Create a thread and run it in one request.

Deprecated: The Assistants API is deprecated in favor of the Responses API

func (*BetaThreadService) Update deprecated added in v1.1.0

func (r *BetaThreadService) Update(ctx context.Context, threadID string, body BetaThreadUpdateParams, opts ...option.RequestOption) (res *Thread, err error)

Modifies a thread.

Deprecated: The Assistants API is deprecated in favor of the Responses API

type BetaThreadUpdateParams added in v1.1.0

type BetaThreadUpdateParams struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// A set of resources that are made available to the assistant's tools in this
	// thread. The resources are specific to the type of tool. For example, the
	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
	// tool requires a list of vector store IDs.
	ToolResources BetaThreadUpdateParamsToolResources `json:"tool_resources,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadUpdateParams) MarshalJSON added in v1.1.0

func (r BetaThreadUpdateParams) MarshalJSON() (data []byte, err error)

func (*BetaThreadUpdateParams) UnmarshalJSON added in v1.1.0

func (r *BetaThreadUpdateParams) UnmarshalJSON(data []byte) error

type BetaThreadUpdateParamsToolResources added in v1.1.0

type BetaThreadUpdateParamsToolResources struct {
	CodeInterpreter BetaThreadUpdateParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
	FileSearch      BetaThreadUpdateParamsToolResourcesFileSearch      `json:"file_search,omitzero"`
	// contains filtered or unexported fields
}

A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (BetaThreadUpdateParamsToolResources) MarshalJSON added in v1.1.0

func (r BetaThreadUpdateParamsToolResources) MarshalJSON() (data []byte, err error)

func (*BetaThreadUpdateParamsToolResources) UnmarshalJSON added in v1.1.0

func (r *BetaThreadUpdateParamsToolResources) UnmarshalJSON(data []byte) error

type BetaThreadUpdateParamsToolResourcesCodeInterpreter added in v1.1.0

type BetaThreadUpdateParamsToolResourcesCodeInterpreter struct {
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
	// available to the `code_interpreter` tool. There can be a maximum of 20 files
	// associated with the tool.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadUpdateParamsToolResourcesCodeInterpreter) MarshalJSON added in v1.1.0

func (r BetaThreadUpdateParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error)

func (*BetaThreadUpdateParamsToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

type BetaThreadUpdateParamsToolResourcesFileSearch added in v1.1.0

type BetaThreadUpdateParamsToolResourcesFileSearch struct {
	// The
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this thread. There can be a maximum of 1 vector store attached to
	// the thread.
	VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
	// contains filtered or unexported fields
}

func (BetaThreadUpdateParamsToolResourcesFileSearch) MarshalJSON added in v1.1.0

func (r BetaThreadUpdateParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error)

func (*BetaThreadUpdateParamsToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

func (r *BetaThreadUpdateParamsToolResourcesFileSearch) UnmarshalJSON(data []byte) error

type ChatCompletion

type ChatCompletion struct {
	// A unique identifier for the chat completion.
	ID string `json:"id,required"`
	// A list of chat completion choices. Can be more than one if `n` is greater
	// than 1.
	Choices []ChatCompletionChoice `json:"choices,required"`
	// The Unix timestamp (in seconds) of when the chat completion was created.
	Created int64 `json:"created,required"`
	// The model used for the chat completion.
	Model string `json:"model,required"`
	// The object type, which is always `chat.completion`.
	Object constant.ChatCompletion `json:"object,required"`
	// Specifies the latency tier to use for processing the request. This parameter is
	// relevant for customers subscribed to the scale tier service:
	//
	//   - If set to 'auto', and the Project is Scale tier enabled, the system will
	//     utilize scale tier credits until they are exhausted.
	//   - If set to 'auto', and the Project is not Scale tier enabled, the request will
	//     be processed using the default service tier with a lower uptime SLA and no
	//     latency guarantee.
	//   - If set to 'default', the request will be processed using the default service
	//     tier with a lower uptime SLA and no latency guarantee.
	//   - If set to 'flex', the request will be processed with the Flex Processing
	//     service tier.
	//     [Learn more](https://platform.openai.com/docs/guides/flex-processing).
	//   - When not set, the default behavior is 'auto'.
	//
	// When this parameter is set, the response body will include the `service_tier`
	// utilized.
	//
	// Any of "auto", "default", "flex", "scale".
	ServiceTier ChatCompletionServiceTier `json:"service_tier,nullable"`
	// This fingerprint represents the backend configuration that the model runs with.
	//
	// Can be used in conjunction with the `seed` request parameter to understand when
	// backend changes have been made that might impact determinism.
	SystemFingerprint string `json:"system_fingerprint"`
	// Usage statistics for the completion request.
	Usage CompletionUsage `json:"usage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		Choices           respjson.Field
		Created           respjson.Field
		Model             respjson.Field
		Object            respjson.Field
		ServiceTier       respjson.Field
		SystemFingerprint respjson.Field
		Usage             respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a chat completion response returned by model, based on the provided input.

func (ChatCompletion) RawJSON

func (r ChatCompletion) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletion) UnmarshalJSON

func (r *ChatCompletion) UnmarshalJSON(data []byte) error

type ChatCompletionAccumulator

type ChatCompletionAccumulator struct {
	// The up-to-date accumulation of model's responses
	ChatCompletion
	// contains filtered or unexported fields
}

Helper to accumulate chunks from a stream

func (*ChatCompletionAccumulator) AddChunk

func (acc *ChatCompletionAccumulator) AddChunk(chunk ChatCompletionChunk) bool

AddChunk incorporates a chunk into the accumulation. Chunks must be added in order. Returns false if the chunk could not be successfully accumulated.

The ChatCompletion field JSON does not get accumulated.

func (*ChatCompletionAccumulator) JustFinishedContent

func (acc *ChatCompletionAccumulator) JustFinishedContent() (content string, ok bool)

JustFinishedContent retrieves the chat completion content when it is known to have just been completed. The content is "just completed" when the last added chunk no longer contains a content delta. If the content is just completed, the content is returned and the boolean is true. Otherwise, an empty string is returned and the boolean will be false.

func (*ChatCompletionAccumulator) JustFinishedRefusal

func (acc *ChatCompletionAccumulator) JustFinishedRefusal() (refusal string, ok bool)

JustFinishedRefusal retrieves the chat completion refusal when it is known to have just been completed. The refusal is "just completed" when the last added chunk no longer contains a refusal delta. If the refusal is just completed, the refusal is returned and the boolean is true. Otherwise, an empty string is returned and the boolean will be false.

func (*ChatCompletionAccumulator) JustFinishedToolCall

func (acc *ChatCompletionAccumulator) JustFinishedToolCall() (toolcall FinishedChatCompletionToolCall, ok bool)

JustFinishedToolCall retrieves a tool call when it is known to have just been completed. A tool call is "just completed" when the last added chunk no longer contains a tool call delta or contains a delta for a different tool call. If the tool call is just completed, a FinishedChatCompletionToolCall is returned and the boolean is true. Otherwise, an empty tool call is returned and the boolean will be false.

You cannot rely on this with a stream that has ParallelToolCalls enabled.

type ChatCompletionAssistantMessageParam

type ChatCompletionAssistantMessageParam struct {
	// The refusal message by the assistant.
	Refusal param.Opt[string] `json:"refusal,omitzero"`
	// An optional name for the participant. Provides the model information to
	// differentiate between participants of the same role.
	Name param.Opt[string] `json:"name,omitzero"`
	// Data about a previous audio response from the model.
	// [Learn more](https://platform.openai.com/docs/guides/audio).
	Audio ChatCompletionAssistantMessageParamAudio `json:"audio,omitzero"`
	// The contents of the assistant message. Required unless `tool_calls` or
	// `function_call` is specified.
	Content ChatCompletionAssistantMessageParamContentUnion `json:"content,omitzero"`
	// Deprecated and replaced by `tool_calls`. The name and arguments of a function
	// that should be called, as generated by the model.
	//
	// Deprecated: deprecated
	FunctionCall ChatCompletionAssistantMessageParamFunctionCall `json:"function_call,omitzero"`
	// The tool calls generated by the model, such as function calls.
	ToolCalls []ChatCompletionMessageToolCallParam `json:"tool_calls,omitzero"`
	// The role of the messages author, in this case `assistant`.
	//
	// This field can be elided, and will marshal its zero value as "assistant".
	Role constant.Assistant `json:"role,required"`
	// contains filtered or unexported fields
}

Messages sent by the model in response to user messages.

The property Role is required.

func (ChatCompletionAssistantMessageParam) MarshalJSON

func (r ChatCompletionAssistantMessageParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionAssistantMessageParam) UnmarshalJSON

func (r *ChatCompletionAssistantMessageParam) UnmarshalJSON(data []byte) error

type ChatCompletionAssistantMessageParamAudio

type ChatCompletionAssistantMessageParamAudio struct {
	// Unique identifier for a previous audio response from the model.
	ID string `json:"id,required"`
	// contains filtered or unexported fields
}

Data about a previous audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).

The property ID is required.

func (ChatCompletionAssistantMessageParamAudio) MarshalJSON

func (r ChatCompletionAssistantMessageParamAudio) MarshalJSON() (data []byte, err error)

func (*ChatCompletionAssistantMessageParamAudio) UnmarshalJSON

func (r *ChatCompletionAssistantMessageParamAudio) UnmarshalJSON(data []byte) error

type ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion added in v1.1.0

type ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion struct {
	OfText    *ChatCompletionContentPartTextParam    `json:",omitzero,inline"`
	OfRefusal *ChatCompletionContentPartRefusalParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) GetRefusal added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) GetText added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) GetType added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) MarshalJSON added in v1.1.0

func (*ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion) UnmarshalJSON added in v1.1.0

type ChatCompletionAssistantMessageParamContentUnion

type ChatCompletionAssistantMessageParamContentUnion struct {
	OfString              param.Opt[string]                                                   `json:",omitzero,inline"`
	OfArrayOfContentParts []ChatCompletionAssistantMessageParamContentArrayOfContentPartUnion `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionAssistantMessageParamContentUnion) MarshalJSON

func (*ChatCompletionAssistantMessageParamContentUnion) UnmarshalJSON

type ChatCompletionAssistantMessageParamFunctionCall deprecated

type ChatCompletionAssistantMessageParamFunctionCall struct {
	// The arguments to call the function with, as generated by the model in JSON
	// format. Note that the model does not always generate valid JSON, and may
	// hallucinate parameters not defined by your function schema. Validate the
	// arguments in your code before calling your function.
	Arguments string `json:"arguments,required"`
	// The name of the function to call.
	Name string `json:"name,required"`
	// contains filtered or unexported fields
}

Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.

Deprecated: deprecated

The properties Arguments, Name are required.

func (ChatCompletionAssistantMessageParamFunctionCall) MarshalJSON

func (r ChatCompletionAssistantMessageParamFunctionCall) MarshalJSON() (data []byte, err error)

func (*ChatCompletionAssistantMessageParamFunctionCall) UnmarshalJSON

type ChatCompletionAudio

type ChatCompletionAudio struct {
	// Unique identifier for this audio response.
	ID string `json:"id,required"`
	// Base64 encoded audio bytes generated by the model, in the format specified in
	// the request.
	Data string `json:"data,required"`
	// The Unix timestamp (in seconds) for when this audio response will no longer be
	// accessible on the server for use in multi-turn conversations.
	ExpiresAt int64 `json:"expires_at,required"`
	// Transcript of the audio generated by the model.
	Transcript string `json:"transcript,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Data        respjson.Field
		ExpiresAt   respjson.Field
		Transcript  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

If the audio output modality is requested, this object contains data about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).

func (ChatCompletionAudio) RawJSON

func (r ChatCompletionAudio) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletionAudio) UnmarshalJSON

func (r *ChatCompletionAudio) UnmarshalJSON(data []byte) error

type ChatCompletionAudioParam

type ChatCompletionAudioParam struct {
	// Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
	// or `pcm16`.
	//
	// Any of "wav", "aac", "mp3", "flac", "opus", "pcm16".
	Format ChatCompletionAudioParamFormat `json:"format,omitzero,required"`
	// The voice the model uses to respond. Supported voices are `alloy`, `ash`,
	// `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`.
	Voice ChatCompletionAudioParamVoice `json:"voice,omitzero,required"`
	// contains filtered or unexported fields
}

Parameters for audio output. Required when audio output is requested with `modalities: ["audio"]`. [Learn more](https://platform.openai.com/docs/guides/audio).

The properties Format, Voice are required.

func (ChatCompletionAudioParam) MarshalJSON

func (r ChatCompletionAudioParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionAudioParam) UnmarshalJSON

func (r *ChatCompletionAudioParam) UnmarshalJSON(data []byte) error

type ChatCompletionAudioParamFormat

type ChatCompletionAudioParamFormat string

Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.

const (
	ChatCompletionAudioParamFormatWAV   ChatCompletionAudioParamFormat = "wav"
	ChatCompletionAudioParamFormatAAC   ChatCompletionAudioParamFormat = "aac"
	ChatCompletionAudioParamFormatMP3   ChatCompletionAudioParamFormat = "mp3"
	ChatCompletionAudioParamFormatFLAC  ChatCompletionAudioParamFormat = "flac"
	ChatCompletionAudioParamFormatOpus  ChatCompletionAudioParamFormat = "opus"
	ChatCompletionAudioParamFormatPcm16 ChatCompletionAudioParamFormat = "pcm16"
)

type ChatCompletionAudioParamVoice

type ChatCompletionAudioParamVoice string

The voice the model uses to respond. Supported voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`.

const (
	ChatCompletionAudioParamVoiceAlloy   ChatCompletionAudioParamVoice = "alloy"
	ChatCompletionAudioParamVoiceAsh     ChatCompletionAudioParamVoice = "ash"
	ChatCompletionAudioParamVoiceBallad  ChatCompletionAudioParamVoice = "ballad"
	ChatCompletionAudioParamVoiceCoral   ChatCompletionAudioParamVoice = "coral"
	ChatCompletionAudioParamVoiceEcho    ChatCompletionAudioParamVoice = "echo"
	ChatCompletionAudioParamVoiceFable   ChatCompletionAudioParamVoice = "fable"
	ChatCompletionAudioParamVoiceOnyx    ChatCompletionAudioParamVoice = "onyx"
	ChatCompletionAudioParamVoiceNova    ChatCompletionAudioParamVoice = "nova"
	ChatCompletionAudioParamVoiceSage    ChatCompletionAudioParamVoice = "sage"
	ChatCompletionAudioParamVoiceShimmer ChatCompletionAudioParamVoice = "shimmer"
	ChatCompletionAudioParamVoiceVerse   ChatCompletionAudioParamVoice = "verse"
)

type ChatCompletionChoice

type ChatCompletionChoice struct {
	// The reason the model stopped generating tokens. This will be `stop` if the model
	// hit a natural stop point or a provided stop sequence, `length` if the maximum
	// number of tokens specified in the request was reached, `content_filter` if
	// content was omitted due to a flag from our content filters, `tool_calls` if the
	// model called a tool, or `function_call` (deprecated) if the model called a
	// function.
	//
	// Any of "stop", "length", "tool_calls", "content_filter", "function_call".
	FinishReason string `json:"finish_reason,required"`
	// The index of the choice in the list of choices.
	Index int64 `json:"index,required"`
	// Log probability information for the choice.
	Logprobs ChatCompletionChoiceLogprobs `json:"logprobs,required"`
	// A chat completion message generated by the model.
	Message ChatCompletionMessage `json:"message,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FinishReason respjson.Field
		Index        respjson.Field
		Logprobs     respjson.Field
		Message      respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionChoice) RawJSON

func (r ChatCompletionChoice) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletionChoice) UnmarshalJSON

func (r *ChatCompletionChoice) UnmarshalJSON(data []byte) error

type ChatCompletionChoiceLogprobs

type ChatCompletionChoiceLogprobs struct {
	// A list of message content tokens with log probability information.
	Content []ChatCompletionTokenLogprob `json:"content,required"`
	// A list of message refusal tokens with log probability information.
	Refusal []ChatCompletionTokenLogprob `json:"refusal,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Refusal     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Log probability information for the choice.

func (ChatCompletionChoiceLogprobs) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionChoiceLogprobs) UnmarshalJSON

func (r *ChatCompletionChoiceLogprobs) UnmarshalJSON(data []byte) error

type ChatCompletionChunk

type ChatCompletionChunk struct {
	// A unique identifier for the chat completion. Each chunk has the same ID.
	ID string `json:"id,required"`
	// A list of chat completion choices. Can contain more than one elements if `n` is
	// greater than 1. Can also be empty for the last chunk if you set
	// `stream_options: {"include_usage": true}`.
	Choices []ChatCompletionChunkChoice `json:"choices,required"`
	// The Unix timestamp (in seconds) of when the chat completion was created. Each
	// chunk has the same timestamp.
	Created int64 `json:"created,required"`
	// The model to generate the completion.
	Model string `json:"model,required"`
	// The object type, which is always `chat.completion.chunk`.
	Object constant.ChatCompletionChunk `json:"object,required"`
	// Specifies the latency tier to use for processing the request. This parameter is
	// relevant for customers subscribed to the scale tier service:
	//
	//   - If set to 'auto', and the Project is Scale tier enabled, the system will
	//     utilize scale tier credits until they are exhausted.
	//   - If set to 'auto', and the Project is not Scale tier enabled, the request will
	//     be processed using the default service tier with a lower uptime SLA and no
	//     latency guarantee.
	//   - If set to 'default', the request will be processed using the default service
	//     tier with a lower uptime SLA and no latency guarantee.
	//   - If set to 'flex', the request will be processed with the Flex Processing
	//     service tier.
	//     [Learn more](https://platform.openai.com/docs/guides/flex-processing).
	//   - When not set, the default behavior is 'auto'.
	//
	// When this parameter is set, the response body will include the `service_tier`
	// utilized.
	//
	// Any of "auto", "default", "flex", "scale".
	ServiceTier ChatCompletionChunkServiceTier `json:"service_tier,nullable"`
	// This fingerprint represents the backend configuration that the model runs with.
	// Can be used in conjunction with the `seed` request parameter to understand when
	// backend changes have been made that might impact determinism.
	SystemFingerprint string `json:"system_fingerprint"`
	// An optional field that will only be present when you set
	// `stream_options: {"include_usage": true}` in your request. When present, it
	// contains a null value **except for the last chunk** which contains the token
	// usage statistics for the entire request.
	//
	// **NOTE:** If the stream is interrupted or cancelled, you may not receive the
	// final usage chunk which contains the total token usage for the request.
	Usage CompletionUsage `json:"usage,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		Choices           respjson.Field
		Created           respjson.Field
		Model             respjson.Field
		Object            respjson.Field
		ServiceTier       respjson.Field
		SystemFingerprint respjson.Field
		Usage             respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a streamed chunk of a chat completion response returned by the model, based on the provided input. [Learn more](https://platform.openai.com/docs/guides/streaming-responses).

func (ChatCompletionChunk) RawJSON

func (r ChatCompletionChunk) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletionChunk) UnmarshalJSON

func (r *ChatCompletionChunk) UnmarshalJSON(data []byte) error

type ChatCompletionChunkChoice

type ChatCompletionChunkChoice struct {
	// A chat completion delta generated by streamed model responses.
	Delta ChatCompletionChunkChoiceDelta `json:"delta,required"`
	// The reason the model stopped generating tokens. This will be `stop` if the model
	// hit a natural stop point or a provided stop sequence, `length` if the maximum
	// number of tokens specified in the request was reached, `content_filter` if
	// content was omitted due to a flag from our content filters, `tool_calls` if the
	// model called a tool, or `function_call` (deprecated) if the model called a
	// function.
	//
	// Any of "stop", "length", "tool_calls", "content_filter", "function_call".
	FinishReason string `json:"finish_reason,required"`
	// The index of the choice in the list of choices.
	Index int64 `json:"index,required"`
	// Log probability information for the choice.
	Logprobs ChatCompletionChunkChoiceLogprobs `json:"logprobs,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta        respjson.Field
		FinishReason respjson.Field
		Index        respjson.Field
		Logprobs     respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionChunkChoice) RawJSON

func (r ChatCompletionChunkChoice) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletionChunkChoice) UnmarshalJSON

func (r *ChatCompletionChunkChoice) UnmarshalJSON(data []byte) error

type ChatCompletionChunkChoiceDelta

type ChatCompletionChunkChoiceDelta struct {
	// The contents of the chunk message.
	Content string `json:"content,nullable"`
	// Deprecated and replaced by `tool_calls`. The name and arguments of a function
	// that should be called, as generated by the model.
	//
	// Deprecated: deprecated
	FunctionCall ChatCompletionChunkChoiceDeltaFunctionCall `json:"function_call"`
	// The refusal message generated by the model.
	Refusal string `json:"refusal,nullable"`
	// The role of the author of this message.
	//
	// Any of "developer", "system", "user", "assistant", "tool".
	Role      string                                   `json:"role"`
	ToolCalls []ChatCompletionChunkChoiceDeltaToolCall `json:"tool_calls"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content      respjson.Field
		FunctionCall respjson.Field
		Refusal      respjson.Field
		Role         respjson.Field
		ToolCalls    respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A chat completion delta generated by streamed model responses.

func (ChatCompletionChunkChoiceDelta) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionChunkChoiceDelta) UnmarshalJSON

func (r *ChatCompletionChunkChoiceDelta) UnmarshalJSON(data []byte) error

type ChatCompletionChunkChoiceDeltaFunctionCall deprecated

type ChatCompletionChunkChoiceDeltaFunctionCall struct {
	// The arguments to call the function with, as generated by the model in JSON
	// format. Note that the model does not always generate valid JSON, and may
	// hallucinate parameters not defined by your function schema. Validate the
	// arguments in your code before calling your function.
	Arguments string `json:"arguments"`
	// The name of the function to call.
	Name string `json:"name"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.

Deprecated: deprecated

func (ChatCompletionChunkChoiceDeltaFunctionCall) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionChunkChoiceDeltaFunctionCall) UnmarshalJSON

func (r *ChatCompletionChunkChoiceDeltaFunctionCall) UnmarshalJSON(data []byte) error

type ChatCompletionChunkChoiceDeltaToolCall added in v1.1.0

type ChatCompletionChunkChoiceDeltaToolCall struct {
	Index int64 `json:"index,required"`
	// The ID of the tool call.
	ID       string                                         `json:"id"`
	Function ChatCompletionChunkChoiceDeltaToolCallFunction `json:"function"`
	// The type of the tool. Currently, only `function` is supported.
	//
	// Any of "function".
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		ID          respjson.Field
		Function    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionChunkChoiceDeltaToolCall) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ChatCompletionChunkChoiceDeltaToolCall) UnmarshalJSON added in v1.1.0

func (r *ChatCompletionChunkChoiceDeltaToolCall) UnmarshalJSON(data []byte) error

type ChatCompletionChunkChoiceDeltaToolCallFunction

type ChatCompletionChunkChoiceDeltaToolCallFunction struct {
	// The arguments to call the function with, as generated by the model in JSON
	// format. Note that the model does not always generate valid JSON, and may
	// hallucinate parameters not defined by your function schema. Validate the
	// arguments in your code before calling your function.
	Arguments string `json:"arguments"`
	// The name of the function to call.
	Name string `json:"name"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionChunkChoiceDeltaToolCallFunction) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionChunkChoiceDeltaToolCallFunction) UnmarshalJSON

type ChatCompletionChunkChoiceLogprobs

type ChatCompletionChunkChoiceLogprobs struct {
	// A list of message content tokens with log probability information.
	Content []ChatCompletionTokenLogprob `json:"content,required"`
	// A list of message refusal tokens with log probability information.
	Refusal []ChatCompletionTokenLogprob `json:"refusal,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Refusal     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Log probability information for the choice.

func (ChatCompletionChunkChoiceLogprobs) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionChunkChoiceLogprobs) UnmarshalJSON

func (r *ChatCompletionChunkChoiceLogprobs) UnmarshalJSON(data []byte) error

type ChatCompletionChunkServiceTier

type ChatCompletionChunkServiceTier string

Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:

  • If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted.
  • If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](https://platform.openai.com/docs/guides/flex-processing).
  • When not set, the default behavior is 'auto'.

When this parameter is set, the response body will include the `service_tier` utilized.

const (
	ChatCompletionChunkServiceTierAuto    ChatCompletionChunkServiceTier = "auto"
	ChatCompletionChunkServiceTierDefault ChatCompletionChunkServiceTier = "default"
	ChatCompletionChunkServiceTierFlex    ChatCompletionChunkServiceTier = "flex"
	ChatCompletionChunkServiceTierScale   ChatCompletionChunkServiceTier = "scale"
)

type ChatCompletionContentPartFileFileParam added in v1.1.0

type ChatCompletionContentPartFileFileParam struct {
	// The base64 encoded file data, used when passing the file to the model as a
	// string.
	FileData param.Opt[string] `json:"file_data,omitzero"`
	// The ID of an uploaded file to use as input.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The name of the file, used when passing the file to the model as a string.
	Filename param.Opt[string] `json:"filename,omitzero"`
	// contains filtered or unexported fields
}

func (ChatCompletionContentPartFileFileParam) MarshalJSON added in v1.1.0

func (r ChatCompletionContentPartFileFileParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartFileFileParam) UnmarshalJSON added in v1.1.0

func (r *ChatCompletionContentPartFileFileParam) UnmarshalJSON(data []byte) error

type ChatCompletionContentPartFileParam

type ChatCompletionContentPartFileParam struct {
	File ChatCompletionContentPartFileFileParam `json:"file,omitzero,required"`
	// The type of the content part. Always `file`.
	//
	// This field can be elided, and will marshal its zero value as "file".
	Type constant.File `json:"type,required"`
	// contains filtered or unexported fields
}

Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation.

The properties File, Type are required.

func (ChatCompletionContentPartFileParam) MarshalJSON

func (r ChatCompletionContentPartFileParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartFileParam) UnmarshalJSON

func (r *ChatCompletionContentPartFileParam) UnmarshalJSON(data []byte) error

type ChatCompletionContentPartImageImageURLParam

type ChatCompletionContentPartImageImageURLParam struct {
	// Either a URL of the image or the base64 encoded image data.
	URL string `json:"url,required" format:"uri"`
	// Specifies the detail level of the image. Learn more in the
	// [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
	//
	// Any of "auto", "low", "high".
	Detail string `json:"detail,omitzero"`
	// contains filtered or unexported fields
}

The property URL is required.

func (ChatCompletionContentPartImageImageURLParam) MarshalJSON

func (r ChatCompletionContentPartImageImageURLParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartImageImageURLParam) UnmarshalJSON

func (r *ChatCompletionContentPartImageImageURLParam) UnmarshalJSON(data []byte) error

type ChatCompletionContentPartImageParam

type ChatCompletionContentPartImageParam struct {
	ImageURL ChatCompletionContentPartImageImageURLParam `json:"image_url,omitzero,required"`
	// The type of the content part.
	//
	// This field can be elided, and will marshal its zero value as "image_url".
	Type constant.ImageURL `json:"type,required"`
	// contains filtered or unexported fields
}

Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

The properties ImageURL, Type are required.

func (ChatCompletionContentPartImageParam) MarshalJSON

func (r ChatCompletionContentPartImageParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartImageParam) UnmarshalJSON

func (r *ChatCompletionContentPartImageParam) UnmarshalJSON(data []byte) error

type ChatCompletionContentPartInputAudioInputAudioParam added in v1.1.0

type ChatCompletionContentPartInputAudioInputAudioParam struct {
	// Base64 encoded audio data.
	Data string `json:"data,required"`
	// The format of the encoded audio data. Currently supports "wav" and "mp3".
	//
	// Any of "wav", "mp3".
	Format string `json:"format,omitzero,required"`
	// contains filtered or unexported fields
}

The properties Data, Format are required.

func (ChatCompletionContentPartInputAudioInputAudioParam) MarshalJSON added in v1.1.0

func (r ChatCompletionContentPartInputAudioInputAudioParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartInputAudioInputAudioParam) UnmarshalJSON added in v1.1.0

type ChatCompletionContentPartInputAudioParam

type ChatCompletionContentPartInputAudioParam struct {
	InputAudio ChatCompletionContentPartInputAudioInputAudioParam `json:"input_audio,omitzero,required"`
	// The type of the content part. Always `input_audio`.
	//
	// This field can be elided, and will marshal its zero value as "input_audio".
	Type constant.InputAudio `json:"type,required"`
	// contains filtered or unexported fields
}

Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).

The properties InputAudio, Type are required.

func (ChatCompletionContentPartInputAudioParam) MarshalJSON

func (r ChatCompletionContentPartInputAudioParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartInputAudioParam) UnmarshalJSON

func (r *ChatCompletionContentPartInputAudioParam) UnmarshalJSON(data []byte) error

type ChatCompletionContentPartRefusalParam

type ChatCompletionContentPartRefusalParam struct {
	// The refusal message generated by the model.
	Refusal string `json:"refusal,required"`
	// The type of the content part.
	//
	// This field can be elided, and will marshal its zero value as "refusal".
	Type constant.Refusal `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Refusal, Type are required.

func (ChatCompletionContentPartRefusalParam) MarshalJSON

func (r ChatCompletionContentPartRefusalParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartRefusalParam) UnmarshalJSON

func (r *ChatCompletionContentPartRefusalParam) UnmarshalJSON(data []byte) error

type ChatCompletionContentPartTextParam

type ChatCompletionContentPartTextParam struct {
	// The text content.
	Text string `json:"text,required"`
	// The type of the content part.
	//
	// This field can be elided, and will marshal its zero value as "text".
	Type constant.Text `json:"type,required"`
	// contains filtered or unexported fields
}

Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).

The properties Text, Type are required.

func (ChatCompletionContentPartTextParam) MarshalJSON

func (r ChatCompletionContentPartTextParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionContentPartTextParam) UnmarshalJSON

func (r *ChatCompletionContentPartTextParam) UnmarshalJSON(data []byte) error

type ChatCompletionContentPartUnionParam

type ChatCompletionContentPartUnionParam struct {
	OfText       *ChatCompletionContentPartTextParam       `json:",omitzero,inline"`
	OfImageURL   *ChatCompletionContentPartImageParam      `json:",omitzero,inline"`
	OfInputAudio *ChatCompletionContentPartInputAudioParam `json:",omitzero,inline"`
	OfFile       *ChatCompletionContentPartFileParam       `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionContentPartUnionParam) GetFile

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionContentPartUnionParam) GetImageURL

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionContentPartUnionParam) GetInputAudio

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionContentPartUnionParam) GetText

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionContentPartUnionParam) GetType

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionContentPartUnionParam) MarshalJSON

func (u ChatCompletionContentPartUnionParam) MarshalJSON() ([]byte, error)

func (*ChatCompletionContentPartUnionParam) UnmarshalJSON

func (u *ChatCompletionContentPartUnionParam) UnmarshalJSON(data []byte) error

type ChatCompletionDeleted

type ChatCompletionDeleted struct {
	// The ID of the chat completion that was deleted.
	ID string `json:"id,required"`
	// Whether the chat completion was deleted.
	Deleted bool `json:"deleted,required"`
	// The type of object being deleted.
	Object constant.ChatCompletionDeleted `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionDeleted) RawJSON

func (r ChatCompletionDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletionDeleted) UnmarshalJSON

func (r *ChatCompletionDeleted) UnmarshalJSON(data []byte) error

type ChatCompletionDeveloperMessageParam

type ChatCompletionDeveloperMessageParam struct {
	// The contents of the developer message.
	Content ChatCompletionDeveloperMessageParamContentUnion `json:"content,omitzero,required"`
	// An optional name for the participant. Provides the model information to
	// differentiate between participants of the same role.
	Name param.Opt[string] `json:"name,omitzero"`
	// The role of the messages author, in this case `developer`.
	//
	// This field can be elided, and will marshal its zero value as "developer".
	Role constant.Developer `json:"role,required"`
	// contains filtered or unexported fields
}

Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, `developer` messages replace the previous `system` messages.

The properties Content, Role are required.

func (ChatCompletionDeveloperMessageParam) MarshalJSON

func (r ChatCompletionDeveloperMessageParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionDeveloperMessageParam) UnmarshalJSON

func (r *ChatCompletionDeveloperMessageParam) UnmarshalJSON(data []byte) error

type ChatCompletionDeveloperMessageParamContentUnion

type ChatCompletionDeveloperMessageParamContentUnion struct {
	OfString              param.Opt[string]                    `json:",omitzero,inline"`
	OfArrayOfContentParts []ChatCompletionContentPartTextParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionDeveloperMessageParamContentUnion) MarshalJSON

func (*ChatCompletionDeveloperMessageParamContentUnion) UnmarshalJSON

type ChatCompletionFunctionCallOptionParam

type ChatCompletionFunctionCallOptionParam struct {
	// The name of the function to call.
	Name string `json:"name,required"`
	// contains filtered or unexported fields
}

Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.

The property Name is required.

func (ChatCompletionFunctionCallOptionParam) MarshalJSON

func (r ChatCompletionFunctionCallOptionParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionFunctionCallOptionParam) UnmarshalJSON

func (r *ChatCompletionFunctionCallOptionParam) UnmarshalJSON(data []byte) error

type ChatCompletionFunctionMessageParam deprecated

type ChatCompletionFunctionMessageParam struct {
	// The contents of the function message.
	Content param.Opt[string] `json:"content,omitzero,required"`
	// The name of the function to call.
	Name string `json:"name,required"`
	// The role of the messages author, in this case `function`.
	//
	// This field can be elided, and will marshal its zero value as "function".
	Role constant.Function `json:"role,required"`
	// contains filtered or unexported fields
}

Deprecated: deprecated

The properties Content, Name, Role are required.

func (ChatCompletionFunctionMessageParam) MarshalJSON

func (r ChatCompletionFunctionMessageParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionFunctionMessageParam) UnmarshalJSON

func (r *ChatCompletionFunctionMessageParam) UnmarshalJSON(data []byte) error

type ChatCompletionListParams

type ChatCompletionListParams struct {
	// Identifier for the last chat completion from the previous pagination request.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// Number of Chat Completions to retrieve.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// The model used to generate the Chat Completions.
	Model param.Opt[string] `query:"model,omitzero" json:"-"`
	// A list of metadata keys to filter the Chat Completions by. Example:
	//
	// `metadata[key1]=value1&metadata[key2]=value2`
	Metadata shared.Metadata `query:"metadata,omitzero" json:"-"`
	// Sort order for Chat Completions by timestamp. Use `asc` for ascending order or
	// `desc` for descending order. Defaults to `asc`.
	//
	// Any of "asc", "desc".
	Order ChatCompletionListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ChatCompletionListParams) URLQuery

func (r ChatCompletionListParams) URLQuery() (v url.Values, err error)

URLQuery serializes ChatCompletionListParams's query parameters as `url.Values`.

type ChatCompletionListParamsOrder

type ChatCompletionListParamsOrder string

Sort order for Chat Completions by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.

const (
	ChatCompletionListParamsOrderAsc  ChatCompletionListParamsOrder = "asc"
	ChatCompletionListParamsOrderDesc ChatCompletionListParamsOrder = "desc"
)

type ChatCompletionMessage

type ChatCompletionMessage struct {
	// The contents of the message.
	Content string `json:"content,required"`
	// The refusal message generated by the model.
	Refusal string `json:"refusal,required"`
	// The role of the author of this message.
	Role constant.Assistant `json:"role,required"`
	// Annotations for the message, when applicable, as when using the
	// [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
	Annotations []ChatCompletionMessageAnnotation `json:"annotations"`
	// If the audio output modality is requested, this object contains data about the
	// audio response from the model.
	// [Learn more](https://platform.openai.com/docs/guides/audio).
	Audio ChatCompletionAudio `json:"audio,nullable"`
	// Deprecated and replaced by `tool_calls`. The name and arguments of a function
	// that should be called, as generated by the model.
	//
	// Deprecated: deprecated
	FunctionCall ChatCompletionMessageFunctionCall `json:"function_call"`
	// The tool calls generated by the model, such as function calls.
	ToolCalls []ChatCompletionMessageToolCall `json:"tool_calls"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content      respjson.Field
		Refusal      respjson.Field
		Role         respjson.Field
		Annotations  respjson.Field
		Audio        respjson.Field
		FunctionCall respjson.Field
		ToolCalls    respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A chat completion message generated by the model.

func (ChatCompletionMessage) RawJSON

func (r ChatCompletionMessage) RawJSON() string

Returns the unmodified JSON received from the API

func (ChatCompletionMessage) ToAssistantMessageParam

func (r ChatCompletionMessage) ToAssistantMessageParam() ChatCompletionAssistantMessageParam

func (ChatCompletionMessage) ToParam

func (*ChatCompletionMessage) UnmarshalJSON

func (r *ChatCompletionMessage) UnmarshalJSON(data []byte) error

type ChatCompletionMessageAnnotation

type ChatCompletionMessageAnnotation struct {
	// The type of the URL citation. Always `url_citation`.
	Type constant.URLCitation `json:"type,required"`
	// A URL citation when using web search.
	URLCitation ChatCompletionMessageAnnotationURLCitation `json:"url_citation,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		URLCitation respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A URL citation when using web search.

func (ChatCompletionMessageAnnotation) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionMessageAnnotation) UnmarshalJSON

func (r *ChatCompletionMessageAnnotation) UnmarshalJSON(data []byte) error

type ChatCompletionMessageAnnotationURLCitation

type ChatCompletionMessageAnnotationURLCitation struct {
	// The index of the last character of the URL citation in the message.
	EndIndex int64 `json:"end_index,required"`
	// The index of the first character of the URL citation in the message.
	StartIndex int64 `json:"start_index,required"`
	// The title of the web resource.
	Title string `json:"title,required"`
	// The URL of the web resource.
	URL string `json:"url,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EndIndex    respjson.Field
		StartIndex  respjson.Field
		Title       respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A URL citation when using web search.

func (ChatCompletionMessageAnnotationURLCitation) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionMessageAnnotationURLCitation) UnmarshalJSON

func (r *ChatCompletionMessageAnnotationURLCitation) UnmarshalJSON(data []byte) error

type ChatCompletionMessageFunctionCall deprecated

type ChatCompletionMessageFunctionCall struct {
	// The arguments to call the function with, as generated by the model in JSON
	// format. Note that the model does not always generate valid JSON, and may
	// hallucinate parameters not defined by your function schema. Validate the
	// arguments in your code before calling your function.
	Arguments string `json:"arguments,required"`
	// The name of the function to call.
	Name string `json:"name,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.

Deprecated: deprecated

func (ChatCompletionMessageFunctionCall) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionMessageFunctionCall) UnmarshalJSON

func (r *ChatCompletionMessageFunctionCall) UnmarshalJSON(data []byte) error

type ChatCompletionMessageListParams

type ChatCompletionMessageListParams struct {
	// Identifier for the last message from the previous pagination request.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// Number of messages to retrieve.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Sort order for messages by timestamp. Use `asc` for ascending order or `desc`
	// for descending order. Defaults to `asc`.
	//
	// Any of "asc", "desc".
	Order ChatCompletionMessageListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ChatCompletionMessageListParams) URLQuery

func (r ChatCompletionMessageListParams) URLQuery() (v url.Values, err error)

URLQuery serializes ChatCompletionMessageListParams's query parameters as `url.Values`.

type ChatCompletionMessageListParamsOrder

type ChatCompletionMessageListParamsOrder string

Sort order for messages by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.

const (
	ChatCompletionMessageListParamsOrderAsc  ChatCompletionMessageListParamsOrder = "asc"
	ChatCompletionMessageListParamsOrderDesc ChatCompletionMessageListParamsOrder = "desc"
)

type ChatCompletionMessageParamUnion

type ChatCompletionMessageParamUnion struct {
	OfDeveloper *ChatCompletionDeveloperMessageParam `json:",omitzero,inline"`
	OfSystem    *ChatCompletionSystemMessageParam    `json:",omitzero,inline"`
	OfUser      *ChatCompletionUserMessageParam      `json:",omitzero,inline"`
	OfAssistant *ChatCompletionAssistantMessageParam `json:",omitzero,inline"`
	OfTool      *ChatCompletionToolMessageParam      `json:",omitzero,inline"`
	OfFunction  *ChatCompletionFunctionMessageParam  `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func ChatCompletionMessageParamOfFunction

func ChatCompletionMessageParamOfFunction(content string, name string) ChatCompletionMessageParamUnion

func (ChatCompletionMessageParamUnion) GetAudio

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionMessageParamUnion) GetContent

func (u ChatCompletionMessageParamUnion) GetContent() (res chatCompletionMessageParamUnionContent)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (ChatCompletionMessageParamUnion) GetFunctionCall

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionMessageParamUnion) GetName

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionMessageParamUnion) GetRefusal

func (u ChatCompletionMessageParamUnion) GetRefusal() *string

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionMessageParamUnion) GetRole

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionMessageParamUnion) GetToolCallID

func (u ChatCompletionMessageParamUnion) GetToolCallID() *string

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionMessageParamUnion) GetToolCalls

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionMessageParamUnion) MarshalJSON

func (u ChatCompletionMessageParamUnion) MarshalJSON() ([]byte, error)

func (*ChatCompletionMessageParamUnion) UnmarshalJSON

func (u *ChatCompletionMessageParamUnion) UnmarshalJSON(data []byte) error

type ChatCompletionMessageService

type ChatCompletionMessageService struct {
	Options []option.RequestOption
}

ChatCompletionMessageService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChatCompletionMessageService method instead.

func NewChatCompletionMessageService

func NewChatCompletionMessageService(opts ...option.RequestOption) (r ChatCompletionMessageService)

NewChatCompletionMessageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ChatCompletionMessageService) List

Get the messages in a stored chat completion. Only Chat Completions that have been created with the `store` parameter set to `true` will be returned.

func (*ChatCompletionMessageService) ListAutoPaging

Get the messages in a stored chat completion. Only Chat Completions that have been created with the `store` parameter set to `true` will be returned.

type ChatCompletionMessageToolCall

type ChatCompletionMessageToolCall struct {
	// The ID of the tool call.
	ID string `json:"id,required"`
	// The function that the model called.
	Function ChatCompletionMessageToolCallFunction `json:"function,required"`
	// The type of the tool. Currently, only `function` is supported.
	Type constant.Function `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Function    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionMessageToolCall) RawJSON

Returns the unmodified JSON received from the API

func (ChatCompletionMessageToolCall) ToParam

ToParam converts this ChatCompletionMessageToolCall to a ChatCompletionMessageToolCallParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ChatCompletionMessageToolCallParam.Overrides()

func (*ChatCompletionMessageToolCall) UnmarshalJSON

func (r *ChatCompletionMessageToolCall) UnmarshalJSON(data []byte) error

type ChatCompletionMessageToolCallFunction

type ChatCompletionMessageToolCallFunction struct {
	// The arguments to call the function with, as generated by the model in JSON
	// format. Note that the model does not always generate valid JSON, and may
	// hallucinate parameters not defined by your function schema. Validate the
	// arguments in your code before calling your function.
	Arguments string `json:"arguments,required"`
	// The name of the function to call.
	Name string `json:"name,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The function that the model called.

func (ChatCompletionMessageToolCallFunction) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionMessageToolCallFunction) UnmarshalJSON

func (r *ChatCompletionMessageToolCallFunction) UnmarshalJSON(data []byte) error

type ChatCompletionMessageToolCallFunctionParam

type ChatCompletionMessageToolCallFunctionParam struct {
	// The arguments to call the function with, as generated by the model in JSON
	// format. Note that the model does not always generate valid JSON, and may
	// hallucinate parameters not defined by your function schema. Validate the
	// arguments in your code before calling your function.
	Arguments string `json:"arguments,required"`
	// The name of the function to call.
	Name string `json:"name,required"`
	// contains filtered or unexported fields
}

The function that the model called.

The properties Arguments, Name are required.

func (ChatCompletionMessageToolCallFunctionParam) MarshalJSON

func (r ChatCompletionMessageToolCallFunctionParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionMessageToolCallFunctionParam) UnmarshalJSON

func (r *ChatCompletionMessageToolCallFunctionParam) UnmarshalJSON(data []byte) error

type ChatCompletionMessageToolCallParam

type ChatCompletionMessageToolCallParam struct {
	// The ID of the tool call.
	ID string `json:"id,required"`
	// The function that the model called.
	Function ChatCompletionMessageToolCallFunctionParam `json:"function,omitzero,required"`
	// The type of the tool. Currently, only `function` is supported.
	//
	// This field can be elided, and will marshal its zero value as "function".
	Type constant.Function `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ID, Function, Type are required.

func (ChatCompletionMessageToolCallParam) MarshalJSON

func (r ChatCompletionMessageToolCallParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionMessageToolCallParam) UnmarshalJSON

func (r *ChatCompletionMessageToolCallParam) UnmarshalJSON(data []byte) error

type ChatCompletionNamedToolChoiceFunctionParam

type ChatCompletionNamedToolChoiceFunctionParam struct {
	// The name of the function to call.
	Name string `json:"name,required"`
	// contains filtered or unexported fields
}

The property Name is required.

func (ChatCompletionNamedToolChoiceFunctionParam) MarshalJSON

func (r ChatCompletionNamedToolChoiceFunctionParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionNamedToolChoiceFunctionParam) UnmarshalJSON

func (r *ChatCompletionNamedToolChoiceFunctionParam) UnmarshalJSON(data []byte) error

type ChatCompletionNamedToolChoiceParam

type ChatCompletionNamedToolChoiceParam struct {
	Function ChatCompletionNamedToolChoiceFunctionParam `json:"function,omitzero,required"`
	// The type of the tool. Currently, only `function` is supported.
	//
	// This field can be elided, and will marshal its zero value as "function".
	Type constant.Function `json:"type,required"`
	// contains filtered or unexported fields
}

Specifies a tool the model should use. Use to force the model to call a specific function.

The properties Function, Type are required.

func (ChatCompletionNamedToolChoiceParam) MarshalJSON

func (r ChatCompletionNamedToolChoiceParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionNamedToolChoiceParam) UnmarshalJSON

func (r *ChatCompletionNamedToolChoiceParam) UnmarshalJSON(data []byte) error

type ChatCompletionNewParams

type ChatCompletionNewParams struct {
	// A list of messages comprising the conversation so far. Depending on the
	// [model](https://platform.openai.com/docs/models) you use, different message
	// types (modalities) are supported, like
	// [text](https://platform.openai.com/docs/guides/text-generation),
	// [images](https://platform.openai.com/docs/guides/vision), and
	// [audio](https://platform.openai.com/docs/guides/audio).
	Messages []ChatCompletionMessageParamUnion `json:"messages,omitzero,required"`
	// Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
	// wide range of models with different capabilities, performance characteristics,
	// and price points. Refer to the
	// [model guide](https://platform.openai.com/docs/models) to browse and compare
	// available models.
	Model shared.ChatModel `json:"model,omitzero,required"`
	// Number between -2.0 and 2.0. Positive values penalize new tokens based on their
	// existing frequency in the text so far, decreasing the model's likelihood to
	// repeat the same line verbatim.
	FrequencyPenalty param.Opt[float64] `json:"frequency_penalty,omitzero"`
	// Whether to return log probabilities of the output tokens or not. If true,
	// returns the log probabilities of each output token returned in the `content` of
	// `message`.
	Logprobs param.Opt[bool] `json:"logprobs,omitzero"`
	// An upper bound for the number of tokens that can be generated for a completion,
	// including visible output tokens and
	// [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
	MaxCompletionTokens param.Opt[int64] `json:"max_completion_tokens,omitzero"`
	// The maximum number of [tokens](/tokenizer) that can be generated in the chat
	// completion. This value can be used to control
	// [costs](https://openai.com/api/pricing/) for text generated via API.
	//
	// This value is now deprecated in favor of `max_completion_tokens`, and is not
	// compatible with
	// [o-series models](https://platform.openai.com/docs/guides/reasoning).
	MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"`
	// How many chat completion choices to generate for each input message. Note that
	// you will be charged based on the number of generated tokens across all of the
	// choices. Keep `n` as `1` to minimize costs.
	N param.Opt[int64] `json:"n,omitzero"`
	// Number between -2.0 and 2.0. Positive values penalize new tokens based on
	// whether they appear in the text so far, increasing the model's likelihood to
	// talk about new topics.
	PresencePenalty param.Opt[float64] `json:"presence_penalty,omitzero"`
	// This feature is in Beta. If specified, our system will make a best effort to
	// sample deterministically, such that repeated requests with the same `seed` and
	// parameters should return the same result. Determinism is not guaranteed, and you
	// should refer to the `system_fingerprint` response parameter to monitor changes
	// in the backend.
	Seed param.Opt[int64] `json:"seed,omitzero"`
	// Whether or not to store the output of this chat completion request for use in
	// our [model distillation](https://platform.openai.com/docs/guides/distillation)
	// or [evals](https://platform.openai.com/docs/guides/evals) products.
	Store param.Opt[bool] `json:"store,omitzero"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic. We generally recommend altering this or `top_p` but
	// not both.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// An integer between 0 and 20 specifying the number of most likely tokens to
	// return at each token position, each with an associated log probability.
	// `logprobs` must be set to `true` if this parameter is used.
	TopLogprobs param.Opt[int64] `json:"top_logprobs,omitzero"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or `temperature` but not both.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// Whether to enable
	// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
	// during tool use.
	ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"`
	// A stable identifier for your end-users. Used to boost cache hit rates by better
	// bucketing similar requests and to help OpenAI detect and prevent abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
	User param.Opt[string] `json:"user,omitzero"`
	// Parameters for audio output. Required when audio output is requested with
	// `modalities: ["audio"]`.
	// [Learn more](https://platform.openai.com/docs/guides/audio).
	Audio ChatCompletionAudioParam `json:"audio,omitzero"`
	// Modify the likelihood of specified tokens appearing in the completion.
	//
	// Accepts a JSON object that maps tokens (specified by their token ID in the
	// tokenizer) to an associated bias value from -100 to 100. Mathematically, the
	// bias is added to the logits generated by the model prior to sampling. The exact
	// effect will vary per model, but values between -1 and 1 should decrease or
	// increase likelihood of selection; values like -100 or 100 should result in a ban
	// or exclusive selection of the relevant token.
	LogitBias map[string]int64 `json:"logit_bias,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// Output types that you would like the model to generate. Most models are capable
	// of generating text, which is the default:
	//
	// `["text"]`
	//
	// The `gpt-4o-audio-preview` model can also be used to
	// [generate audio](https://platform.openai.com/docs/guides/audio). To request that
	// this model generate both text and audio responses, you can use:
	//
	// `["text", "audio"]`
	//
	// Any of "text", "audio".
	Modalities []string `json:"modalities,omitzero"`
	// **o-series models only**
	//
	// Constrains effort on reasoning for
	// [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
	// supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
	// result in faster responses and fewer tokens used on reasoning in a response.
	//
	// Any of "low", "medium", "high".
	ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
	// Specifies the latency tier to use for processing the request. This parameter is
	// relevant for customers subscribed to the scale tier service:
	//
	//   - If set to 'auto', and the Project is Scale tier enabled, the system will
	//     utilize scale tier credits until they are exhausted.
	//   - If set to 'auto', and the Project is not Scale tier enabled, the request will
	//     be processed using the default service tier with a lower uptime SLA and no
	//     latency guarantee.
	//   - If set to 'default', the request will be processed using the default service
	//     tier with a lower uptime SLA and no latency guarantee.
	//   - If set to 'flex', the request will be processed with the Flex Processing
	//     service tier.
	//     [Learn more](https://platform.openai.com/docs/guides/flex-processing).
	//   - When not set, the default behavior is 'auto'.
	//
	// When this parameter is set, the response body will include the `service_tier`
	// utilized.
	//
	// Any of "auto", "default", "flex", "scale".
	ServiceTier ChatCompletionNewParamsServiceTier `json:"service_tier,omitzero"`
	// Not supported with latest reasoning models `o3` and `o4-mini`.
	//
	// Up to 4 sequences where the API will stop generating further tokens. The
	// returned text will not contain the stop sequence.
	Stop ChatCompletionNewParamsStopUnion `json:"stop,omitzero"`
	// Options for streaming response. Only set this when you set `stream: true`.
	StreamOptions ChatCompletionStreamOptionsParam `json:"stream_options,omitzero"`
	// Deprecated in favor of `tool_choice`.
	//
	// Controls which (if any) function is called by the model.
	//
	// `none` means the model will not call a function and instead generates a message.
	//
	// `auto` means the model can pick between generating a message or calling a
	// function.
	//
	// Specifying a particular function via `{"name": "my_function"}` forces the model
	// to call that function.
	//
	// `none` is the default when no functions are present. `auto` is the default if
	// functions are present.
	FunctionCall ChatCompletionNewParamsFunctionCallUnion `json:"function_call,omitzero"`
	// Deprecated in favor of `tools`.
	//
	// A list of functions the model may generate JSON inputs for.
	Functions []ChatCompletionNewParamsFunction `json:"functions,omitzero"`
	// Static predicted output content, such as the content of a text file that is
	// being regenerated.
	Prediction ChatCompletionPredictionContentParam `json:"prediction,omitzero"`
	// An object specifying the format that the model must output.
	//
	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
	// Outputs which ensures the model will match your supplied JSON schema. Learn more
	// in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// Setting to `{ "type": "json_object" }` enables the older JSON mode, which
	// ensures the message the model generates is valid JSON. Using `json_schema` is
	// preferred for models that support it.
	ResponseFormat ChatCompletionNewParamsResponseFormatUnion `json:"response_format,omitzero"`
	// Controls which (if any) tool is called by the model. `none` means the model will
	// not call any tool and instead generates a message. `auto` means the model can
	// pick between generating a message or calling one or more tools. `required` means
	// the model must call one or more tools. Specifying a particular tool via
	// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
	// call that tool.
	//
	// `none` is the default when no tools are present. `auto` is the default if tools
	// are present.
	ToolChoice ChatCompletionToolChoiceOptionUnionParam `json:"tool_choice,omitzero"`
	// A list of tools the model may call. Currently, only functions are supported as a
	// tool. Use this to provide a list of functions the model may generate JSON inputs
	// for. A max of 128 functions are supported.
	Tools []ChatCompletionToolParam `json:"tools,omitzero"`
	// This tool searches the web for relevant results to use in a response. Learn more
	// about the
	// [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
	WebSearchOptions ChatCompletionNewParamsWebSearchOptions `json:"web_search_options,omitzero"`
	// contains filtered or unexported fields
}

func (ChatCompletionNewParams) MarshalJSON

func (r ChatCompletionNewParams) MarshalJSON() (data []byte, err error)

func (*ChatCompletionNewParams) UnmarshalJSON

func (r *ChatCompletionNewParams) UnmarshalJSON(data []byte) error

type ChatCompletionNewParamsFunction deprecated

type ChatCompletionNewParamsFunction struct {
	// The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
	// underscores and dashes, with a maximum length of 64.
	Name string `json:"name,required"`
	// A description of what the function does, used by the model to choose when and
	// how to call the function.
	Description param.Opt[string] `json:"description,omitzero"`
	// The parameters the functions accepts, described as a JSON Schema object. See the
	// [guide](https://platform.openai.com/docs/guides/function-calling) for examples,
	// and the
	// [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
	// documentation about the format.
	//
	// Omitting `parameters` defines a function with an empty parameter list.
	Parameters shared.FunctionParameters `json:"parameters,omitzero"`
	// contains filtered or unexported fields
}

Deprecated: deprecated

The property Name is required.

func (ChatCompletionNewParamsFunction) MarshalJSON

func (r ChatCompletionNewParamsFunction) MarshalJSON() (data []byte, err error)

func (*ChatCompletionNewParamsFunction) UnmarshalJSON

func (r *ChatCompletionNewParamsFunction) UnmarshalJSON(data []byte) error

type ChatCompletionNewParamsFunctionCallFunctionCallMode

type ChatCompletionNewParamsFunctionCallFunctionCallMode string

`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.

const (
	ChatCompletionNewParamsFunctionCallFunctionCallModeNone ChatCompletionNewParamsFunctionCallFunctionCallMode = "none"
	ChatCompletionNewParamsFunctionCallFunctionCallModeAuto ChatCompletionNewParamsFunctionCallFunctionCallMode = "auto"
)

type ChatCompletionNewParamsFunctionCallUnion

type ChatCompletionNewParamsFunctionCallUnion struct {
	// Check if union is this variant with !param.IsOmitted(union.OfFunctionCallMode)
	OfFunctionCallMode   param.Opt[string]                      `json:",omitzero,inline"`
	OfFunctionCallOption *ChatCompletionFunctionCallOptionParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionNewParamsFunctionCallUnion) MarshalJSON

func (*ChatCompletionNewParamsFunctionCallUnion) UnmarshalJSON

func (u *ChatCompletionNewParamsFunctionCallUnion) UnmarshalJSON(data []byte) error

type ChatCompletionNewParamsResponseFormatUnion

type ChatCompletionNewParamsResponseFormatUnion struct {
	OfText       *shared.ResponseFormatTextParam       `json:",omitzero,inline"`
	OfJSONSchema *shared.ResponseFormatJSONSchemaParam `json:",omitzero,inline"`
	OfJSONObject *shared.ResponseFormatJSONObjectParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionNewParamsResponseFormatUnion) GetJSONSchema

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionNewParamsResponseFormatUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (ChatCompletionNewParamsResponseFormatUnion) MarshalJSON

func (*ChatCompletionNewParamsResponseFormatUnion) UnmarshalJSON

func (u *ChatCompletionNewParamsResponseFormatUnion) UnmarshalJSON(data []byte) error

type ChatCompletionNewParamsServiceTier

type ChatCompletionNewParamsServiceTier string

Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:

  • If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted.
  • If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](https://platform.openai.com/docs/guides/flex-processing).
  • When not set, the default behavior is 'auto'.

When this parameter is set, the response body will include the `service_tier` utilized.

const (
	ChatCompletionNewParamsServiceTierAuto    ChatCompletionNewParamsServiceTier = "auto"
	ChatCompletionNewParamsServiceTierDefault ChatCompletionNewParamsServiceTier = "default"
	ChatCompletionNewParamsServiceTierFlex    ChatCompletionNewParamsServiceTier = "flex"
	ChatCompletionNewParamsServiceTierScale   ChatCompletionNewParamsServiceTier = "scale"
)

type ChatCompletionNewParamsStopUnion

type ChatCompletionNewParamsStopUnion struct {
	OfString      param.Opt[string] `json:",omitzero,inline"`
	OfStringArray []string          `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionNewParamsStopUnion) MarshalJSON

func (u ChatCompletionNewParamsStopUnion) MarshalJSON() ([]byte, error)

func (*ChatCompletionNewParamsStopUnion) UnmarshalJSON

func (u *ChatCompletionNewParamsStopUnion) UnmarshalJSON(data []byte) error

type ChatCompletionNewParamsWebSearchOptions

type ChatCompletionNewParamsWebSearchOptions struct {
	// Approximate location parameters for the search.
	UserLocation ChatCompletionNewParamsWebSearchOptionsUserLocation `json:"user_location,omitzero"`
	// High level guidance for the amount of context window space to use for the
	// search. One of `low`, `medium`, or `high`. `medium` is the default.
	//
	// Any of "low", "medium", "high".
	SearchContextSize string `json:"search_context_size,omitzero"`
	// contains filtered or unexported fields
}

This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).

func (ChatCompletionNewParamsWebSearchOptions) MarshalJSON

func (r ChatCompletionNewParamsWebSearchOptions) MarshalJSON() (data []byte, err error)

func (*ChatCompletionNewParamsWebSearchOptions) UnmarshalJSON

func (r *ChatCompletionNewParamsWebSearchOptions) UnmarshalJSON(data []byte) error

type ChatCompletionNewParamsWebSearchOptionsUserLocation added in v1.1.0

type ChatCompletionNewParamsWebSearchOptionsUserLocation struct {
	// Approximate location parameters for the search.
	Approximate ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate `json:"approximate,omitzero,required"`
	// The type of location approximation. Always `approximate`.
	//
	// This field can be elided, and will marshal its zero value as "approximate".
	Type constant.Approximate `json:"type,required"`
	// contains filtered or unexported fields
}

Approximate location parameters for the search.

The properties Approximate, Type are required.

func (ChatCompletionNewParamsWebSearchOptionsUserLocation) MarshalJSON added in v1.1.0

func (r ChatCompletionNewParamsWebSearchOptionsUserLocation) MarshalJSON() (data []byte, err error)

func (*ChatCompletionNewParamsWebSearchOptionsUserLocation) UnmarshalJSON added in v1.1.0

type ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate added in v1.1.0

type ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate struct {
	// Free text input for the city of the user, e.g. `San Francisco`.
	City param.Opt[string] `json:"city,omitzero"`
	// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
	// the user, e.g. `US`.
	Country param.Opt[string] `json:"country,omitzero"`
	// Free text input for the region of the user, e.g. `California`.
	Region param.Opt[string] `json:"region,omitzero"`
	// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
	// user, e.g. `America/Los_Angeles`.
	Timezone param.Opt[string] `json:"timezone,omitzero"`
	// contains filtered or unexported fields
}

Approximate location parameters for the search.

func (ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate) MarshalJSON added in v1.1.0

func (*ChatCompletionNewParamsWebSearchOptionsUserLocationApproximate) UnmarshalJSON added in v1.1.0

type ChatCompletionPredictionContentContentUnionParam

type ChatCompletionPredictionContentContentUnionParam struct {
	OfString              param.Opt[string]                    `json:",omitzero,inline"`
	OfArrayOfContentParts []ChatCompletionContentPartTextParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionPredictionContentContentUnionParam) MarshalJSON

func (*ChatCompletionPredictionContentContentUnionParam) UnmarshalJSON

type ChatCompletionPredictionContentParam

type ChatCompletionPredictionContentParam struct {
	// The content that should be matched when generating a model response. If
	// generated tokens would match this content, the entire model response can be
	// returned much more quickly.
	Content ChatCompletionPredictionContentContentUnionParam `json:"content,omitzero,required"`
	// The type of the predicted content you want to provide. This type is currently
	// always `content`.
	//
	// This field can be elided, and will marshal its zero value as "content".
	Type constant.Content `json:"type,required"`
	// contains filtered or unexported fields
}

Static predicted output content, such as the content of a text file that is being regenerated.

The properties Content, Type are required.

func (ChatCompletionPredictionContentParam) MarshalJSON

func (r ChatCompletionPredictionContentParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionPredictionContentParam) UnmarshalJSON

func (r *ChatCompletionPredictionContentParam) UnmarshalJSON(data []byte) error

type ChatCompletionService

type ChatCompletionService struct {
	Options  []option.RequestOption
	Messages ChatCompletionMessageService
}

ChatCompletionService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChatCompletionService method instead.

func NewChatCompletionService

func NewChatCompletionService(opts ...option.RequestOption) (r ChatCompletionService)

NewChatCompletionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ChatCompletionService) Delete

func (r *ChatCompletionService) Delete(ctx context.Context, completionID string, opts ...option.RequestOption) (res *ChatCompletionDeleted, err error)

Delete a stored chat completion. Only Chat Completions that have been created with the `store` parameter set to `true` can be deleted.

func (*ChatCompletionService) Get

func (r *ChatCompletionService) Get(ctx context.Context, completionID string, opts ...option.RequestOption) (res *ChatCompletion, err error)

Get a stored chat completion. Only Chat Completions that have been created with the `store` parameter set to `true` will be returned.

func (*ChatCompletionService) List

List stored Chat Completions. Only Chat Completions that have been stored with the `store` parameter set to `true` will be returned.

func (*ChatCompletionService) ListAutoPaging

List stored Chat Completions. Only Chat Completions that have been stored with the `store` parameter set to `true` will be returned.

func (*ChatCompletionService) New

**Starting a new project?** We recommend trying [Responses](https://platform.openai.com/docs/api-reference/responses) to take advantage of the latest OpenAI platform features. Compare [Chat Completions with Responses](https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses).

---

Creates a model response for the given chat conversation. Learn more in the [text generation](https://platform.openai.com/docs/guides/text-generation), [vision](https://platform.openai.com/docs/guides/vision), and [audio](https://platform.openai.com/docs/guides/audio) guides.

Parameter support can differ depending on the model used to generate the response, particularly for newer reasoning models. Parameters that are only supported for reasoning models are noted below. For the current state of unsupported parameters in reasoning models, [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).

func (*ChatCompletionService) NewStreaming

**Starting a new project?** We recommend trying [Responses](https://platform.openai.com/docs/api-reference/responses) to take advantage of the latest OpenAI platform features. Compare [Chat Completions with Responses](https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses).

---

Creates a model response for the given chat conversation. Learn more in the [text generation](https://platform.openai.com/docs/guides/text-generation), [vision](https://platform.openai.com/docs/guides/vision), and [audio](https://platform.openai.com/docs/guides/audio) guides.

Parameter support can differ depending on the model used to generate the response, particularly for newer reasoning models. Parameters that are only supported for reasoning models are noted below. For the current state of unsupported parameters in reasoning models, [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).

func (*ChatCompletionService) Update

func (r *ChatCompletionService) Update(ctx context.Context, completionID string, body ChatCompletionUpdateParams, opts ...option.RequestOption) (res *ChatCompletion, err error)

Modify a stored chat completion. Only Chat Completions that have been created with the `store` parameter set to `true` can be modified. Currently, the only supported modification is to update the `metadata` field.

type ChatCompletionServiceTier

type ChatCompletionServiceTier string

Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:

  • If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted.
  • If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarantee.
  • If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](https://platform.openai.com/docs/guides/flex-processing).
  • When not set, the default behavior is 'auto'.

When this parameter is set, the response body will include the `service_tier` utilized.

const (
	ChatCompletionServiceTierAuto    ChatCompletionServiceTier = "auto"
	ChatCompletionServiceTierDefault ChatCompletionServiceTier = "default"
	ChatCompletionServiceTierFlex    ChatCompletionServiceTier = "flex"
	ChatCompletionServiceTierScale   ChatCompletionServiceTier = "scale"
)

type ChatCompletionStoreMessage

type ChatCompletionStoreMessage struct {
	// The identifier of the chat message.
	ID string `json:"id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
	ChatCompletionMessage
}

A chat completion message generated by the model.

func (ChatCompletionStoreMessage) RawJSON

func (r ChatCompletionStoreMessage) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletionStoreMessage) UnmarshalJSON

func (r *ChatCompletionStoreMessage) UnmarshalJSON(data []byte) error

type ChatCompletionStreamOptionsParam

type ChatCompletionStreamOptionsParam struct {
	// If set, an additional chunk will be streamed before the `data: [DONE]` message.
	// The `usage` field on this chunk shows the token usage statistics for the entire
	// request, and the `choices` field will always be an empty array.
	//
	// All other chunks will also include a `usage` field, but with a null value.
	// **NOTE:** If the stream is interrupted, you may not receive the final usage
	// chunk which contains the total token usage for the request.
	IncludeUsage param.Opt[bool] `json:"include_usage,omitzero"`
	// contains filtered or unexported fields
}

Options for streaming response. Only set this when you set `stream: true`.

func (ChatCompletionStreamOptionsParam) MarshalJSON

func (r ChatCompletionStreamOptionsParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionStreamOptionsParam) UnmarshalJSON

func (r *ChatCompletionStreamOptionsParam) UnmarshalJSON(data []byte) error

type ChatCompletionSystemMessageParam

type ChatCompletionSystemMessageParam struct {
	// The contents of the system message.
	Content ChatCompletionSystemMessageParamContentUnion `json:"content,omitzero,required"`
	// An optional name for the participant. Provides the model information to
	// differentiate between participants of the same role.
	Name param.Opt[string] `json:"name,omitzero"`
	// The role of the messages author, in this case `system`.
	//
	// This field can be elided, and will marshal its zero value as "system".
	Role constant.System `json:"role,required"`
	// contains filtered or unexported fields
}

Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, use `developer` messages for this purpose instead.

The properties Content, Role are required.

func (ChatCompletionSystemMessageParam) MarshalJSON

func (r ChatCompletionSystemMessageParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionSystemMessageParam) UnmarshalJSON

func (r *ChatCompletionSystemMessageParam) UnmarshalJSON(data []byte) error

type ChatCompletionSystemMessageParamContentUnion

type ChatCompletionSystemMessageParamContentUnion struct {
	OfString              param.Opt[string]                    `json:",omitzero,inline"`
	OfArrayOfContentParts []ChatCompletionContentPartTextParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionSystemMessageParamContentUnion) MarshalJSON

func (*ChatCompletionSystemMessageParamContentUnion) UnmarshalJSON

func (u *ChatCompletionSystemMessageParamContentUnion) UnmarshalJSON(data []byte) error

type ChatCompletionTokenLogprob

type ChatCompletionTokenLogprob struct {
	// The token.
	Token string `json:"token,required"`
	// A list of integers representing the UTF-8 bytes representation of the token.
	// Useful in instances where characters are represented by multiple tokens and
	// their byte representations must be combined to generate the correct text
	// representation. Can be `null` if there is no bytes representation for the token.
	Bytes []int64 `json:"bytes,required"`
	// The log probability of this token, if it is within the top 20 most likely
	// tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
	// unlikely.
	Logprob float64 `json:"logprob,required"`
	// List of the most likely tokens and their log probability, at this token
	// position. In rare cases, there may be fewer than the number of requested
	// `top_logprobs` returned.
	TopLogprobs []ChatCompletionTokenLogprobTopLogprob `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
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionTokenLogprob) RawJSON

func (r ChatCompletionTokenLogprob) RawJSON() string

Returns the unmodified JSON received from the API

func (*ChatCompletionTokenLogprob) UnmarshalJSON

func (r *ChatCompletionTokenLogprob) UnmarshalJSON(data []byte) error

type ChatCompletionTokenLogprobTopLogprob

type ChatCompletionTokenLogprobTopLogprob struct {
	// The token.
	Token string `json:"token,required"`
	// A list of integers representing the UTF-8 bytes representation of the token.
	// Useful in instances where characters are represented by multiple tokens and
	// their byte representations must be combined to generate the correct text
	// representation. Can be `null` if there is no bytes representation for the token.
	Bytes []int64 `json:"bytes,required"`
	// The log probability of this token, if it is within the top 20 most likely
	// tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
	// unlikely.
	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
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ChatCompletionTokenLogprobTopLogprob) RawJSON

Returns the unmodified JSON received from the API

func (*ChatCompletionTokenLogprobTopLogprob) UnmarshalJSON

func (r *ChatCompletionTokenLogprobTopLogprob) UnmarshalJSON(data []byte) error

type ChatCompletionToolChoiceOptionAuto

type ChatCompletionToolChoiceOptionAuto string

`none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.

const (
	ChatCompletionToolChoiceOptionAutoNone     ChatCompletionToolChoiceOptionAuto = "none"
	ChatCompletionToolChoiceOptionAutoAuto     ChatCompletionToolChoiceOptionAuto = "auto"
	ChatCompletionToolChoiceOptionAutoRequired ChatCompletionToolChoiceOptionAuto = "required"
)

type ChatCompletionToolChoiceOptionUnionParam

type ChatCompletionToolChoiceOptionUnionParam struct {
	// Check if union is this variant with !param.IsOmitted(union.OfAuto)
	OfAuto                          param.Opt[string]                   `json:",omitzero,inline"`
	OfChatCompletionNamedToolChoice *ChatCompletionNamedToolChoiceParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func ChatCompletionToolChoiceOptionParamOfChatCompletionNamedToolChoice added in v1.1.0

func ChatCompletionToolChoiceOptionParamOfChatCompletionNamedToolChoice(function ChatCompletionNamedToolChoiceFunctionParam) ChatCompletionToolChoiceOptionUnionParam

func (ChatCompletionToolChoiceOptionUnionParam) MarshalJSON

func (*ChatCompletionToolChoiceOptionUnionParam) UnmarshalJSON

func (u *ChatCompletionToolChoiceOptionUnionParam) UnmarshalJSON(data []byte) error

type ChatCompletionToolMessageParam

type ChatCompletionToolMessageParam struct {
	// The contents of the tool message.
	Content ChatCompletionToolMessageParamContentUnion `json:"content,omitzero,required"`
	// Tool call that this message is responding to.
	ToolCallID string `json:"tool_call_id,required"`
	// The role of the messages author, in this case `tool`.
	//
	// This field can be elided, and will marshal its zero value as "tool".
	Role constant.Tool `json:"role,required"`
	// contains filtered or unexported fields
}

The properties Content, Role, ToolCallID are required.

func (ChatCompletionToolMessageParam) MarshalJSON

func (r ChatCompletionToolMessageParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionToolMessageParam) UnmarshalJSON

func (r *ChatCompletionToolMessageParam) UnmarshalJSON(data []byte) error

type ChatCompletionToolMessageParamContentUnion

type ChatCompletionToolMessageParamContentUnion struct {
	OfString              param.Opt[string]                    `json:",omitzero,inline"`
	OfArrayOfContentParts []ChatCompletionContentPartTextParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionToolMessageParamContentUnion) MarshalJSON

func (*ChatCompletionToolMessageParamContentUnion) UnmarshalJSON

func (u *ChatCompletionToolMessageParamContentUnion) UnmarshalJSON(data []byte) error

type ChatCompletionToolParam

type ChatCompletionToolParam struct {
	Function shared.FunctionDefinitionParam `json:"function,omitzero,required"`
	// The type of the tool. Currently, only `function` is supported.
	//
	// This field can be elided, and will marshal its zero value as "function".
	Type constant.Function `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Function, Type are required.

func (ChatCompletionToolParam) MarshalJSON

func (r ChatCompletionToolParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionToolParam) UnmarshalJSON

func (r *ChatCompletionToolParam) UnmarshalJSON(data []byte) error

type ChatCompletionUpdateParams

type ChatCompletionUpdateParams struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero,required"`
	// contains filtered or unexported fields
}

func (ChatCompletionUpdateParams) MarshalJSON

func (r ChatCompletionUpdateParams) MarshalJSON() (data []byte, err error)

func (*ChatCompletionUpdateParams) UnmarshalJSON

func (r *ChatCompletionUpdateParams) UnmarshalJSON(data []byte) error

type ChatCompletionUserMessageParam

type ChatCompletionUserMessageParam struct {
	// The contents of the user message.
	Content ChatCompletionUserMessageParamContentUnion `json:"content,omitzero,required"`
	// An optional name for the participant. Provides the model information to
	// differentiate between participants of the same role.
	Name param.Opt[string] `json:"name,omitzero"`
	// The role of the messages author, in this case `user`.
	//
	// This field can be elided, and will marshal its zero value as "user".
	Role constant.User `json:"role,required"`
	// contains filtered or unexported fields
}

Messages sent by an end user, containing prompts or additional context information.

The properties Content, Role are required.

func (ChatCompletionUserMessageParam) MarshalJSON

func (r ChatCompletionUserMessageParam) MarshalJSON() (data []byte, err error)

func (*ChatCompletionUserMessageParam) UnmarshalJSON

func (r *ChatCompletionUserMessageParam) UnmarshalJSON(data []byte) error

type ChatCompletionUserMessageParamContentUnion

type ChatCompletionUserMessageParamContentUnion struct {
	OfString              param.Opt[string]                     `json:",omitzero,inline"`
	OfArrayOfContentParts []ChatCompletionContentPartUnionParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ChatCompletionUserMessageParamContentUnion) MarshalJSON

func (*ChatCompletionUserMessageParamContentUnion) UnmarshalJSON

func (u *ChatCompletionUserMessageParamContentUnion) UnmarshalJSON(data []byte) error

type ChatModel

type ChatModel = shared.ChatModel

This is an alias to an internal type.

type ChatService

type ChatService struct {
	Options     []option.RequestOption
	Completions ChatCompletionService
}

ChatService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChatService method instead.

func NewChatService

func NewChatService(opts ...option.RequestOption) (r ChatService)

NewChatService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type Client

type Client struct {
	Options      []option.RequestOption
	Completions  CompletionService
	Chat         ChatService
	Embeddings   EmbeddingService
	Files        FileService
	Images       ImageService
	Audio        AudioService
	Moderations  ModerationService
	Models       ModelService
	FineTuning   FineTuningService
	Graders      GraderService
	VectorStores VectorStoreService
	Beta         BetaService
	Batches      BatchService
	Uploads      UploadService
	Responses    responses.ResponseService
	Containers   ContainerService
}

Client creates a struct with services and top level methods that help with interacting with the openai API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (OPENAI_API_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID, OPENAI_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type CodeInterpreterLogs added in v1.1.0

type CodeInterpreterLogs struct {
	// The index of the output in the outputs array.
	Index int64 `json:"index,required"`
	// Always `logs`.
	Type constant.Logs `json:"type,required"`
	// The text output from the Code Interpreter tool call.
	Logs string `json:"logs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		Logs        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Text output from the Code Interpreter tool call as part of a run step.

func (CodeInterpreterLogs) RawJSON added in v1.1.0

func (r CodeInterpreterLogs) RawJSON() string

Returns the unmodified JSON received from the API

func (*CodeInterpreterLogs) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterLogs) UnmarshalJSON(data []byte) error

type CodeInterpreterOutputImage added in v1.1.0

type CodeInterpreterOutputImage struct {
	// The index of the output in the outputs array.
	Index int64 `json:"index,required"`
	// Always `image`.
	Type  constant.Image                  `json:"type,required"`
	Image CodeInterpreterOutputImageImage `json:"image"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		Image       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeInterpreterOutputImage) RawJSON added in v1.1.0

func (r CodeInterpreterOutputImage) RawJSON() string

Returns the unmodified JSON received from the API

func (*CodeInterpreterOutputImage) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterOutputImage) UnmarshalJSON(data []byte) error

type CodeInterpreterOutputImageImage added in v1.1.0

type CodeInterpreterOutputImageImage struct {
	// The [file](https://platform.openai.com/docs/api-reference/files) ID of the
	// image.
	FileID string `json:"file_id"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeInterpreterOutputImageImage) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterOutputImageImage) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterOutputImageImage) UnmarshalJSON(data []byte) error

type CodeInterpreterTool added in v1.1.0

type CodeInterpreterTool struct {
	// The type of tool being defined: `code_interpreter`
	Type constant.CodeInterpreter `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeInterpreterTool) RawJSON added in v1.1.0

func (r CodeInterpreterTool) RawJSON() string

Returns the unmodified JSON received from the API

func (CodeInterpreterTool) ToParam added in v1.1.0

ToParam converts this CodeInterpreterTool to a CodeInterpreterToolParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with CodeInterpreterToolParam.Overrides()

func (*CodeInterpreterTool) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterTool) UnmarshalJSON(data []byte) error

type CodeInterpreterToolCall added in v1.1.0

type CodeInterpreterToolCall struct {
	// The ID of the tool call.
	ID string `json:"id,required"`
	// The Code Interpreter tool call definition.
	CodeInterpreter CodeInterpreterToolCallCodeInterpreter `json:"code_interpreter,required"`
	// The type of tool call. This is always going to be `code_interpreter` for this
	// type of tool call.
	Type constant.CodeInterpreter `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID              respjson.Field
		CodeInterpreter respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details of the Code Interpreter tool call the run step was involved in.

func (CodeInterpreterToolCall) RawJSON added in v1.1.0

func (r CodeInterpreterToolCall) RawJSON() string

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCall) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterToolCall) UnmarshalJSON(data []byte) error

type CodeInterpreterToolCallCodeInterpreter added in v1.1.0

type CodeInterpreterToolCallCodeInterpreter struct {
	// The input to the Code Interpreter tool call.
	Input string `json:"input,required"`
	// The outputs from the Code Interpreter tool call. Code Interpreter can output one
	// or more items, including text (`logs`) or images (`image`). Each of these are
	// represented by a different object type.
	Outputs []CodeInterpreterToolCallCodeInterpreterOutputUnion `json:"outputs,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Input       respjson.Field
		Outputs     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The Code Interpreter tool call definition.

func (CodeInterpreterToolCallCodeInterpreter) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallCodeInterpreter) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterToolCallCodeInterpreter) UnmarshalJSON(data []byte) error

type CodeInterpreterToolCallCodeInterpreterOutputImage added in v1.1.0

type CodeInterpreterToolCallCodeInterpreterOutputImage struct {
	Image CodeInterpreterToolCallCodeInterpreterOutputImageImage `json:"image,required"`
	// Always `image`.
	Type constant.Image `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Image       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeInterpreterToolCallCodeInterpreterOutputImage) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallCodeInterpreterOutputImage) UnmarshalJSON added in v1.1.0

type CodeInterpreterToolCallCodeInterpreterOutputImageImage added in v1.1.0

type CodeInterpreterToolCallCodeInterpreterOutputImageImage struct {
	// The [file](https://platform.openai.com/docs/api-reference/files) ID of the
	// image.
	FileID string `json:"file_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeInterpreterToolCallCodeInterpreterOutputImageImage) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallCodeInterpreterOutputImageImage) UnmarshalJSON added in v1.1.0

type CodeInterpreterToolCallCodeInterpreterOutputLogs added in v1.1.0

type CodeInterpreterToolCallCodeInterpreterOutputLogs struct {
	// The text output from the Code Interpreter tool call.
	Logs string `json:"logs,required"`
	// Always `logs`.
	Type constant.Logs `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Logs        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Text output from the Code Interpreter tool call as part of a run step.

func (CodeInterpreterToolCallCodeInterpreterOutputLogs) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallCodeInterpreterOutputLogs) UnmarshalJSON added in v1.1.0

type CodeInterpreterToolCallCodeInterpreterOutputUnion added in v1.1.0

type CodeInterpreterToolCallCodeInterpreterOutputUnion struct {
	// This field is from variant [CodeInterpreterToolCallCodeInterpreterOutputLogs].
	Logs string `json:"logs"`
	// Any of "logs", "image".
	Type string `json:"type"`
	// This field is from variant [CodeInterpreterToolCallCodeInterpreterOutputImage].
	Image CodeInterpreterToolCallCodeInterpreterOutputImageImage `json:"image"`
	JSON  struct {
		Logs  respjson.Field
		Type  respjson.Field
		Image respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

CodeInterpreterToolCallCodeInterpreterOutputUnion contains all possible properties and values from CodeInterpreterToolCallCodeInterpreterOutputLogs, CodeInterpreterToolCallCodeInterpreterOutputImage.

Use the CodeInterpreterToolCallCodeInterpreterOutputUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (CodeInterpreterToolCallCodeInterpreterOutputUnion) AsAny added in v1.1.0

func (u CodeInterpreterToolCallCodeInterpreterOutputUnion) AsAny() anyCodeInterpreterToolCallCodeInterpreterOutput

Use the following switch statement to find the correct variant

switch variant := CodeInterpreterToolCallCodeInterpreterOutputUnion.AsAny().(type) {
case openai.CodeInterpreterToolCallCodeInterpreterOutputLogs:
case openai.CodeInterpreterToolCallCodeInterpreterOutputImage:
default:
  fmt.Errorf("no variant present")
}

func (CodeInterpreterToolCallCodeInterpreterOutputUnion) AsImage added in v1.1.0

func (CodeInterpreterToolCallCodeInterpreterOutputUnion) AsLogs added in v1.1.0

func (CodeInterpreterToolCallCodeInterpreterOutputUnion) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallCodeInterpreterOutputUnion) UnmarshalJSON added in v1.1.0

type CodeInterpreterToolCallDelta added in v1.1.0

type CodeInterpreterToolCallDelta struct {
	// The index of the tool call in the tool calls array.
	Index int64 `json:"index,required"`
	// The type of tool call. This is always going to be `code_interpreter` for this
	// type of tool call.
	Type constant.CodeInterpreter `json:"type,required"`
	// The ID of the tool call.
	ID string `json:"id"`
	// The Code Interpreter tool call definition.
	CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter `json:"code_interpreter"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index           respjson.Field
		Type            respjson.Field
		ID              respjson.Field
		CodeInterpreter respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details of the Code Interpreter tool call the run step was involved in.

func (CodeInterpreterToolCallDelta) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallDelta) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterToolCallDelta) UnmarshalJSON(data []byte) error

type CodeInterpreterToolCallDeltaCodeInterpreter added in v1.1.0

type CodeInterpreterToolCallDeltaCodeInterpreter struct {
	// The input to the Code Interpreter tool call.
	Input string `json:"input"`
	// The outputs from the Code Interpreter tool call. Code Interpreter can output one
	// or more items, including text (`logs`) or images (`image`). Each of these are
	// represented by a different object type.
	Outputs []CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion `json:"outputs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Input       respjson.Field
		Outputs     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The Code Interpreter tool call definition.

func (CodeInterpreterToolCallDeltaCodeInterpreter) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallDeltaCodeInterpreter) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterToolCallDeltaCodeInterpreter) UnmarshalJSON(data []byte) error

type CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion added in v1.1.0

type CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion struct {
	Index int64 `json:"index"`
	// Any of "logs", "image".
	Type string `json:"type"`
	// This field is from variant [CodeInterpreterLogs].
	Logs string `json:"logs"`
	// This field is from variant [CodeInterpreterOutputImage].
	Image CodeInterpreterOutputImageImage `json:"image"`
	JSON  struct {
		Index respjson.Field
		Type  respjson.Field
		Logs  respjson.Field
		Image respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion contains all possible properties and values from CodeInterpreterLogs, CodeInterpreterOutputImage.

Use the CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) AsAny added in v1.1.0

func (u CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) AsAny() anyCodeInterpreterToolCallDeltaCodeInterpreterOutput

Use the following switch statement to find the correct variant

switch variant := CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion.AsAny().(type) {
case openai.CodeInterpreterLogs:
case openai.CodeInterpreterOutputImage:
default:
  fmt.Errorf("no variant present")
}

func (CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) AsImage added in v1.1.0

func (CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) AsLogs added in v1.1.0

func (CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) UnmarshalJSON added in v1.1.0

type CodeInterpreterToolParam added in v1.1.0

type CodeInterpreterToolParam struct {
	// The type of tool being defined: `code_interpreter`
	Type constant.CodeInterpreter `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewCodeInterpreterToolParam.

func NewCodeInterpreterToolParam added in v1.1.0

func NewCodeInterpreterToolParam() CodeInterpreterToolParam

func (CodeInterpreterToolParam) MarshalJSON added in v1.1.0

func (r CodeInterpreterToolParam) MarshalJSON() (data []byte, err error)

func (*CodeInterpreterToolParam) UnmarshalJSON added in v1.1.0

func (r *CodeInterpreterToolParam) UnmarshalJSON(data []byte) error

type ComparisonFilter

type ComparisonFilter = shared.ComparisonFilter

A filter used to compare a specified attribute key to a given value using a defined comparison operation.

This is an alias to an internal type.

type ComparisonFilterParam

type ComparisonFilterParam = shared.ComparisonFilterParam

A filter used to compare a specified attribute key to a given value using a defined comparison operation.

This is an alias to an internal type.

type ComparisonFilterType

type ComparisonFilterType = shared.ComparisonFilterType

Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.

- `eq`: equals - `ne`: not equal - `gt`: greater than - `gte`: greater than or equal - `lt`: less than - `lte`: less than or equal

This is an alias to an internal type.

type ComparisonFilterValueUnion

type ComparisonFilterValueUnion = shared.ComparisonFilterValueUnion

The value to compare against the attribute key; supports string, number, or boolean types.

This is an alias to an internal type.

type ComparisonFilterValueUnionParam

type ComparisonFilterValueUnionParam = shared.ComparisonFilterValueUnionParam

The value to compare against the attribute key; supports string, number, or boolean types.

This is an alias to an internal type.

type Completion

type Completion struct {
	// A unique identifier for the completion.
	ID string `json:"id,required"`
	// The list of completion choices the model generated for the input prompt.
	Choices []CompletionChoice `json:"choices,required"`
	// The Unix timestamp (in seconds) of when the completion was created.
	Created int64 `json:"created,required"`
	// The model used for completion.
	Model string `json:"model,required"`
	// The object type, which is always "text_completion"
	Object constant.TextCompletion `json:"object,required"`
	// This fingerprint represents the backend configuration that the model runs with.
	//
	// Can be used in conjunction with the `seed` request parameter to understand when
	// backend changes have been made that might impact determinism.
	SystemFingerprint string `json:"system_fingerprint"`
	// Usage statistics for the completion request.
	Usage CompletionUsage `json:"usage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		Choices           respjson.Field
		Created           respjson.Field
		Model             respjson.Field
		Object            respjson.Field
		SystemFingerprint respjson.Field
		Usage             respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).

func (Completion) RawJSON

func (r Completion) RawJSON() string

Returns the unmodified JSON received from the API

func (*Completion) UnmarshalJSON

func (r *Completion) UnmarshalJSON(data []byte) error

type CompletionChoice

type CompletionChoice struct {
	// The reason the model stopped generating tokens. This will be `stop` if the model
	// hit a natural stop point or a provided stop sequence, `length` if the maximum
	// number of tokens specified in the request was reached, or `content_filter` if
	// content was omitted due to a flag from our content filters.
	//
	// Any of "stop", "length", "content_filter".
	FinishReason CompletionChoiceFinishReason `json:"finish_reason,required"`
	Index        int64                        `json:"index,required"`
	Logprobs     CompletionChoiceLogprobs     `json:"logprobs,required"`
	Text         string                       `json:"text,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FinishReason respjson.Field
		Index        respjson.Field
		Logprobs     respjson.Field
		Text         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CompletionChoice) RawJSON

func (r CompletionChoice) RawJSON() string

Returns the unmodified JSON received from the API

func (*CompletionChoice) UnmarshalJSON

func (r *CompletionChoice) UnmarshalJSON(data []byte) error

type CompletionChoiceFinishReason

type CompletionChoiceFinishReason string

The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, or `content_filter` if content was omitted due to a flag from our content filters.

const (
	CompletionChoiceFinishReasonStop          CompletionChoiceFinishReason = "stop"
	CompletionChoiceFinishReasonLength        CompletionChoiceFinishReason = "length"
	CompletionChoiceFinishReasonContentFilter CompletionChoiceFinishReason = "content_filter"
)

type CompletionChoiceLogprobs

type CompletionChoiceLogprobs struct {
	TextOffset    []int64              `json:"text_offset"`
	TokenLogprobs []float64            `json:"token_logprobs"`
	Tokens        []string             `json:"tokens"`
	TopLogprobs   []map[string]float64 `json:"top_logprobs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		TextOffset    respjson.Field
		TokenLogprobs respjson.Field
		Tokens        respjson.Field
		TopLogprobs   respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CompletionChoiceLogprobs) RawJSON

func (r CompletionChoiceLogprobs) RawJSON() string

Returns the unmodified JSON received from the API

func (*CompletionChoiceLogprobs) UnmarshalJSON

func (r *CompletionChoiceLogprobs) UnmarshalJSON(data []byte) error

type CompletionNewParams

type CompletionNewParams struct {
	// The prompt(s) to generate completions for, encoded as a string, array of
	// strings, array of tokens, or array of token arrays.
	//
	// Note that <|endoftext|> is the document separator that the model sees during
	// training, so if a prompt is not specified the model will generate as if from the
	// beginning of a new document.
	Prompt CompletionNewParamsPromptUnion `json:"prompt,omitzero,required"`
	// ID of the model to use. You can use the
	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
	// see all of your available models, or see our
	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
	// them.
	Model CompletionNewParamsModel `json:"model,omitzero,required"`
	// Generates `best_of` completions server-side and returns the "best" (the one with
	// the highest log probability per token). Results cannot be streamed.
	//
	// When used with `n`, `best_of` controls the number of candidate completions and
	// `n` specifies how many to return – `best_of` must be greater than `n`.
	//
	// **Note:** Because this parameter generates many completions, it can quickly
	// consume your token quota. Use carefully and ensure that you have reasonable
	// settings for `max_tokens` and `stop`.
	BestOf param.Opt[int64] `json:"best_of,omitzero"`
	// Echo back the prompt in addition to the completion
	Echo param.Opt[bool] `json:"echo,omitzero"`
	// Number between -2.0 and 2.0. Positive values penalize new tokens based on their
	// existing frequency in the text so far, decreasing the model's likelihood to
	// repeat the same line verbatim.
	//
	// [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
	FrequencyPenalty param.Opt[float64] `json:"frequency_penalty,omitzero"`
	// Include the log probabilities on the `logprobs` most likely output tokens, as
	// well the chosen tokens. For example, if `logprobs` is 5, the API will return a
	// list of the 5 most likely tokens. The API will always return the `logprob` of
	// the sampled token, so there may be up to `logprobs+1` elements in the response.
	//
	// The maximum value for `logprobs` is 5.
	Logprobs param.Opt[int64] `json:"logprobs,omitzero"`
	// The maximum number of [tokens](/tokenizer) that can be generated in the
	// completion.
	//
	// The token count of your prompt plus `max_tokens` cannot exceed the model's
	// context length.
	// [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
	// for counting tokens.
	MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"`
	// How many completions to generate for each prompt.
	//
	// **Note:** Because this parameter generates many completions, it can quickly
	// consume your token quota. Use carefully and ensure that you have reasonable
	// settings for `max_tokens` and `stop`.
	N param.Opt[int64] `json:"n,omitzero"`
	// Number between -2.0 and 2.0. Positive values penalize new tokens based on
	// whether they appear in the text so far, increasing the model's likelihood to
	// talk about new topics.
	//
	// [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
	PresencePenalty param.Opt[float64] `json:"presence_penalty,omitzero"`
	// If specified, our system will make a best effort to sample deterministically,
	// such that repeated requests with the same `seed` and parameters should return
	// the same result.
	//
	// Determinism is not guaranteed, and you should refer to the `system_fingerprint`
	// response parameter to monitor changes in the backend.
	Seed param.Opt[int64] `json:"seed,omitzero"`
	// The suffix that comes after a completion of inserted text.
	//
	// This parameter is only supported for `gpt-3.5-turbo-instruct`.
	Suffix param.Opt[string] `json:"suffix,omitzero"`
	// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
	// make the output more random, while lower values like 0.2 will make it more
	// focused and deterministic.
	//
	// We generally recommend altering this or `top_p` but not both.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// An alternative to sampling with temperature, called nucleus sampling, where the
	// model considers the results of the tokens with top_p probability mass. So 0.1
	// means only the tokens comprising the top 10% probability mass are considered.
	//
	// We generally recommend altering this or `temperature` but not both.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// A unique identifier representing your end-user, which can help OpenAI to monitor
	// and detect abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
	User param.Opt[string] `json:"user,omitzero"`
	// Modify the likelihood of specified tokens appearing in the completion.
	//
	// Accepts a JSON object that maps tokens (specified by their token ID in the GPT
	// tokenizer) to an associated bias value from -100 to 100. You can use this
	// [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs.
	// Mathematically, the bias is added to the logits generated by the model prior to
	// sampling. The exact effect will vary per model, but values between -1 and 1
	// should decrease or increase likelihood of selection; values like -100 or 100
	// should result in a ban or exclusive selection of the relevant token.
	//
	// As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token
	// from being generated.
	LogitBias map[string]int64 `json:"logit_bias,omitzero"`
	// Not supported with latest reasoning models `o3` and `o4-mini`.
	//
	// Up to 4 sequences where the API will stop generating further tokens. The
	// returned text will not contain the stop sequence.
	Stop CompletionNewParamsStopUnion `json:"stop,omitzero"`
	// Options for streaming response. Only set this when you set `stream: true`.
	StreamOptions ChatCompletionStreamOptionsParam `json:"stream_options,omitzero"`
	// contains filtered or unexported fields
}

func (CompletionNewParams) MarshalJSON

func (r CompletionNewParams) MarshalJSON() (data []byte, err error)

func (*CompletionNewParams) UnmarshalJSON

func (r *CompletionNewParams) UnmarshalJSON(data []byte) error

type CompletionNewParamsModel

type CompletionNewParamsModel string

ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

const (
	CompletionNewParamsModelGPT3_5TurboInstruct CompletionNewParamsModel = "gpt-3.5-turbo-instruct"
	CompletionNewParamsModelDavinci002          CompletionNewParamsModel = "davinci-002"
	CompletionNewParamsModelBabbage002          CompletionNewParamsModel = "babbage-002"
)

type CompletionNewParamsPromptUnion

type CompletionNewParamsPromptUnion struct {
	OfString             param.Opt[string] `json:",omitzero,inline"`
	OfArrayOfStrings     []string          `json:",omitzero,inline"`
	OfArrayOfTokens      []int64           `json:",omitzero,inline"`
	OfArrayOfTokenArrays [][]int64         `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (CompletionNewParamsPromptUnion) MarshalJSON

func (u CompletionNewParamsPromptUnion) MarshalJSON() ([]byte, error)

func (*CompletionNewParamsPromptUnion) UnmarshalJSON

func (u *CompletionNewParamsPromptUnion) UnmarshalJSON(data []byte) error

type CompletionNewParamsStopUnion

type CompletionNewParamsStopUnion struct {
	OfString      param.Opt[string] `json:",omitzero,inline"`
	OfStringArray []string          `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (CompletionNewParamsStopUnion) MarshalJSON

func (u CompletionNewParamsStopUnion) MarshalJSON() ([]byte, error)

func (*CompletionNewParamsStopUnion) UnmarshalJSON

func (u *CompletionNewParamsStopUnion) UnmarshalJSON(data []byte) error

type CompletionService

type CompletionService struct {
	Options []option.RequestOption
}

CompletionService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCompletionService method instead.

func NewCompletionService

func NewCompletionService(opts ...option.RequestOption) (r CompletionService)

NewCompletionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*CompletionService) New

Creates a completion for the provided prompt and parameters.

func (*CompletionService) NewStreaming

func (r *CompletionService) NewStreaming(ctx context.Context, body CompletionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[Completion])

Creates a completion for the provided prompt and parameters.

type CompletionUsage

type CompletionUsage struct {
	// Number of tokens in the generated completion.
	CompletionTokens int64 `json:"completion_tokens,required"`
	// Number of tokens in the prompt.
	PromptTokens int64 `json:"prompt_tokens,required"`
	// Total number of tokens used in the request (prompt + completion).
	TotalTokens int64 `json:"total_tokens,required"`
	// Breakdown of tokens used in a completion.
	CompletionTokensDetails CompletionUsageCompletionTokensDetails `json:"completion_tokens_details"`
	// Breakdown of tokens used in the prompt.
	PromptTokensDetails CompletionUsagePromptTokensDetails `json:"prompt_tokens_details"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CompletionTokens        respjson.Field
		PromptTokens            respjson.Field
		TotalTokens             respjson.Field
		CompletionTokensDetails respjson.Field
		PromptTokensDetails     respjson.Field
		ExtraFields             map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Usage statistics for the completion request.

func (CompletionUsage) RawJSON

func (r CompletionUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*CompletionUsage) UnmarshalJSON

func (r *CompletionUsage) UnmarshalJSON(data []byte) error

type CompletionUsageCompletionTokensDetails

type CompletionUsageCompletionTokensDetails struct {
	// When using Predicted Outputs, the number of tokens in the prediction that
	// appeared in the completion.
	AcceptedPredictionTokens int64 `json:"accepted_prediction_tokens"`
	// Audio input tokens generated by the model.
	AudioTokens int64 `json:"audio_tokens"`
	// Tokens generated by the model for reasoning.
	ReasoningTokens int64 `json:"reasoning_tokens"`
	// When using Predicted Outputs, the number of tokens in the prediction that did
	// not appear in the completion. However, like reasoning tokens, these tokens are
	// still counted in the total completion tokens for purposes of billing, output,
	// and context window limits.
	RejectedPredictionTokens int64 `json:"rejected_prediction_tokens"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AcceptedPredictionTokens respjson.Field
		AudioTokens              respjson.Field
		ReasoningTokens          respjson.Field
		RejectedPredictionTokens respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Breakdown of tokens used in a completion.

func (CompletionUsageCompletionTokensDetails) RawJSON

Returns the unmodified JSON received from the API

func (*CompletionUsageCompletionTokensDetails) UnmarshalJSON

func (r *CompletionUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error

type CompletionUsagePromptTokensDetails

type CompletionUsagePromptTokensDetails struct {
	// Audio input tokens present in the prompt.
	AudioTokens int64 `json:"audio_tokens"`
	// Cached tokens present in the prompt.
	CachedTokens int64 `json:"cached_tokens"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AudioTokens  respjson.Field
		CachedTokens respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Breakdown of tokens used in the prompt.

func (CompletionUsagePromptTokensDetails) RawJSON

Returns the unmodified JSON received from the API

func (*CompletionUsagePromptTokensDetails) UnmarshalJSON

func (r *CompletionUsagePromptTokensDetails) UnmarshalJSON(data []byte) error

type CompoundFilter

type CompoundFilter = shared.CompoundFilter

Combine multiple filters using `and` or `or`.

This is an alias to an internal type.

type CompoundFilterParam

type CompoundFilterParam = shared.CompoundFilterParam

Combine multiple filters using `and` or `or`.

This is an alias to an internal type.

type CompoundFilterType

type CompoundFilterType = shared.CompoundFilterType

Type of operation: `and` or `or`.

This is an alias to an internal type.

type ContainerFileContentService added in v1.1.0

type ContainerFileContentService struct {
	Options []option.RequestOption
}

ContainerFileContentService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewContainerFileContentService method instead.

func NewContainerFileContentService added in v1.1.0

func NewContainerFileContentService(opts ...option.RequestOption) (r ContainerFileContentService)

NewContainerFileContentService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ContainerFileContentService) Get added in v1.1.0

func (r *ContainerFileContentService) Get(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (res *http.Response, err error)

Retrieve Container File Content

type ContainerFileGetResponse added in v1.1.0

type ContainerFileGetResponse struct {
	// Unique identifier for the file.
	ID string `json:"id,required"`
	// Size of the file in bytes.
	Bytes int64 `json:"bytes,required"`
	// The container this file belongs to.
	ContainerID string `json:"container_id,required"`
	// Unix timestamp (in seconds) when the file was created.
	CreatedAt int64 `json:"created_at,required"`
	// The type of this object (`container.file`).
	Object constant.ContainerFile `json:"object,required"`
	// Path of the file in the container.
	Path string `json:"path,required"`
	// Source of the file (e.g., `user`, `assistant`).
	Source string `json:"source,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Bytes       respjson.Field
		ContainerID respjson.Field
		CreatedAt   respjson.Field
		Object      respjson.Field
		Path        respjson.Field
		Source      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContainerFileGetResponse) RawJSON added in v1.1.0

func (r ContainerFileGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContainerFileGetResponse) UnmarshalJSON added in v1.1.0

func (r *ContainerFileGetResponse) UnmarshalJSON(data []byte) error

type ContainerFileListParams added in v1.1.0

type ContainerFileListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order ContainerFileListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ContainerFileListParams) URLQuery added in v1.1.0

func (r ContainerFileListParams) URLQuery() (v url.Values, err error)

URLQuery serializes ContainerFileListParams's query parameters as `url.Values`.

type ContainerFileListParamsOrder added in v1.1.0

type ContainerFileListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	ContainerFileListParamsOrderAsc  ContainerFileListParamsOrder = "asc"
	ContainerFileListParamsOrderDesc ContainerFileListParamsOrder = "desc"
)

type ContainerFileListResponse added in v1.1.0

type ContainerFileListResponse struct {
	// Unique identifier for the file.
	ID string `json:"id,required"`
	// Size of the file in bytes.
	Bytes int64 `json:"bytes,required"`
	// The container this file belongs to.
	ContainerID string `json:"container_id,required"`
	// Unix timestamp (in seconds) when the file was created.
	CreatedAt int64 `json:"created_at,required"`
	// The type of this object (`container.file`).
	Object constant.ContainerFile `json:"object,required"`
	// Path of the file in the container.
	Path string `json:"path,required"`
	// Source of the file (e.g., `user`, `assistant`).
	Source string `json:"source,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Bytes       respjson.Field
		ContainerID respjson.Field
		CreatedAt   respjson.Field
		Object      respjson.Field
		Path        respjson.Field
		Source      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContainerFileListResponse) RawJSON added in v1.1.0

func (r ContainerFileListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContainerFileListResponse) UnmarshalJSON added in v1.1.0

func (r *ContainerFileListResponse) UnmarshalJSON(data []byte) error

type ContainerFileNewParams added in v1.1.0

type ContainerFileNewParams struct {
	// Name of the file to create.
	FileID param.Opt[string] `json:"file_id,omitzero"`
	// The File object (not file name) to be uploaded.
	File io.Reader `json:"file,omitzero" format:"binary"`
	// contains filtered or unexported fields
}

func (ContainerFileNewParams) MarshalMultipart added in v1.1.0

func (r ContainerFileNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type ContainerFileNewResponse added in v1.1.0

type ContainerFileNewResponse struct {
	// Unique identifier for the file.
	ID string `json:"id,required"`
	// Size of the file in bytes.
	Bytes int64 `json:"bytes,required"`
	// The container this file belongs to.
	ContainerID string `json:"container_id,required"`
	// Unix timestamp (in seconds) when the file was created.
	CreatedAt int64 `json:"created_at,required"`
	// The type of this object (`container.file`).
	Object constant.ContainerFile `json:"object,required"`
	// Path of the file in the container.
	Path string `json:"path,required"`
	// Source of the file (e.g., `user`, `assistant`).
	Source string `json:"source,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Bytes       respjson.Field
		ContainerID respjson.Field
		CreatedAt   respjson.Field
		Object      respjson.Field
		Path        respjson.Field
		Source      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContainerFileNewResponse) RawJSON added in v1.1.0

func (r ContainerFileNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContainerFileNewResponse) UnmarshalJSON added in v1.1.0

func (r *ContainerFileNewResponse) UnmarshalJSON(data []byte) error

type ContainerFileService added in v1.1.0

type ContainerFileService struct {
	Options []option.RequestOption
	Content ContainerFileContentService
}

ContainerFileService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewContainerFileService method instead.

func NewContainerFileService added in v1.1.0

func NewContainerFileService(opts ...option.RequestOption) (r ContainerFileService)

NewContainerFileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ContainerFileService) Delete added in v1.1.0

func (r *ContainerFileService) Delete(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (err error)

Delete Container File

func (*ContainerFileService) Get added in v1.1.0

func (r *ContainerFileService) Get(ctx context.Context, containerID string, fileID string, opts ...option.RequestOption) (res *ContainerFileGetResponse, err error)

Retrieve Container File

func (*ContainerFileService) List added in v1.1.0

List Container files

func (*ContainerFileService) ListAutoPaging added in v1.1.0

List Container files

func (*ContainerFileService) New added in v1.1.0

Create a Container File

You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.

type ContainerGetResponse added in v1.1.0

type ContainerGetResponse struct {
	// Unique identifier for the container.
	ID string `json:"id,required"`
	// Unix timestamp (in seconds) when the container was created.
	CreatedAt int64 `json:"created_at,required"`
	// Name of the container.
	Name string `json:"name,required"`
	// The type of this object.
	Object string `json:"object,required"`
	// Status of the container (e.g., active, deleted).
	Status string `json:"status,required"`
	// The container will expire after this time period. The anchor is the reference
	// point for the expiration. The minutes is the number of minutes after the anchor
	// before the container expires.
	ExpiresAfter ContainerGetResponseExpiresAfter `json:"expires_after"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CreatedAt    respjson.Field
		Name         respjson.Field
		Object       respjson.Field
		Status       respjson.Field
		ExpiresAfter respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContainerGetResponse) RawJSON added in v1.1.0

func (r ContainerGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContainerGetResponse) UnmarshalJSON added in v1.1.0

func (r *ContainerGetResponse) UnmarshalJSON(data []byte) error

type ContainerGetResponseExpiresAfter added in v1.1.0

type ContainerGetResponseExpiresAfter struct {
	// The reference point for the expiration.
	//
	// Any of "last_active_at".
	Anchor string `json:"anchor"`
	// The number of minutes after the anchor before the container expires.
	Minutes int64 `json:"minutes"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Anchor      respjson.Field
		Minutes     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The container will expire after this time period. The anchor is the reference point for the expiration. The minutes is the number of minutes after the anchor before the container expires.

func (ContainerGetResponseExpiresAfter) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ContainerGetResponseExpiresAfter) UnmarshalJSON added in v1.1.0

func (r *ContainerGetResponseExpiresAfter) UnmarshalJSON(data []byte) error

type ContainerListParams added in v1.1.0

type ContainerListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order ContainerListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ContainerListParams) URLQuery added in v1.1.0

func (r ContainerListParams) URLQuery() (v url.Values, err error)

URLQuery serializes ContainerListParams's query parameters as `url.Values`.

type ContainerListParamsOrder added in v1.1.0

type ContainerListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	ContainerListParamsOrderAsc  ContainerListParamsOrder = "asc"
	ContainerListParamsOrderDesc ContainerListParamsOrder = "desc"
)

type ContainerListResponse added in v1.1.0

type ContainerListResponse struct {
	// Unique identifier for the container.
	ID string `json:"id,required"`
	// Unix timestamp (in seconds) when the container was created.
	CreatedAt int64 `json:"created_at,required"`
	// Name of the container.
	Name string `json:"name,required"`
	// The type of this object.
	Object string `json:"object,required"`
	// Status of the container (e.g., active, deleted).
	Status string `json:"status,required"`
	// The container will expire after this time period. The anchor is the reference
	// point for the expiration. The minutes is the number of minutes after the anchor
	// before the container expires.
	ExpiresAfter ContainerListResponseExpiresAfter `json:"expires_after"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CreatedAt    respjson.Field
		Name         respjson.Field
		Object       respjson.Field
		Status       respjson.Field
		ExpiresAfter respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContainerListResponse) RawJSON added in v1.1.0

func (r ContainerListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContainerListResponse) UnmarshalJSON added in v1.1.0

func (r *ContainerListResponse) UnmarshalJSON(data []byte) error

type ContainerListResponseExpiresAfter added in v1.1.0

type ContainerListResponseExpiresAfter struct {
	// The reference point for the expiration.
	//
	// Any of "last_active_at".
	Anchor string `json:"anchor"`
	// The number of minutes after the anchor before the container expires.
	Minutes int64 `json:"minutes"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Anchor      respjson.Field
		Minutes     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The container will expire after this time period. The anchor is the reference point for the expiration. The minutes is the number of minutes after the anchor before the container expires.

func (ContainerListResponseExpiresAfter) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ContainerListResponseExpiresAfter) UnmarshalJSON added in v1.1.0

func (r *ContainerListResponseExpiresAfter) UnmarshalJSON(data []byte) error

type ContainerNewParams added in v1.1.0

type ContainerNewParams struct {
	// Name of the container to create.
	Name string `json:"name,required"`
	// Container expiration time in seconds relative to the 'anchor' time.
	ExpiresAfter ContainerNewParamsExpiresAfter `json:"expires_after,omitzero"`
	// IDs of files to copy to the container.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (ContainerNewParams) MarshalJSON added in v1.1.0

func (r ContainerNewParams) MarshalJSON() (data []byte, err error)

func (*ContainerNewParams) UnmarshalJSON added in v1.1.0

func (r *ContainerNewParams) UnmarshalJSON(data []byte) error

type ContainerNewParamsExpiresAfter added in v1.1.0

type ContainerNewParamsExpiresAfter struct {
	// Time anchor for the expiration time. Currently only 'last_active_at' is
	// supported.
	//
	// Any of "last_active_at".
	Anchor  string `json:"anchor,omitzero,required"`
	Minutes int64  `json:"minutes,required"`
	// contains filtered or unexported fields
}

Container expiration time in seconds relative to the 'anchor' time.

The properties Anchor, Minutes are required.

func (ContainerNewParamsExpiresAfter) MarshalJSON added in v1.1.0

func (r ContainerNewParamsExpiresAfter) MarshalJSON() (data []byte, err error)

func (*ContainerNewParamsExpiresAfter) UnmarshalJSON added in v1.1.0

func (r *ContainerNewParamsExpiresAfter) UnmarshalJSON(data []byte) error

type ContainerNewResponse added in v1.1.0

type ContainerNewResponse struct {
	// Unique identifier for the container.
	ID string `json:"id,required"`
	// Unix timestamp (in seconds) when the container was created.
	CreatedAt int64 `json:"created_at,required"`
	// Name of the container.
	Name string `json:"name,required"`
	// The type of this object.
	Object string `json:"object,required"`
	// Status of the container (e.g., active, deleted).
	Status string `json:"status,required"`
	// The container will expire after this time period. The anchor is the reference
	// point for the expiration. The minutes is the number of minutes after the anchor
	// before the container expires.
	ExpiresAfter ContainerNewResponseExpiresAfter `json:"expires_after"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CreatedAt    respjson.Field
		Name         respjson.Field
		Object       respjson.Field
		Status       respjson.Field
		ExpiresAfter respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContainerNewResponse) RawJSON added in v1.1.0

func (r ContainerNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContainerNewResponse) UnmarshalJSON added in v1.1.0

func (r *ContainerNewResponse) UnmarshalJSON(data []byte) error

type ContainerNewResponseExpiresAfter added in v1.1.0

type ContainerNewResponseExpiresAfter struct {
	// The reference point for the expiration.
	//
	// Any of "last_active_at".
	Anchor string `json:"anchor"`
	// The number of minutes after the anchor before the container expires.
	Minutes int64 `json:"minutes"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Anchor      respjson.Field
		Minutes     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The container will expire after this time period. The anchor is the reference point for the expiration. The minutes is the number of minutes after the anchor before the container expires.

func (ContainerNewResponseExpiresAfter) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ContainerNewResponseExpiresAfter) UnmarshalJSON added in v1.1.0

func (r *ContainerNewResponseExpiresAfter) UnmarshalJSON(data []byte) error

type ContainerService added in v1.1.0

type ContainerService struct {
	Options []option.RequestOption
	Files   ContainerFileService
}

ContainerService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewContainerService method instead.

func NewContainerService added in v1.1.0

func NewContainerService(opts ...option.RequestOption) (r ContainerService)

NewContainerService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ContainerService) Delete added in v1.1.0

func (r *ContainerService) Delete(ctx context.Context, containerID string, opts ...option.RequestOption) (err error)

Delete Container

func (*ContainerService) Get added in v1.1.0

func (r *ContainerService) Get(ctx context.Context, containerID string, opts ...option.RequestOption) (res *ContainerGetResponse, err error)

Retrieve Container

func (*ContainerService) List added in v1.1.0

List Containers

func (*ContainerService) ListAutoPaging added in v1.1.0

List Containers

func (*ContainerService) New added in v1.1.0

Create Container

type CreateEmbeddingResponse

type CreateEmbeddingResponse struct {
	// The list of embeddings generated by the model.
	Data []Embedding `json:"data,required"`
	// The name of the model used to generate the embedding.
	Model string `json:"model,required"`
	// The object type, which is always "list".
	Object constant.List `json:"object,required"`
	// The usage information for the request.
	Usage CreateEmbeddingResponseUsage `json:"usage,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Model       respjson.Field
		Object      respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CreateEmbeddingResponse) RawJSON

func (r CreateEmbeddingResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*CreateEmbeddingResponse) UnmarshalJSON

func (r *CreateEmbeddingResponse) UnmarshalJSON(data []byte) error

type CreateEmbeddingResponseUsage

type CreateEmbeddingResponseUsage struct {
	// The number of tokens used by the prompt.
	PromptTokens int64 `json:"prompt_tokens,required"`
	// The total number of tokens used by the request.
	TotalTokens int64 `json:"total_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		PromptTokens respjson.Field
		TotalTokens  respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The usage information for the request.

func (CreateEmbeddingResponseUsage) RawJSON

Returns the unmodified JSON received from the API

func (*CreateEmbeddingResponseUsage) UnmarshalJSON

func (r *CreateEmbeddingResponseUsage) UnmarshalJSON(data []byte) error

type DpoHyperparameters

type DpoHyperparameters struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize DpoHyperparametersBatchSizeUnion `json:"batch_size,omitzero"`
	// The beta value for the DPO method. A higher beta value will increase the weight
	// of the penalty between the policy and reference model.
	Beta DpoHyperparametersBetaUnion `json:"beta,omitzero"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier DpoHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier,omitzero"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs DpoHyperparametersNEpochsUnion `json:"n_epochs,omitzero"`
	// contains filtered or unexported fields
}

The hyperparameters used for the DPO fine-tuning job.

func (DpoHyperparameters) MarshalJSON

func (r DpoHyperparameters) MarshalJSON() (data []byte, err error)

func (*DpoHyperparameters) UnmarshalJSON

func (r *DpoHyperparameters) UnmarshalJSON(data []byte) error

type DpoHyperparametersBatchSizeUnion

type DpoHyperparametersBatchSizeUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (DpoHyperparametersBatchSizeUnion) MarshalJSON

func (u DpoHyperparametersBatchSizeUnion) MarshalJSON() ([]byte, error)

func (*DpoHyperparametersBatchSizeUnion) UnmarshalJSON

func (u *DpoHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error

type DpoHyperparametersBatchSizeUnionResp

type DpoHyperparametersBatchSizeUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

DpoHyperparametersBatchSizeUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (DpoHyperparametersBatchSizeUnionResp) AsAuto

func (DpoHyperparametersBatchSizeUnionResp) AsInt

func (DpoHyperparametersBatchSizeUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*DpoHyperparametersBatchSizeUnionResp) UnmarshalJSON

func (r *DpoHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error

type DpoHyperparametersBetaUnion

type DpoHyperparametersBetaUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto  constant.Auto      `json:",omitzero,inline"`
	OfFloat param.Opt[float64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (DpoHyperparametersBetaUnion) MarshalJSON

func (u DpoHyperparametersBetaUnion) MarshalJSON() ([]byte, error)

func (*DpoHyperparametersBetaUnion) UnmarshalJSON

func (u *DpoHyperparametersBetaUnion) UnmarshalJSON(data []byte) error

type DpoHyperparametersBetaUnionResp

type DpoHyperparametersBetaUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfAuto  respjson.Field
		OfFloat respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

DpoHyperparametersBetaUnionResp contains all possible properties and values from constant.Auto, [float64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfFloat]

func (DpoHyperparametersBetaUnionResp) AsAuto

func (DpoHyperparametersBetaUnionResp) AsFloat

func (u DpoHyperparametersBetaUnionResp) AsFloat() (v float64)

func (DpoHyperparametersBetaUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*DpoHyperparametersBetaUnionResp) UnmarshalJSON

func (r *DpoHyperparametersBetaUnionResp) UnmarshalJSON(data []byte) error

type DpoHyperparametersLearningRateMultiplierUnion

type DpoHyperparametersLearningRateMultiplierUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto  constant.Auto      `json:",omitzero,inline"`
	OfFloat param.Opt[float64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (DpoHyperparametersLearningRateMultiplierUnion) MarshalJSON

func (*DpoHyperparametersLearningRateMultiplierUnion) UnmarshalJSON

func (u *DpoHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error

type DpoHyperparametersLearningRateMultiplierUnionResp

type DpoHyperparametersLearningRateMultiplierUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfAuto  respjson.Field
		OfFloat respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

DpoHyperparametersLearningRateMultiplierUnionResp contains all possible properties and values from constant.Auto, [float64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfFloat]

func (DpoHyperparametersLearningRateMultiplierUnionResp) AsAuto

func (DpoHyperparametersLearningRateMultiplierUnionResp) AsFloat

func (DpoHyperparametersLearningRateMultiplierUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*DpoHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON

type DpoHyperparametersNEpochsUnion

type DpoHyperparametersNEpochsUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (DpoHyperparametersNEpochsUnion) MarshalJSON

func (u DpoHyperparametersNEpochsUnion) MarshalJSON() ([]byte, error)

func (*DpoHyperparametersNEpochsUnion) UnmarshalJSON

func (u *DpoHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error

type DpoHyperparametersNEpochsUnionResp

type DpoHyperparametersNEpochsUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

DpoHyperparametersNEpochsUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (DpoHyperparametersNEpochsUnionResp) AsAuto

func (DpoHyperparametersNEpochsUnionResp) AsInt

func (DpoHyperparametersNEpochsUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*DpoHyperparametersNEpochsUnionResp) UnmarshalJSON

func (r *DpoHyperparametersNEpochsUnionResp) UnmarshalJSON(data []byte) error

type DpoHyperparametersResp

type DpoHyperparametersResp struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize DpoHyperparametersBatchSizeUnionResp `json:"batch_size"`
	// The beta value for the DPO method. A higher beta value will increase the weight
	// of the penalty between the policy and reference model.
	Beta DpoHyperparametersBetaUnionResp `json:"beta"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier DpoHyperparametersLearningRateMultiplierUnionResp `json:"learning_rate_multiplier"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs DpoHyperparametersNEpochsUnionResp `json:"n_epochs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BatchSize              respjson.Field
		Beta                   respjson.Field
		LearningRateMultiplier respjson.Field
		NEpochs                respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The hyperparameters used for the DPO fine-tuning job.

func (DpoHyperparametersResp) RawJSON

func (r DpoHyperparametersResp) RawJSON() string

Returns the unmodified JSON received from the API

func (DpoHyperparametersResp) ToParam

ToParam converts this DpoHyperparametersResp to a DpoHyperparameters.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with DpoHyperparameters.Overrides()

func (*DpoHyperparametersResp) UnmarshalJSON

func (r *DpoHyperparametersResp) UnmarshalJSON(data []byte) error

type DpoMethod

type DpoMethod struct {
	// The hyperparameters used for the DPO fine-tuning job.
	Hyperparameters DpoHyperparametersResp `json:"hyperparameters"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Hyperparameters respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Configuration for the DPO fine-tuning method.

func (DpoMethod) RawJSON

func (r DpoMethod) RawJSON() string

Returns the unmodified JSON received from the API

func (DpoMethod) ToParam

func (r DpoMethod) ToParam() DpoMethodParam

ToParam converts this DpoMethod to a DpoMethodParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with DpoMethodParam.Overrides()

func (*DpoMethod) UnmarshalJSON

func (r *DpoMethod) UnmarshalJSON(data []byte) error

type DpoMethodParam

type DpoMethodParam struct {
	// The hyperparameters used for the DPO fine-tuning job.
	Hyperparameters DpoHyperparameters `json:"hyperparameters,omitzero"`
	// contains filtered or unexported fields
}

Configuration for the DPO fine-tuning method.

func (DpoMethodParam) MarshalJSON

func (r DpoMethodParam) MarshalJSON() (data []byte, err error)

func (*DpoMethodParam) UnmarshalJSON

func (r *DpoMethodParam) UnmarshalJSON(data []byte) error

type Embedding

type Embedding struct {
	// The embedding vector, which is a list of floats. The length of vector depends on
	// the model as listed in the
	// [embedding guide](https://platform.openai.com/docs/guides/embeddings).
	Embedding []float64 `json:"embedding,required"`
	// The index of the embedding in the list of embeddings.
	Index int64 `json:"index,required"`
	// The object type, which is always "embedding".
	Object constant.Embedding `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Embedding   respjson.Field
		Index       respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents an embedding vector returned by embedding endpoint.

func (Embedding) RawJSON

func (r Embedding) RawJSON() string

Returns the unmodified JSON received from the API

func (*Embedding) UnmarshalJSON

func (r *Embedding) UnmarshalJSON(data []byte) error

type EmbeddingModel

type EmbeddingModel = string
const (
	EmbeddingModelTextEmbeddingAda002 EmbeddingModel = "text-embedding-ada-002"
	EmbeddingModelTextEmbedding3Small EmbeddingModel = "text-embedding-3-small"
	EmbeddingModelTextEmbedding3Large EmbeddingModel = "text-embedding-3-large"
)

type EmbeddingNewParams

type EmbeddingNewParams struct {
	// Input text to embed, encoded as a string or array of tokens. To embed multiple
	// inputs in a single request, pass an array of strings or array of token arrays.
	// The input must not exceed the max input tokens for the model (8192 tokens for
	// all embedding models), cannot be an empty string, and any array must be 2048
	// dimensions or less.
	// [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
	// for counting tokens. In addition to the per-input token limit, all embedding
	// models enforce a maximum of 300,000 tokens summed across all inputs in a single
	// request.
	Input EmbeddingNewParamsInputUnion `json:"input,omitzero,required"`
	// ID of the model to use. You can use the
	// [List models](https://platform.openai.com/docs/api-reference/models/list) API to
	// see all of your available models, or see our
	// [Model overview](https://platform.openai.com/docs/models) for descriptions of
	// them.
	Model EmbeddingModel `json:"model,omitzero,required"`
	// The number of dimensions the resulting output embeddings should have. Only
	// supported in `text-embedding-3` and later models.
	Dimensions param.Opt[int64] `json:"dimensions,omitzero"`
	// A unique identifier representing your end-user, which can help OpenAI to monitor
	// and detect abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
	User param.Opt[string] `json:"user,omitzero"`
	// The format to return the embeddings in. Can be either `float` or
	// [`base64`](https://pypi.org/project/pybase64/).
	//
	// Any of "float", "base64".
	EncodingFormat EmbeddingNewParamsEncodingFormat `json:"encoding_format,omitzero"`
	// contains filtered or unexported fields
}

func (EmbeddingNewParams) MarshalJSON

func (r EmbeddingNewParams) MarshalJSON() (data []byte, err error)

func (*EmbeddingNewParams) UnmarshalJSON

func (r *EmbeddingNewParams) UnmarshalJSON(data []byte) error

type EmbeddingNewParamsEncodingFormat

type EmbeddingNewParamsEncodingFormat string

The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).

const (
	EmbeddingNewParamsEncodingFormatFloat  EmbeddingNewParamsEncodingFormat = "float"
	EmbeddingNewParamsEncodingFormatBase64 EmbeddingNewParamsEncodingFormat = "base64"
)

type EmbeddingNewParamsInputUnion

type EmbeddingNewParamsInputUnion struct {
	OfString             param.Opt[string] `json:",omitzero,inline"`
	OfArrayOfStrings     []string          `json:",omitzero,inline"`
	OfArrayOfTokens      []int64           `json:",omitzero,inline"`
	OfArrayOfTokenArrays [][]int64         `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (EmbeddingNewParamsInputUnion) MarshalJSON

func (u EmbeddingNewParamsInputUnion) MarshalJSON() ([]byte, error)

func (*EmbeddingNewParamsInputUnion) UnmarshalJSON

func (u *EmbeddingNewParamsInputUnion) UnmarshalJSON(data []byte) error

type EmbeddingService

type EmbeddingService struct {
	Options []option.RequestOption
}

EmbeddingService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEmbeddingService method instead.

func NewEmbeddingService

func NewEmbeddingService(opts ...option.RequestOption) (r EmbeddingService)

NewEmbeddingService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*EmbeddingService) New

Creates an embedding vector representing the input text.

type Error

type Error = apierror.Error

type ErrorObject added in v1.1.0

type ErrorObject = shared.ErrorObject

This is an alias to an internal type.

type FileChunkingStrategyParamUnion

type FileChunkingStrategyParamUnion struct {
	OfAuto   *AutoFileChunkingStrategyParam         `json:",omitzero,inline"`
	OfStatic *StaticFileChunkingStrategyObjectParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (FileChunkingStrategyParamUnion) GetStatic

Returns a pointer to the underlying variant's property, if present.

func (FileChunkingStrategyParamUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (FileChunkingStrategyParamUnion) MarshalJSON

func (u FileChunkingStrategyParamUnion) MarshalJSON() ([]byte, error)

func (*FileChunkingStrategyParamUnion) UnmarshalJSON

func (u *FileChunkingStrategyParamUnion) UnmarshalJSON(data []byte) error

type FileChunkingStrategyUnion

type FileChunkingStrategyUnion struct {
	// This field is from variant [StaticFileChunkingStrategyObject].
	Static StaticFileChunkingStrategy `json:"static"`
	// Any of "static", "other".
	Type string `json:"type"`
	JSON struct {
		Static respjson.Field
		Type   respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

FileChunkingStrategyUnion contains all possible properties and values from StaticFileChunkingStrategyObject, OtherFileChunkingStrategyObject.

Use the FileChunkingStrategyUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (FileChunkingStrategyUnion) AsAny

func (u FileChunkingStrategyUnion) AsAny() anyFileChunkingStrategy

Use the following switch statement to find the correct variant

switch variant := FileChunkingStrategyUnion.AsAny().(type) {
case openai.StaticFileChunkingStrategyObject:
case openai.OtherFileChunkingStrategyObject:
default:
  fmt.Errorf("no variant present")
}

func (FileChunkingStrategyUnion) AsOther

func (FileChunkingStrategyUnion) AsStatic

func (FileChunkingStrategyUnion) RawJSON

func (u FileChunkingStrategyUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileChunkingStrategyUnion) UnmarshalJSON

func (r *FileChunkingStrategyUnion) UnmarshalJSON(data []byte) error

type FileCitationAnnotation added in v1.1.0

type FileCitationAnnotation struct {
	EndIndex     int64                              `json:"end_index,required"`
	FileCitation FileCitationAnnotationFileCitation `json:"file_citation,required"`
	StartIndex   int64                              `json:"start_index,required"`
	// The text in the message content that needs to be replaced.
	Text string `json:"text,required"`
	// Always `file_citation`.
	Type constant.FileCitation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EndIndex     respjson.Field
		FileCitation respjson.Field
		StartIndex   respjson.Field
		Text         respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.

func (FileCitationAnnotation) RawJSON added in v1.1.0

func (r FileCitationAnnotation) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileCitationAnnotation) UnmarshalJSON added in v1.1.0

func (r *FileCitationAnnotation) UnmarshalJSON(data []byte) error

type FileCitationAnnotationFileCitation added in v1.1.0

type FileCitationAnnotationFileCitation struct {
	// The ID of the specific File the citation is from.
	FileID string `json:"file_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileCitationAnnotationFileCitation) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FileCitationAnnotationFileCitation) UnmarshalJSON added in v1.1.0

func (r *FileCitationAnnotationFileCitation) UnmarshalJSON(data []byte) error

type FileCitationDeltaAnnotation added in v1.1.0

type FileCitationDeltaAnnotation struct {
	// The index of the annotation in the text content part.
	Index int64 `json:"index,required"`
	// Always `file_citation`.
	Type         constant.FileCitation                   `json:"type,required"`
	EndIndex     int64                                   `json:"end_index"`
	FileCitation FileCitationDeltaAnnotationFileCitation `json:"file_citation"`
	StartIndex   int64                                   `json:"start_index"`
	// The text in the message content that needs to be replaced.
	Text string `json:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index        respjson.Field
		Type         respjson.Field
		EndIndex     respjson.Field
		FileCitation respjson.Field
		StartIndex   respjson.Field
		Text         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.

func (FileCitationDeltaAnnotation) RawJSON added in v1.1.0

func (r FileCitationDeltaAnnotation) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileCitationDeltaAnnotation) UnmarshalJSON added in v1.1.0

func (r *FileCitationDeltaAnnotation) UnmarshalJSON(data []byte) error

type FileCitationDeltaAnnotationFileCitation added in v1.1.0

type FileCitationDeltaAnnotationFileCitation struct {
	// The ID of the specific File the citation is from.
	FileID string `json:"file_id"`
	// The specific quote in the file.
	Quote string `json:"quote"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Quote       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileCitationDeltaAnnotationFileCitation) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FileCitationDeltaAnnotationFileCitation) UnmarshalJSON added in v1.1.0

func (r *FileCitationDeltaAnnotationFileCitation) UnmarshalJSON(data []byte) error

type FileDeleted

type FileDeleted struct {
	ID      string        `json:"id,required"`
	Deleted bool          `json:"deleted,required"`
	Object  constant.File `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileDeleted) RawJSON

func (r FileDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileDeleted) UnmarshalJSON

func (r *FileDeleted) UnmarshalJSON(data []byte) error

type FileListParams

type FileListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 10,000, and the default is 10,000.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Only return files with the given purpose.
	Purpose param.Opt[string] `query:"purpose,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order FileListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (FileListParams) URLQuery

func (r FileListParams) URLQuery() (v url.Values, err error)

URLQuery serializes FileListParams's query parameters as `url.Values`.

type FileListParamsOrder

type FileListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	FileListParamsOrderAsc  FileListParamsOrder = "asc"
	FileListParamsOrderDesc FileListParamsOrder = "desc"
)

type FileNewParams

type FileNewParams struct {
	// The File object (not file name) to be uploaded.
	File io.Reader `json:"file,omitzero,required" format:"binary"`
	// The intended purpose of the uploaded file. One of: - `assistants`: Used in the
	// Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
	// fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
	// Flexible file type for any purpose - `evals`: Used for eval data sets
	//
	// Any of "assistants", "batch", "fine-tune", "vision", "user_data", "evals".
	Purpose FilePurpose `json:"purpose,omitzero,required"`
	// contains filtered or unexported fields
}

func (FileNewParams) MarshalMultipart

func (r FileNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type FileObject

type FileObject struct {
	// The file identifier, which can be referenced in the API endpoints.
	ID string `json:"id,required"`
	// The size of the file, in bytes.
	Bytes int64 `json:"bytes,required"`
	// The Unix timestamp (in seconds) for when the file was created.
	CreatedAt int64 `json:"created_at,required"`
	// The name of the file.
	Filename string `json:"filename,required"`
	// The object type, which is always `file`.
	Object constant.File `json:"object,required"`
	// The intended purpose of the file. Supported values are `assistants`,
	// `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`
	// and `vision`.
	//
	// Any of "assistants", "assistants_output", "batch", "batch_output", "fine-tune",
	// "fine-tune-results", "vision".
	Purpose FileObjectPurpose `json:"purpose,required"`
	// Deprecated. The current status of the file, which can be either `uploaded`,
	// `processed`, or `error`.
	//
	// Any of "uploaded", "processed", "error".
	//
	// Deprecated: deprecated
	Status FileObjectStatus `json:"status,required"`
	// The Unix timestamp (in seconds) for when the file will expire.
	ExpiresAt int64 `json:"expires_at"`
	// Deprecated. For details on why a fine-tuning training file failed validation,
	// see the `error` field on `fine_tuning.job`.
	//
	// Deprecated: deprecated
	StatusDetails string `json:"status_details"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		Bytes         respjson.Field
		CreatedAt     respjson.Field
		Filename      respjson.Field
		Object        respjson.Field
		Purpose       respjson.Field
		Status        respjson.Field
		ExpiresAt     respjson.Field
		StatusDetails respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The `File` object represents a document that has been uploaded to OpenAI.

func (FileObject) RawJSON

func (r FileObject) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileObject) UnmarshalJSON

func (r *FileObject) UnmarshalJSON(data []byte) error

type FileObjectPurpose

type FileObjectPurpose string

The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`.

const (
	FileObjectPurposeAssistants       FileObjectPurpose = "assistants"
	FileObjectPurposeAssistantsOutput FileObjectPurpose = "assistants_output"
	FileObjectPurposeBatch            FileObjectPurpose = "batch"
	FileObjectPurposeBatchOutput      FileObjectPurpose = "batch_output"
	FileObjectPurposeFineTune         FileObjectPurpose = "fine-tune"
	FileObjectPurposeFineTuneResults  FileObjectPurpose = "fine-tune-results"
	FileObjectPurposeVision           FileObjectPurpose = "vision"
)

type FileObjectStatus

type FileObjectStatus string

Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.

const (
	FileObjectStatusUploaded  FileObjectStatus = "uploaded"
	FileObjectStatusProcessed FileObjectStatus = "processed"
	FileObjectStatusError     FileObjectStatus = "error"
)

type FilePathAnnotation added in v1.1.0

type FilePathAnnotation struct {
	EndIndex   int64                      `json:"end_index,required"`
	FilePath   FilePathAnnotationFilePath `json:"file_path,required"`
	StartIndex int64                      `json:"start_index,required"`
	// The text in the message content that needs to be replaced.
	Text string `json:"text,required"`
	// Always `file_path`.
	Type constant.FilePath `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EndIndex    respjson.Field
		FilePath    respjson.Field
		StartIndex  respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.

func (FilePathAnnotation) RawJSON added in v1.1.0

func (r FilePathAnnotation) RawJSON() string

Returns the unmodified JSON received from the API

func (*FilePathAnnotation) UnmarshalJSON added in v1.1.0

func (r *FilePathAnnotation) UnmarshalJSON(data []byte) error

type FilePathAnnotationFilePath added in v1.1.0

type FilePathAnnotationFilePath struct {
	// The ID of the file that was generated.
	FileID string `json:"file_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FilePathAnnotationFilePath) RawJSON added in v1.1.0

func (r FilePathAnnotationFilePath) RawJSON() string

Returns the unmodified JSON received from the API

func (*FilePathAnnotationFilePath) UnmarshalJSON added in v1.1.0

func (r *FilePathAnnotationFilePath) UnmarshalJSON(data []byte) error

type FilePathDeltaAnnotation added in v1.1.0

type FilePathDeltaAnnotation struct {
	// The index of the annotation in the text content part.
	Index int64 `json:"index,required"`
	// Always `file_path`.
	Type       constant.FilePath               `json:"type,required"`
	EndIndex   int64                           `json:"end_index"`
	FilePath   FilePathDeltaAnnotationFilePath `json:"file_path"`
	StartIndex int64                           `json:"start_index"`
	// The text in the message content that needs to be replaced.
	Text string `json:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		EndIndex    respjson.Field
		FilePath    respjson.Field
		StartIndex  respjson.Field
		Text        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.

func (FilePathDeltaAnnotation) RawJSON added in v1.1.0

func (r FilePathDeltaAnnotation) RawJSON() string

Returns the unmodified JSON received from the API

func (*FilePathDeltaAnnotation) UnmarshalJSON added in v1.1.0

func (r *FilePathDeltaAnnotation) UnmarshalJSON(data []byte) error

type FilePathDeltaAnnotationFilePath added in v1.1.0

type FilePathDeltaAnnotationFilePath struct {
	// The ID of the file that was generated.
	FileID string `json:"file_id"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FilePathDeltaAnnotationFilePath) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FilePathDeltaAnnotationFilePath) UnmarshalJSON added in v1.1.0

func (r *FilePathDeltaAnnotationFilePath) UnmarshalJSON(data []byte) error

type FilePurpose

type FilePurpose string

The intended purpose of the uploaded file. One of: - `assistants`: Used in the Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`: Flexible file type for any purpose - `evals`: Used for eval data sets

const (
	FilePurposeAssistants FilePurpose = "assistants"
	FilePurposeBatch      FilePurpose = "batch"
	FilePurposeFineTune   FilePurpose = "fine-tune"
	FilePurposeVision     FilePurpose = "vision"
	FilePurposeUserData   FilePurpose = "user_data"
	FilePurposeEvals      FilePurpose = "evals"
)

type FileSearchTool added in v1.1.0

type FileSearchTool struct {
	// The type of tool being defined: `file_search`
	Type constant.FileSearch `json:"type,required"`
	// Overrides for the file search tool.
	FileSearch FileSearchToolFileSearch `json:"file_search"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		FileSearch  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileSearchTool) RawJSON added in v1.1.0

func (r FileSearchTool) RawJSON() string

Returns the unmodified JSON received from the API

func (FileSearchTool) ToParam added in v1.1.0

func (r FileSearchTool) ToParam() FileSearchToolParam

ToParam converts this FileSearchTool to a FileSearchToolParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with FileSearchToolParam.Overrides()

func (*FileSearchTool) UnmarshalJSON added in v1.1.0

func (r *FileSearchTool) UnmarshalJSON(data []byte) error

type FileSearchToolCall added in v1.1.0

type FileSearchToolCall struct {
	// The ID of the tool call object.
	ID string `json:"id,required"`
	// For now, this is always going to be an empty object.
	FileSearch FileSearchToolCallFileSearch `json:"file_search,required"`
	// The type of tool call. This is always going to be `file_search` for this type of
	// tool call.
	Type constant.FileSearch `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		FileSearch  respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileSearchToolCall) RawJSON added in v1.1.0

func (r FileSearchToolCall) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileSearchToolCall) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolCall) UnmarshalJSON(data []byte) error

type FileSearchToolCallDelta added in v1.1.0

type FileSearchToolCallDelta struct {
	// For now, this is always going to be an empty object.
	FileSearch any `json:"file_search,required"`
	// The index of the tool call in the tool calls array.
	Index int64 `json:"index,required"`
	// The type of tool call. This is always going to be `file_search` for this type of
	// tool call.
	Type constant.FileSearch `json:"type,required"`
	// The ID of the tool call object.
	ID string `json:"id"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileSearch  respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileSearchToolCallDelta) RawJSON added in v1.1.0

func (r FileSearchToolCallDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileSearchToolCallDelta) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolCallDelta) UnmarshalJSON(data []byte) error

type FileSearchToolCallFileSearch added in v1.1.0

type FileSearchToolCallFileSearch struct {
	// The ranking options for the file search.
	RankingOptions FileSearchToolCallFileSearchRankingOptions `json:"ranking_options"`
	// The results of the file search.
	Results []FileSearchToolCallFileSearchResult `json:"results"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		RankingOptions respjson.Field
		Results        respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

For now, this is always going to be an empty object.

func (FileSearchToolCallFileSearch) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FileSearchToolCallFileSearch) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolCallFileSearch) UnmarshalJSON(data []byte) error

type FileSearchToolCallFileSearchRankingOptions added in v1.1.0

type FileSearchToolCallFileSearchRankingOptions struct {
	// The ranker to use for the file search. If not specified will use the `auto`
	// ranker.
	//
	// Any of "auto", "default_2024_08_21".
	Ranker string `json:"ranker,required"`
	// The score threshold for the file search. All values must be a floating point
	// number between 0 and 1.
	ScoreThreshold float64 `json:"score_threshold,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Ranker         respjson.Field
		ScoreThreshold respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The ranking options for the file search.

func (FileSearchToolCallFileSearchRankingOptions) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FileSearchToolCallFileSearchRankingOptions) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolCallFileSearchRankingOptions) UnmarshalJSON(data []byte) error

type FileSearchToolCallFileSearchResult added in v1.1.0

type FileSearchToolCallFileSearchResult struct {
	// The ID of the file that result was found in.
	FileID string `json:"file_id,required"`
	// The name of the file that result was found in.
	FileName string `json:"file_name,required"`
	// The score of the result. All values must be a floating point number between 0
	// and 1.
	Score float64 `json:"score,required"`
	// The content of the result that was found. The content is only included if
	// requested via the include query parameter.
	Content []FileSearchToolCallFileSearchResultContent `json:"content"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		FileName    respjson.Field
		Score       respjson.Field
		Content     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A result instance of the file search.

func (FileSearchToolCallFileSearchResult) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FileSearchToolCallFileSearchResult) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolCallFileSearchResult) UnmarshalJSON(data []byte) error

type FileSearchToolCallFileSearchResultContent added in v1.1.0

type FileSearchToolCallFileSearchResultContent struct {
	// The text content of the file.
	Text string `json:"text"`
	// The type of the content.
	//
	// Any of "text".
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileSearchToolCallFileSearchResultContent) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FileSearchToolCallFileSearchResultContent) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolCallFileSearchResultContent) UnmarshalJSON(data []byte) error

type FileSearchToolFileSearch added in v1.1.0

type FileSearchToolFileSearch struct {
	// The maximum number of results the file search tool should output. The default is
	// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
	// 1 and 50 inclusive.
	//
	// Note that the file search tool may output fewer than `max_num_results` results.
	// See the
	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
	// for more information.
	MaxNumResults int64 `json:"max_num_results"`
	// The ranking options for the file search. If not specified, the file search tool
	// will use the `auto` ranker and a score_threshold of 0.
	//
	// See the
	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
	// for more information.
	RankingOptions FileSearchToolFileSearchRankingOptions `json:"ranking_options"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		MaxNumResults  respjson.Field
		RankingOptions respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Overrides for the file search tool.

func (FileSearchToolFileSearch) RawJSON added in v1.1.0

func (r FileSearchToolFileSearch) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileSearchToolFileSearch) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolFileSearch) UnmarshalJSON(data []byte) error

type FileSearchToolFileSearchParam added in v1.1.0

type FileSearchToolFileSearchParam struct {
	// The maximum number of results the file search tool should output. The default is
	// 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
	// 1 and 50 inclusive.
	//
	// Note that the file search tool may output fewer than `max_num_results` results.
	// See the
	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
	// for more information.
	MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"`
	// The ranking options for the file search. If not specified, the file search tool
	// will use the `auto` ranker and a score_threshold of 0.
	//
	// See the
	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
	// for more information.
	RankingOptions FileSearchToolFileSearchRankingOptionsParam `json:"ranking_options,omitzero"`
	// contains filtered or unexported fields
}

Overrides for the file search tool.

func (FileSearchToolFileSearchParam) MarshalJSON added in v1.1.0

func (r FileSearchToolFileSearchParam) MarshalJSON() (data []byte, err error)

func (*FileSearchToolFileSearchParam) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolFileSearchParam) UnmarshalJSON(data []byte) error

type FileSearchToolFileSearchRankingOptions added in v1.1.0

type FileSearchToolFileSearchRankingOptions struct {
	// The score threshold for the file search. All values must be a floating point
	// number between 0 and 1.
	ScoreThreshold float64 `json:"score_threshold,required"`
	// The ranker to use for the file search. If not specified will use the `auto`
	// ranker.
	//
	// Any of "auto", "default_2024_08_21".
	Ranker string `json:"ranker"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ScoreThreshold respjson.Field
		Ranker         respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

func (FileSearchToolFileSearchRankingOptions) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FileSearchToolFileSearchRankingOptions) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolFileSearchRankingOptions) UnmarshalJSON(data []byte) error

type FileSearchToolFileSearchRankingOptionsParam added in v1.1.0

type FileSearchToolFileSearchRankingOptionsParam struct {
	// The score threshold for the file search. All values must be a floating point
	// number between 0 and 1.
	ScoreThreshold float64 `json:"score_threshold,required"`
	// The ranker to use for the file search. If not specified will use the `auto`
	// ranker.
	//
	// Any of "auto", "default_2024_08_21".
	Ranker string `json:"ranker,omitzero"`
	// contains filtered or unexported fields
}

The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

The property ScoreThreshold is required.

func (FileSearchToolFileSearchRankingOptionsParam) MarshalJSON added in v1.1.0

func (r FileSearchToolFileSearchRankingOptionsParam) MarshalJSON() (data []byte, err error)

func (*FileSearchToolFileSearchRankingOptionsParam) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolFileSearchRankingOptionsParam) UnmarshalJSON(data []byte) error

type FileSearchToolParam added in v1.1.0

type FileSearchToolParam struct {
	// Overrides for the file search tool.
	FileSearch FileSearchToolFileSearchParam `json:"file_search,omitzero"`
	// The type of tool being defined: `file_search`
	//
	// This field can be elided, and will marshal its zero value as "file_search".
	Type constant.FileSearch `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (FileSearchToolParam) MarshalJSON added in v1.1.0

func (r FileSearchToolParam) MarshalJSON() (data []byte, err error)

func (*FileSearchToolParam) UnmarshalJSON added in v1.1.0

func (r *FileSearchToolParam) UnmarshalJSON(data []byte) error

type FileService

type FileService struct {
	Options []option.RequestOption
}

FileService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFileService method instead.

func NewFileService

func NewFileService(opts ...option.RequestOption) (r FileService)

NewFileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FileService) Content

func (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *http.Response, err error)

Returns the contents of the specified file.

func (*FileService) Delete

func (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileDeleted, err error)

Delete a file.

func (*FileService) Get

func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileObject, err error)

Returns information about a specific file.

func (*FileService) List

Returns a list of files.

func (*FileService) ListAutoPaging

Returns a list of files.

func (*FileService) New

func (r *FileService) New(ctx context.Context, body FileNewParams, opts ...option.RequestOption) (res *FileObject, err error)

Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB.

The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for details.

The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) models.

The Batch API only supports `.jsonl` files up to 200 MB in size. The input also has a specific required [format](https://platform.openai.com/docs/api-reference/batch/request-input).

Please [contact us](https://help.openai.com/) if you need to increase these storage limits.

type FineTuningAlphaGraderRunParams

type FineTuningAlphaGraderRunParams struct {
	// The grader used for the fine-tuning job.
	Grader FineTuningAlphaGraderRunParamsGraderUnion `json:"grader,omitzero,required"`
	// The model sample to be evaluated. This value will be used to populate the
	// `sample` namespace. See
	// [the guide](https://platform.openai.com/docs/guides/graders) for more details.
	// The `output_json` variable will be populated if the model sample is a valid JSON
	// string.
	ModelSample string `json:"model_sample,required"`
	// The dataset item provided to the grader. This will be used to populate the
	// `item` namespace. See
	// [the guide](https://platform.openai.com/docs/guides/graders) for more details.
	Item any `json:"item,omitzero"`
	// contains filtered or unexported fields
}

func (FineTuningAlphaGraderRunParams) MarshalJSON

func (r FineTuningAlphaGraderRunParams) MarshalJSON() (data []byte, err error)

func (*FineTuningAlphaGraderRunParams) UnmarshalJSON

func (r *FineTuningAlphaGraderRunParams) UnmarshalJSON(data []byte) error

type FineTuningAlphaGraderRunParamsGraderUnion

type FineTuningAlphaGraderRunParamsGraderUnion struct {
	OfStringCheck    *StringCheckGraderParam    `json:",omitzero,inline"`
	OfTextSimilarity *TextSimilarityGraderParam `json:",omitzero,inline"`
	OfPython         *PythonGraderParam         `json:",omitzero,inline"`
	OfScoreModel     *ScoreModelGraderParam     `json:",omitzero,inline"`
	OfMulti          *MultiGraderParam          `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetCalculateOutput

func (u FineTuningAlphaGraderRunParamsGraderUnion) GetCalculateOutput() *string

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetEvaluationMetric

func (u FineTuningAlphaGraderRunParamsGraderUnion) GetEvaluationMetric() *string

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetGraders

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetImageTag

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetInput

func (u FineTuningAlphaGraderRunParamsGraderUnion) GetInput() (res fineTuningAlphaGraderRunParamsGraderUnionInput)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (FineTuningAlphaGraderRunParamsGraderUnion) GetModel

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetName

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetOperation

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetRange

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetReference

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetSamplingParams

func (u FineTuningAlphaGraderRunParamsGraderUnion) GetSamplingParams() *any

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetSource

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderRunParamsGraderUnion) MarshalJSON

func (*FineTuningAlphaGraderRunParamsGraderUnion) UnmarshalJSON

func (u *FineTuningAlphaGraderRunParamsGraderUnion) UnmarshalJSON(data []byte) error

type FineTuningAlphaGraderRunResponse

type FineTuningAlphaGraderRunResponse struct {
	Metadata                      FineTuningAlphaGraderRunResponseMetadata `json:"metadata,required"`
	ModelGraderTokenUsagePerModel map[string]any                           `json:"model_grader_token_usage_per_model,required"`
	Reward                        float64                                  `json:"reward,required"`
	SubRewards                    map[string]any                           `json:"sub_rewards,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Metadata                      respjson.Field
		ModelGraderTokenUsagePerModel respjson.Field
		Reward                        respjson.Field
		SubRewards                    respjson.Field
		ExtraFields                   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FineTuningAlphaGraderRunResponse) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningAlphaGraderRunResponse) UnmarshalJSON

func (r *FineTuningAlphaGraderRunResponse) UnmarshalJSON(data []byte) error

type FineTuningAlphaGraderRunResponseMetadata

type FineTuningAlphaGraderRunResponseMetadata struct {
	Errors           FineTuningAlphaGraderRunResponseMetadataErrors `json:"errors,required"`
	ExecutionTime    float64                                        `json:"execution_time,required"`
	Name             string                                         `json:"name,required"`
	SampledModelName string                                         `json:"sampled_model_name,required"`
	Scores           map[string]any                                 `json:"scores,required"`
	TokenUsage       int64                                          `json:"token_usage,required"`
	Type             string                                         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Errors           respjson.Field
		ExecutionTime    respjson.Field
		Name             respjson.Field
		SampledModelName respjson.Field
		Scores           respjson.Field
		TokenUsage       respjson.Field
		Type             respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FineTuningAlphaGraderRunResponseMetadata) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningAlphaGraderRunResponseMetadata) UnmarshalJSON

func (r *FineTuningAlphaGraderRunResponseMetadata) UnmarshalJSON(data []byte) error

type FineTuningAlphaGraderRunResponseMetadataErrors

type FineTuningAlphaGraderRunResponseMetadataErrors struct {
	FormulaParseError               bool   `json:"formula_parse_error,required"`
	InvalidVariableError            bool   `json:"invalid_variable_error,required"`
	ModelGraderParseError           bool   `json:"model_grader_parse_error,required"`
	ModelGraderRefusalError         bool   `json:"model_grader_refusal_error,required"`
	ModelGraderServerError          bool   `json:"model_grader_server_error,required"`
	ModelGraderServerErrorDetails   string `json:"model_grader_server_error_details,required"`
	OtherError                      bool   `json:"other_error,required"`
	PythonGraderRuntimeError        bool   `json:"python_grader_runtime_error,required"`
	PythonGraderRuntimeErrorDetails string `json:"python_grader_runtime_error_details,required"`
	PythonGraderServerError         bool   `json:"python_grader_server_error,required"`
	PythonGraderServerErrorType     string `json:"python_grader_server_error_type,required"`
	SampleParseError                bool   `json:"sample_parse_error,required"`
	TruncatedObservationError       bool   `json:"truncated_observation_error,required"`
	UnresponsiveRewardError         bool   `json:"unresponsive_reward_error,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FormulaParseError               respjson.Field
		InvalidVariableError            respjson.Field
		ModelGraderParseError           respjson.Field
		ModelGraderRefusalError         respjson.Field
		ModelGraderServerError          respjson.Field
		ModelGraderServerErrorDetails   respjson.Field
		OtherError                      respjson.Field
		PythonGraderRuntimeError        respjson.Field
		PythonGraderRuntimeErrorDetails respjson.Field
		PythonGraderServerError         respjson.Field
		PythonGraderServerErrorType     respjson.Field
		SampleParseError                respjson.Field
		TruncatedObservationError       respjson.Field
		UnresponsiveRewardError         respjson.Field
		ExtraFields                     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FineTuningAlphaGraderRunResponseMetadataErrors) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningAlphaGraderRunResponseMetadataErrors) UnmarshalJSON

type FineTuningAlphaGraderService

type FineTuningAlphaGraderService struct {
	Options []option.RequestOption
}

FineTuningAlphaGraderService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningAlphaGraderService method instead.

func NewFineTuningAlphaGraderService

func NewFineTuningAlphaGraderService(opts ...option.RequestOption) (r FineTuningAlphaGraderService)

NewFineTuningAlphaGraderService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FineTuningAlphaGraderService) Run

Run a grader.

func (*FineTuningAlphaGraderService) Validate

Validate a grader.

type FineTuningAlphaGraderValidateParams

type FineTuningAlphaGraderValidateParams struct {
	// The grader used for the fine-tuning job.
	Grader FineTuningAlphaGraderValidateParamsGraderUnion `json:"grader,omitzero,required"`
	// contains filtered or unexported fields
}

func (FineTuningAlphaGraderValidateParams) MarshalJSON

func (r FineTuningAlphaGraderValidateParams) MarshalJSON() (data []byte, err error)

func (*FineTuningAlphaGraderValidateParams) UnmarshalJSON

func (r *FineTuningAlphaGraderValidateParams) UnmarshalJSON(data []byte) error

type FineTuningAlphaGraderValidateParamsGraderUnion

type FineTuningAlphaGraderValidateParamsGraderUnion struct {
	OfStringCheckGrader    *StringCheckGraderParam    `json:",omitzero,inline"`
	OfTextSimilarityGrader *TextSimilarityGraderParam `json:",omitzero,inline"`
	OfPythonGrader         *PythonGraderParam         `json:",omitzero,inline"`
	OfScoreModelGrader     *ScoreModelGraderParam     `json:",omitzero,inline"`
	OfMultiGrader          *MultiGraderParam          `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetCalculateOutput

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetEvaluationMetric

func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetEvaluationMetric() *string

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetGraders

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetImageTag

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetInput

func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetInput() (res fineTuningAlphaGraderValidateParamsGraderUnionInput)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetModel

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetName

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetOperation

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetRange

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetReference

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetSamplingParams

func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetSamplingParams() *any

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetSource

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (FineTuningAlphaGraderValidateParamsGraderUnion) MarshalJSON

func (*FineTuningAlphaGraderValidateParamsGraderUnion) UnmarshalJSON

type FineTuningAlphaGraderValidateResponse

type FineTuningAlphaGraderValidateResponse struct {
	// The grader used for the fine-tuning job.
	Grader FineTuningAlphaGraderValidateResponseGraderUnion `json:"grader"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Grader      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FineTuningAlphaGraderValidateResponse) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningAlphaGraderValidateResponse) UnmarshalJSON

func (r *FineTuningAlphaGraderValidateResponse) UnmarshalJSON(data []byte) error

type FineTuningAlphaGraderValidateResponseGraderUnion

type FineTuningAlphaGraderValidateResponseGraderUnion struct {
	// This field is a union of [string], [string], [[]ScoreModelGraderInput]
	Input FineTuningAlphaGraderValidateResponseGraderUnionInput `json:"input"`
	Name  string                                                `json:"name"`
	// This field is from variant [StringCheckGrader].
	Operation StringCheckGraderOperation `json:"operation"`
	Reference string                     `json:"reference"`
	Type      string                     `json:"type"`
	// This field is from variant [TextSimilarityGrader].
	EvaluationMetric TextSimilarityGraderEvaluationMetric `json:"evaluation_metric"`
	// This field is from variant [PythonGrader].
	Source string `json:"source"`
	// This field is from variant [PythonGrader].
	ImageTag string `json:"image_tag"`
	// This field is from variant [ScoreModelGrader].
	Model string `json:"model"`
	// This field is from variant [ScoreModelGrader].
	Range []float64 `json:"range"`
	// This field is from variant [ScoreModelGrader].
	SamplingParams any `json:"sampling_params"`
	// This field is from variant [MultiGrader].
	CalculateOutput string `json:"calculate_output"`
	// This field is from variant [MultiGrader].
	Graders MultiGraderGradersUnion `json:"graders"`
	JSON    struct {
		Input            respjson.Field
		Name             respjson.Field
		Operation        respjson.Field
		Reference        respjson.Field
		Type             respjson.Field
		EvaluationMetric respjson.Field
		Source           respjson.Field
		ImageTag         respjson.Field
		Model            respjson.Field
		Range            respjson.Field
		SamplingParams   respjson.Field
		CalculateOutput  respjson.Field
		Graders          respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

FineTuningAlphaGraderValidateResponseGraderUnion contains all possible properties and values from StringCheckGrader, TextSimilarityGrader, PythonGrader, ScoreModelGrader, MultiGrader.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (FineTuningAlphaGraderValidateResponseGraderUnion) AsMultiGrader

func (FineTuningAlphaGraderValidateResponseGraderUnion) AsPythonGrader

func (FineTuningAlphaGraderValidateResponseGraderUnion) AsScoreModelGrader

func (FineTuningAlphaGraderValidateResponseGraderUnion) AsStringCheckGrader

func (FineTuningAlphaGraderValidateResponseGraderUnion) AsTextSimilarityGrader

func (FineTuningAlphaGraderValidateResponseGraderUnion) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningAlphaGraderValidateResponseGraderUnion) UnmarshalJSON

type FineTuningAlphaGraderValidateResponseGraderUnionInput

type FineTuningAlphaGraderValidateResponseGraderUnionInput struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]ScoreModelGraderInput] instead
	// of an object.
	OfScoreModelGraderInputArray []ScoreModelGraderInput `json:",inline"`
	JSON                         struct {
		OfString                     respjson.Field
		OfScoreModelGraderInputArray respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

FineTuningAlphaGraderValidateResponseGraderUnionInput is an implicit subunion of FineTuningAlphaGraderValidateResponseGraderUnion. FineTuningAlphaGraderValidateResponseGraderUnionInput provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the FineTuningAlphaGraderValidateResponseGraderUnion.

If the underlying value is not a json object, one of the following properties will be valid: OfString OfScoreModelGraderInputArray]

func (*FineTuningAlphaGraderValidateResponseGraderUnionInput) UnmarshalJSON

type FineTuningAlphaService

type FineTuningAlphaService struct {
	Options []option.RequestOption
	Graders FineTuningAlphaGraderService
}

FineTuningAlphaService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningAlphaService method instead.

func NewFineTuningAlphaService

func NewFineTuningAlphaService(opts ...option.RequestOption) (r FineTuningAlphaService)

NewFineTuningAlphaService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type FineTuningCheckpointPermissionDeleteResponse

type FineTuningCheckpointPermissionDeleteResponse struct {
	// The ID of the fine-tuned model checkpoint permission that was deleted.
	ID string `json:"id,required"`
	// Whether the fine-tuned model checkpoint permission was successfully deleted.
	Deleted bool `json:"deleted,required"`
	// The object type, which is always "checkpoint.permission".
	Object constant.CheckpointPermission `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FineTuningCheckpointPermissionDeleteResponse) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningCheckpointPermissionDeleteResponse) UnmarshalJSON

func (r *FineTuningCheckpointPermissionDeleteResponse) UnmarshalJSON(data []byte) error

type FineTuningCheckpointPermissionGetParams

type FineTuningCheckpointPermissionGetParams struct {
	// Identifier for the last permission ID from the previous pagination request.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// Number of permissions to retrieve.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// The ID of the project to get permissions for.
	ProjectID param.Opt[string] `query:"project_id,omitzero" json:"-"`
	// The order in which to retrieve permissions.
	//
	// Any of "ascending", "descending".
	Order FineTuningCheckpointPermissionGetParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (FineTuningCheckpointPermissionGetParams) URLQuery

URLQuery serializes FineTuningCheckpointPermissionGetParams's query parameters as `url.Values`.

type FineTuningCheckpointPermissionGetParamsOrder

type FineTuningCheckpointPermissionGetParamsOrder string

The order in which to retrieve permissions.

const (
	FineTuningCheckpointPermissionGetParamsOrderAscending  FineTuningCheckpointPermissionGetParamsOrder = "ascending"
	FineTuningCheckpointPermissionGetParamsOrderDescending FineTuningCheckpointPermissionGetParamsOrder = "descending"
)

type FineTuningCheckpointPermissionGetResponse

type FineTuningCheckpointPermissionGetResponse struct {
	Data    []FineTuningCheckpointPermissionGetResponseData `json:"data,required"`
	HasMore bool                                            `json:"has_more,required"`
	Object  constant.List                                   `json:"object,required"`
	FirstID string                                          `json:"first_id,nullable"`
	LastID  string                                          `json:"last_id,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		HasMore     respjson.Field
		Object      respjson.Field
		FirstID     respjson.Field
		LastID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FineTuningCheckpointPermissionGetResponse) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningCheckpointPermissionGetResponse) UnmarshalJSON

func (r *FineTuningCheckpointPermissionGetResponse) UnmarshalJSON(data []byte) error

type FineTuningCheckpointPermissionGetResponseData

type FineTuningCheckpointPermissionGetResponseData struct {
	// The permission identifier, which can be referenced in the API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the permission was created.
	CreatedAt int64 `json:"created_at,required"`
	// The object type, which is always "checkpoint.permission".
	Object constant.CheckpointPermission `json:"object,required"`
	// The project identifier that the permission is for.
	ProjectID string `json:"project_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Object      respjson.Field
		ProjectID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The `checkpoint.permission` object represents a permission for a fine-tuned model checkpoint.

func (FineTuningCheckpointPermissionGetResponseData) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningCheckpointPermissionGetResponseData) UnmarshalJSON

func (r *FineTuningCheckpointPermissionGetResponseData) UnmarshalJSON(data []byte) error

type FineTuningCheckpointPermissionNewParams

type FineTuningCheckpointPermissionNewParams struct {
	// The project identifiers to grant access to.
	ProjectIDs []string `json:"project_ids,omitzero,required"`
	// contains filtered or unexported fields
}

func (FineTuningCheckpointPermissionNewParams) MarshalJSON

func (r FineTuningCheckpointPermissionNewParams) MarshalJSON() (data []byte, err error)

func (*FineTuningCheckpointPermissionNewParams) UnmarshalJSON

func (r *FineTuningCheckpointPermissionNewParams) UnmarshalJSON(data []byte) error

type FineTuningCheckpointPermissionNewResponse

type FineTuningCheckpointPermissionNewResponse struct {
	// The permission identifier, which can be referenced in the API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the permission was created.
	CreatedAt int64 `json:"created_at,required"`
	// The object type, which is always "checkpoint.permission".
	Object constant.CheckpointPermission `json:"object,required"`
	// The project identifier that the permission is for.
	ProjectID string `json:"project_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Object      respjson.Field
		ProjectID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The `checkpoint.permission` object represents a permission for a fine-tuned model checkpoint.

func (FineTuningCheckpointPermissionNewResponse) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningCheckpointPermissionNewResponse) UnmarshalJSON

func (r *FineTuningCheckpointPermissionNewResponse) UnmarshalJSON(data []byte) error

type FineTuningCheckpointPermissionService

type FineTuningCheckpointPermissionService struct {
	Options []option.RequestOption
}

FineTuningCheckpointPermissionService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningCheckpointPermissionService method instead.

func NewFineTuningCheckpointPermissionService

func NewFineTuningCheckpointPermissionService(opts ...option.RequestOption) (r FineTuningCheckpointPermissionService)

NewFineTuningCheckpointPermissionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FineTuningCheckpointPermissionService) Delete

func (r *FineTuningCheckpointPermissionService) Delete(ctx context.Context, fineTunedModelCheckpoint string, permissionID string, opts ...option.RequestOption) (res *FineTuningCheckpointPermissionDeleteResponse, err error)

**NOTE:** This endpoint requires an [admin API key](../admin-api-keys).

Organization owners can use this endpoint to delete a permission for a fine-tuned model checkpoint.

func (*FineTuningCheckpointPermissionService) Get

**NOTE:** This endpoint requires an [admin API key](../admin-api-keys).

Organization owners can use this endpoint to view all permissions for a fine-tuned model checkpoint.

func (*FineTuningCheckpointPermissionService) New

**NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).

This enables organization owners to share fine-tuned models with other projects in their organization.

func (*FineTuningCheckpointPermissionService) NewAutoPaging

**NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).

This enables organization owners to share fine-tuned models with other projects in their organization.

type FineTuningCheckpointService

type FineTuningCheckpointService struct {
	Options     []option.RequestOption
	Permissions FineTuningCheckpointPermissionService
}

FineTuningCheckpointService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningCheckpointService method instead.

func NewFineTuningCheckpointService

func NewFineTuningCheckpointService(opts ...option.RequestOption) (r FineTuningCheckpointService)

NewFineTuningCheckpointService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type FineTuningJob

type FineTuningJob struct {
	// The object identifier, which can be referenced in the API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the fine-tuning job was created.
	CreatedAt int64 `json:"created_at,required"`
	// For fine-tuning jobs that have `failed`, this will contain more information on
	// the cause of the failure.
	Error FineTuningJobError `json:"error,required"`
	// The name of the fine-tuned model that is being created. The value will be null
	// if the fine-tuning job is still running.
	FineTunedModel string `json:"fine_tuned_model,required"`
	// The Unix timestamp (in seconds) for when the fine-tuning job was finished. The
	// value will be null if the fine-tuning job is still running.
	FinishedAt int64 `json:"finished_at,required"`
	// The hyperparameters used for the fine-tuning job. This value will only be
	// returned when running `supervised` jobs.
	Hyperparameters FineTuningJobHyperparameters `json:"hyperparameters,required"`
	// The base model that is being fine-tuned.
	Model string `json:"model,required"`
	// The object type, which is always "fine_tuning.job".
	Object constant.FineTuningJob `json:"object,required"`
	// The organization that owns the fine-tuning job.
	OrganizationID string `json:"organization_id,required"`
	// The compiled results file ID(s) for the fine-tuning job. You can retrieve the
	// results with the
	// [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
	ResultFiles []string `json:"result_files,required"`
	// The seed used for the fine-tuning job.
	Seed int64 `json:"seed,required"`
	// The current status of the fine-tuning job, which can be either
	// `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
	//
	// Any of "validating_files", "queued", "running", "succeeded", "failed",
	// "cancelled".
	Status FineTuningJobStatus `json:"status,required"`
	// The total number of billable tokens processed by this fine-tuning job. The value
	// will be null if the fine-tuning job is still running.
	TrainedTokens int64 `json:"trained_tokens,required"`
	// The file ID used for training. You can retrieve the training data with the
	// [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
	TrainingFile string `json:"training_file,required"`
	// The file ID used for validation. You can retrieve the validation results with
	// the
	// [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
	ValidationFile string `json:"validation_file,required"`
	// The Unix timestamp (in seconds) for when the fine-tuning job is estimated to
	// finish. The value will be null if the fine-tuning job is not running.
	EstimatedFinish int64 `json:"estimated_finish,nullable"`
	// A list of integrations to enable for this fine-tuning job.
	Integrations []FineTuningJobWandbIntegrationObject `json:"integrations,nullable"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,nullable"`
	// The method used for fine-tuning.
	Method FineTuningJobMethod `json:"method"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID              respjson.Field
		CreatedAt       respjson.Field
		Error           respjson.Field
		FineTunedModel  respjson.Field
		FinishedAt      respjson.Field
		Hyperparameters respjson.Field
		Model           respjson.Field
		Object          respjson.Field
		OrganizationID  respjson.Field
		ResultFiles     respjson.Field
		Seed            respjson.Field
		Status          respjson.Field
		TrainedTokens   respjson.Field
		TrainingFile    respjson.Field
		ValidationFile  respjson.Field
		EstimatedFinish respjson.Field
		Integrations    respjson.Field
		Metadata        respjson.Field
		Method          respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The `fine_tuning.job` object represents a fine-tuning job that has been created through the API.

func (FineTuningJob) RawJSON

func (r FineTuningJob) RawJSON() string

Returns the unmodified JSON received from the API

func (*FineTuningJob) UnmarshalJSON

func (r *FineTuningJob) UnmarshalJSON(data []byte) error

type FineTuningJobCheckpoint

type FineTuningJobCheckpoint struct {
	// The checkpoint identifier, which can be referenced in the API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the checkpoint was created.
	CreatedAt int64 `json:"created_at,required"`
	// The name of the fine-tuned checkpoint model that is created.
	FineTunedModelCheckpoint string `json:"fine_tuned_model_checkpoint,required"`
	// The name of the fine-tuning job that this checkpoint was created from.
	FineTuningJobID string `json:"fine_tuning_job_id,required"`
	// Metrics at the step number during the fine-tuning job.
	Metrics FineTuningJobCheckpointMetrics `json:"metrics,required"`
	// The object type, which is always "fine_tuning.job.checkpoint".
	Object constant.FineTuningJobCheckpoint `json:"object,required"`
	// The step number that the checkpoint was created at.
	StepNumber int64 `json:"step_number,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                       respjson.Field
		CreatedAt                respjson.Field
		FineTunedModelCheckpoint respjson.Field
		FineTuningJobID          respjson.Field
		Metrics                  respjson.Field
		Object                   respjson.Field
		StepNumber               respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The `fine_tuning.job.checkpoint` object represents a model checkpoint for a fine-tuning job that is ready to use.

func (FineTuningJobCheckpoint) RawJSON

func (r FineTuningJobCheckpoint) RawJSON() string

Returns the unmodified JSON received from the API

func (*FineTuningJobCheckpoint) UnmarshalJSON

func (r *FineTuningJobCheckpoint) UnmarshalJSON(data []byte) error

type FineTuningJobCheckpointListParams

type FineTuningJobCheckpointListParams struct {
	// Identifier for the last checkpoint ID from the previous pagination request.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// Number of checkpoints to retrieve.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (FineTuningJobCheckpointListParams) URLQuery

func (r FineTuningJobCheckpointListParams) URLQuery() (v url.Values, err error)

URLQuery serializes FineTuningJobCheckpointListParams's query parameters as `url.Values`.

type FineTuningJobCheckpointMetrics

type FineTuningJobCheckpointMetrics struct {
	FullValidLoss              float64 `json:"full_valid_loss"`
	FullValidMeanTokenAccuracy float64 `json:"full_valid_mean_token_accuracy"`
	Step                       float64 `json:"step"`
	TrainLoss                  float64 `json:"train_loss"`
	TrainMeanTokenAccuracy     float64 `json:"train_mean_token_accuracy"`
	ValidLoss                  float64 `json:"valid_loss"`
	ValidMeanTokenAccuracy     float64 `json:"valid_mean_token_accuracy"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FullValidLoss              respjson.Field
		FullValidMeanTokenAccuracy respjson.Field
		Step                       respjson.Field
		TrainLoss                  respjson.Field
		TrainMeanTokenAccuracy     respjson.Field
		ValidLoss                  respjson.Field
		ValidMeanTokenAccuracy     respjson.Field
		ExtraFields                map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Metrics at the step number during the fine-tuning job.

func (FineTuningJobCheckpointMetrics) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningJobCheckpointMetrics) UnmarshalJSON

func (r *FineTuningJobCheckpointMetrics) UnmarshalJSON(data []byte) error

type FineTuningJobCheckpointService

type FineTuningJobCheckpointService struct {
	Options []option.RequestOption
}

FineTuningJobCheckpointService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningJobCheckpointService method instead.

func NewFineTuningJobCheckpointService

func NewFineTuningJobCheckpointService(opts ...option.RequestOption) (r FineTuningJobCheckpointService)

NewFineTuningJobCheckpointService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FineTuningJobCheckpointService) List

List checkpoints for a fine-tuning job.

func (*FineTuningJobCheckpointService) ListAutoPaging

List checkpoints for a fine-tuning job.

type FineTuningJobError

type FineTuningJobError struct {
	// A machine-readable error code.
	Code string `json:"code,required"`
	// A human-readable error message.
	Message string `json:"message,required"`
	// The parameter that was invalid, usually `training_file` or `validation_file`.
	// This field will be null if the failure was not parameter-specific.
	Param string `json:"param,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Message     respjson.Field
		Param       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure.

func (FineTuningJobError) RawJSON

func (r FineTuningJobError) RawJSON() string

Returns the unmodified JSON received from the API

func (*FineTuningJobError) UnmarshalJSON

func (r *FineTuningJobError) UnmarshalJSON(data []byte) error

type FineTuningJobEvent

type FineTuningJobEvent struct {
	// The object identifier.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the fine-tuning job was created.
	CreatedAt int64 `json:"created_at,required"`
	// The log level of the event.
	//
	// Any of "info", "warn", "error".
	Level FineTuningJobEventLevel `json:"level,required"`
	// The message of the event.
	Message string `json:"message,required"`
	// The object type, which is always "fine_tuning.job.event".
	Object constant.FineTuningJobEvent `json:"object,required"`
	// The data associated with the event.
	Data any `json:"data"`
	// The type of event.
	//
	// Any of "message", "metrics".
	Type FineTuningJobEventType `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Level       respjson.Field
		Message     respjson.Field
		Object      respjson.Field
		Data        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Fine-tuning job event object

func (FineTuningJobEvent) RawJSON

func (r FineTuningJobEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*FineTuningJobEvent) UnmarshalJSON

func (r *FineTuningJobEvent) UnmarshalJSON(data []byte) error

type FineTuningJobEventLevel

type FineTuningJobEventLevel string

The log level of the event.

const (
	FineTuningJobEventLevelInfo  FineTuningJobEventLevel = "info"
	FineTuningJobEventLevelWarn  FineTuningJobEventLevel = "warn"
	FineTuningJobEventLevelError FineTuningJobEventLevel = "error"
)

type FineTuningJobEventType

type FineTuningJobEventType string

The type of event.

const (
	FineTuningJobEventTypeMessage FineTuningJobEventType = "message"
	FineTuningJobEventTypeMetrics FineTuningJobEventType = "metrics"
)

type FineTuningJobHyperparameters

type FineTuningJobHyperparameters struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize FineTuningJobHyperparametersBatchSizeUnion `json:"batch_size,nullable"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier FineTuningJobHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs FineTuningJobHyperparametersNEpochsUnion `json:"n_epochs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BatchSize              respjson.Field
		LearningRateMultiplier respjson.Field
		NEpochs                respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The hyperparameters used for the fine-tuning job. This value will only be returned when running `supervised` jobs.

func (FineTuningJobHyperparameters) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningJobHyperparameters) UnmarshalJSON

func (r *FineTuningJobHyperparameters) UnmarshalJSON(data []byte) error

type FineTuningJobHyperparametersBatchSizeUnion

type FineTuningJobHyperparametersBatchSizeUnion struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

FineTuningJobHyperparametersBatchSizeUnion contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (FineTuningJobHyperparametersBatchSizeUnion) AsAuto added in v1.2.1

func (FineTuningJobHyperparametersBatchSizeUnion) AsInt

func (FineTuningJobHyperparametersBatchSizeUnion) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningJobHyperparametersBatchSizeUnion) UnmarshalJSON

func (r *FineTuningJobHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error

type FineTuningJobHyperparametersLearningRateMultiplierUnion

type FineTuningJobHyperparametersLearningRateMultiplierUnion struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfAuto  respjson.Field
		OfFloat respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

FineTuningJobHyperparametersLearningRateMultiplierUnion contains all possible properties and values from constant.Auto, [float64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfFloat]

func (FineTuningJobHyperparametersLearningRateMultiplierUnion) AsAuto

func (FineTuningJobHyperparametersLearningRateMultiplierUnion) AsFloat

func (FineTuningJobHyperparametersLearningRateMultiplierUnion) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningJobHyperparametersLearningRateMultiplierUnion) UnmarshalJSON

type FineTuningJobHyperparametersNEpochsUnion

type FineTuningJobHyperparametersNEpochsUnion struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

FineTuningJobHyperparametersNEpochsUnion contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (FineTuningJobHyperparametersNEpochsUnion) AsAuto

func (FineTuningJobHyperparametersNEpochsUnion) AsInt

func (FineTuningJobHyperparametersNEpochsUnion) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningJobHyperparametersNEpochsUnion) UnmarshalJSON

func (r *FineTuningJobHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error

type FineTuningJobListEventsParams

type FineTuningJobListEventsParams struct {
	// Identifier for the last event from the previous pagination request.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// Number of events to retrieve.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (FineTuningJobListEventsParams) URLQuery

func (r FineTuningJobListEventsParams) URLQuery() (v url.Values, err error)

URLQuery serializes FineTuningJobListEventsParams's query parameters as `url.Values`.

type FineTuningJobListParams

type FineTuningJobListParams struct {
	// Identifier for the last job from the previous pagination request.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// Number of fine-tuning jobs to retrieve.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
	// Alternatively, set `metadata=null` to indicate no metadata.
	Metadata map[string]string `query:"metadata,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (FineTuningJobListParams) URLQuery

func (r FineTuningJobListParams) URLQuery() (v url.Values, err error)

URLQuery serializes FineTuningJobListParams's query parameters as `url.Values`.

type FineTuningJobMethod

type FineTuningJobMethod struct {
	// The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
	//
	// Any of "supervised", "dpo", "reinforcement".
	Type string `json:"type,required"`
	// Configuration for the DPO fine-tuning method.
	Dpo DpoMethod `json:"dpo"`
	// Configuration for the reinforcement fine-tuning method.
	Reinforcement ReinforcementMethod `json:"reinforcement"`
	// Configuration for the supervised fine-tuning method.
	Supervised SupervisedMethod `json:"supervised"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type          respjson.Field
		Dpo           respjson.Field
		Reinforcement respjson.Field
		Supervised    respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The method used for fine-tuning.

func (FineTuningJobMethod) RawJSON

func (r FineTuningJobMethod) RawJSON() string

Returns the unmodified JSON received from the API

func (*FineTuningJobMethod) UnmarshalJSON

func (r *FineTuningJobMethod) UnmarshalJSON(data []byte) error

type FineTuningJobNewParams

type FineTuningJobNewParams struct {
	// The name of the model to fine-tune. You can select one of the
	// [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
	Model FineTuningJobNewParamsModel `json:"model,omitzero,required"`
	// The ID of an uploaded file that contains training data.
	//
	// See [upload file](https://platform.openai.com/docs/api-reference/files/create)
	// for how to upload a file.
	//
	// Your dataset must be formatted as a JSONL file. Additionally, you must upload
	// your file with the purpose `fine-tune`.
	//
	// The contents of the file should differ depending on if the model uses the
	// [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input),
	// [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
	// format, or if the fine-tuning method uses the
	// [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
	// format.
	//
	// See the
	// [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
	// for more details.
	TrainingFile string `json:"training_file,required"`
	// The seed controls the reproducibility of the job. Passing in the same seed and
	// job parameters should produce the same results, but may differ in rare cases. If
	// a seed is not specified, one will be generated for you.
	Seed param.Opt[int64] `json:"seed,omitzero"`
	// A string of up to 64 characters that will be added to your fine-tuned model
	// name.
	//
	// For example, a `suffix` of "custom-model-name" would produce a model name like
	// `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`.
	Suffix param.Opt[string] `json:"suffix,omitzero"`
	// The ID of an uploaded file that contains validation data.
	//
	// If you provide this file, the data is used to generate validation metrics
	// periodically during fine-tuning. These metrics can be viewed in the fine-tuning
	// results file. The same data should not be present in both train and validation
	// files.
	//
	// Your dataset must be formatted as a JSONL file. You must upload your file with
	// the purpose `fine-tune`.
	//
	// See the
	// [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
	// for more details.
	ValidationFile param.Opt[string] `json:"validation_file,omitzero"`
	// A list of integrations to enable for your fine-tuning job.
	Integrations []FineTuningJobNewParamsIntegration `json:"integrations,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// The hyperparameters used for the fine-tuning job. This value is now deprecated
	// in favor of `method`, and should be passed in under the `method` parameter.
	Hyperparameters FineTuningJobNewParamsHyperparameters `json:"hyperparameters,omitzero"`
	// The method used for fine-tuning.
	Method FineTuningJobNewParamsMethod `json:"method,omitzero"`
	// contains filtered or unexported fields
}

func (FineTuningJobNewParams) MarshalJSON

func (r FineTuningJobNewParams) MarshalJSON() (data []byte, err error)

func (*FineTuningJobNewParams) UnmarshalJSON

func (r *FineTuningJobNewParams) UnmarshalJSON(data []byte) error

type FineTuningJobNewParamsHyperparameters deprecated

type FineTuningJobNewParamsHyperparameters struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize FineTuningJobNewParamsHyperparametersBatchSizeUnion `json:"batch_size,omitzero"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier,omitzero"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs FineTuningJobNewParamsHyperparametersNEpochsUnion `json:"n_epochs,omitzero"`
	// contains filtered or unexported fields
}

The hyperparameters used for the fine-tuning job. This value is now deprecated in favor of `method`, and should be passed in under the `method` parameter.

Deprecated: deprecated

func (FineTuningJobNewParamsHyperparameters) MarshalJSON

func (r FineTuningJobNewParamsHyperparameters) MarshalJSON() (data []byte, err error)

func (*FineTuningJobNewParamsHyperparameters) UnmarshalJSON

func (r *FineTuningJobNewParamsHyperparameters) UnmarshalJSON(data []byte) error

type FineTuningJobNewParamsHyperparametersBatchSizeUnion

type FineTuningJobNewParamsHyperparametersBatchSizeUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (FineTuningJobNewParamsHyperparametersBatchSizeUnion) MarshalJSON

func (*FineTuningJobNewParamsHyperparametersBatchSizeUnion) UnmarshalJSON

type FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion

type FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto  constant.Auto      `json:",omitzero,inline"`
	OfFloat param.Opt[float64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion) MarshalJSON

func (*FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion) UnmarshalJSON

type FineTuningJobNewParamsHyperparametersNEpochsUnion

type FineTuningJobNewParamsHyperparametersNEpochsUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (FineTuningJobNewParamsHyperparametersNEpochsUnion) MarshalJSON

func (*FineTuningJobNewParamsHyperparametersNEpochsUnion) UnmarshalJSON

type FineTuningJobNewParamsIntegration

type FineTuningJobNewParamsIntegration struct {
	// The settings for your integration with Weights and Biases. This payload
	// specifies the project that metrics will be sent to. Optionally, you can set an
	// explicit display name for your run, add tags to your run, and set a default
	// entity (team, username, etc) to be associated with your run.
	Wandb FineTuningJobNewParamsIntegrationWandb `json:"wandb,omitzero,required"`
	// The type of integration to enable. Currently, only "wandb" (Weights and Biases)
	// is supported.
	//
	// This field can be elided, and will marshal its zero value as "wandb".
	Type constant.Wandb `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, Wandb are required.

func (FineTuningJobNewParamsIntegration) MarshalJSON

func (r FineTuningJobNewParamsIntegration) MarshalJSON() (data []byte, err error)

func (*FineTuningJobNewParamsIntegration) UnmarshalJSON

func (r *FineTuningJobNewParamsIntegration) UnmarshalJSON(data []byte) error

type FineTuningJobNewParamsIntegrationWandb

type FineTuningJobNewParamsIntegrationWandb struct {
	// The name of the project that the new run will be created under.
	Project string `json:"project,required"`
	// The entity to use for the run. This allows you to set the team or username of
	// the WandB user that you would like associated with the run. If not set, the
	// default entity for the registered WandB API key is used.
	Entity param.Opt[string] `json:"entity,omitzero"`
	// A display name to set for the run. If not set, we will use the Job ID as the
	// name.
	Name param.Opt[string] `json:"name,omitzero"`
	// A list of tags to be attached to the newly created run. These tags are passed
	// through directly to WandB. Some default tags are generated by OpenAI:
	// "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".
	Tags []string `json:"tags,omitzero"`
	// contains filtered or unexported fields
}

The settings for your integration with Weights and Biases. This payload specifies the project that metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags to your run, and set a default entity (team, username, etc) to be associated with your run.

The property Project is required.

func (FineTuningJobNewParamsIntegrationWandb) MarshalJSON

func (r FineTuningJobNewParamsIntegrationWandb) MarshalJSON() (data []byte, err error)

func (*FineTuningJobNewParamsIntegrationWandb) UnmarshalJSON

func (r *FineTuningJobNewParamsIntegrationWandb) UnmarshalJSON(data []byte) error

type FineTuningJobNewParamsMethod

type FineTuningJobNewParamsMethod struct {
	// The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
	//
	// Any of "supervised", "dpo", "reinforcement".
	Type string `json:"type,omitzero,required"`
	// Configuration for the DPO fine-tuning method.
	Dpo DpoMethodParam `json:"dpo,omitzero"`
	// Configuration for the reinforcement fine-tuning method.
	Reinforcement ReinforcementMethodParam `json:"reinforcement,omitzero"`
	// Configuration for the supervised fine-tuning method.
	Supervised SupervisedMethodParam `json:"supervised,omitzero"`
	// contains filtered or unexported fields
}

The method used for fine-tuning.

The property Type is required.

func (FineTuningJobNewParamsMethod) MarshalJSON

func (r FineTuningJobNewParamsMethod) MarshalJSON() (data []byte, err error)

func (*FineTuningJobNewParamsMethod) UnmarshalJSON

func (r *FineTuningJobNewParamsMethod) UnmarshalJSON(data []byte) error

type FineTuningJobNewParamsModel

type FineTuningJobNewParamsModel string

The name of the model to fine-tune. You can select one of the [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).

const (
	FineTuningJobNewParamsModelBabbage002  FineTuningJobNewParamsModel = "babbage-002"
	FineTuningJobNewParamsModelDavinci002  FineTuningJobNewParamsModel = "davinci-002"
	FineTuningJobNewParamsModelGPT3_5Turbo FineTuningJobNewParamsModel = "gpt-3.5-turbo"
	FineTuningJobNewParamsModelGPT4oMini   FineTuningJobNewParamsModel = "gpt-4o-mini"
)

type FineTuningJobService

type FineTuningJobService struct {
	Options     []option.RequestOption
	Checkpoints FineTuningJobCheckpointService
}

FineTuningJobService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningJobService method instead.

func NewFineTuningJobService

func NewFineTuningJobService(opts ...option.RequestOption) (r FineTuningJobService)

NewFineTuningJobService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FineTuningJobService) Cancel

func (r *FineTuningJobService) Cancel(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)

Immediately cancel a fine-tune job.

func (*FineTuningJobService) Get

func (r *FineTuningJobService) Get(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)

Get info about a fine-tuning job.

[Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)

func (*FineTuningJobService) List

List your organization's fine-tuning jobs

func (*FineTuningJobService) ListAutoPaging

List your organization's fine-tuning jobs

func (*FineTuningJobService) ListEvents

Get status updates for a fine-tuning job.

func (*FineTuningJobService) ListEventsAutoPaging

Get status updates for a fine-tuning job.

func (*FineTuningJobService) New

Creates a fine-tuning job which begins the process of creating a new model from a given dataset.

Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.

[Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)

func (*FineTuningJobService) Pause

func (r *FineTuningJobService) Pause(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)

Pause a fine-tune job.

func (*FineTuningJobService) Resume

func (r *FineTuningJobService) Resume(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)

Resume a fine-tune job.

type FineTuningJobStatus

type FineTuningJobStatus string

The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.

const (
	FineTuningJobStatusValidatingFiles FineTuningJobStatus = "validating_files"
	FineTuningJobStatusQueued          FineTuningJobStatus = "queued"
	FineTuningJobStatusRunning         FineTuningJobStatus = "running"
	FineTuningJobStatusSucceeded       FineTuningJobStatus = "succeeded"
	FineTuningJobStatusFailed          FineTuningJobStatus = "failed"
	FineTuningJobStatusCancelled       FineTuningJobStatus = "cancelled"
)

type FineTuningJobWandbIntegration

type FineTuningJobWandbIntegration struct {
	// The name of the project that the new run will be created under.
	Project string `json:"project,required"`
	// The entity to use for the run. This allows you to set the team or username of
	// the WandB user that you would like associated with the run. If not set, the
	// default entity for the registered WandB API key is used.
	Entity string `json:"entity,nullable"`
	// A display name to set for the run. If not set, we will use the Job ID as the
	// name.
	Name string `json:"name,nullable"`
	// A list of tags to be attached to the newly created run. These tags are passed
	// through directly to WandB. Some default tags are generated by OpenAI:
	// "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".
	Tags []string `json:"tags"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Project     respjson.Field
		Entity      respjson.Field
		Name        respjson.Field
		Tags        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The settings for your integration with Weights and Biases. This payload specifies the project that metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags to your run, and set a default entity (team, username, etc) to be associated with your run.

func (FineTuningJobWandbIntegration) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningJobWandbIntegration) UnmarshalJSON

func (r *FineTuningJobWandbIntegration) UnmarshalJSON(data []byte) error

type FineTuningJobWandbIntegrationObject

type FineTuningJobWandbIntegrationObject struct {
	// The type of the integration being enabled for the fine-tuning job
	Type constant.Wandb `json:"type,required"`
	// The settings for your integration with Weights and Biases. This payload
	// specifies the project that metrics will be sent to. Optionally, you can set an
	// explicit display name for your run, add tags to your run, and set a default
	// entity (team, username, etc) to be associated with your run.
	Wandb FineTuningJobWandbIntegration `json:"wandb,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		Wandb       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FineTuningJobWandbIntegrationObject) RawJSON

Returns the unmodified JSON received from the API

func (*FineTuningJobWandbIntegrationObject) UnmarshalJSON

func (r *FineTuningJobWandbIntegrationObject) UnmarshalJSON(data []byte) error

type FineTuningMethodService

type FineTuningMethodService struct {
	Options []option.RequestOption
}

FineTuningMethodService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningMethodService method instead.

func NewFineTuningMethodService

func NewFineTuningMethodService(opts ...option.RequestOption) (r FineTuningMethodService)

NewFineTuningMethodService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type FineTuningService

type FineTuningService struct {
	Options     []option.RequestOption
	Methods     FineTuningMethodService
	Jobs        FineTuningJobService
	Checkpoints FineTuningCheckpointService
	Alpha       FineTuningAlphaService
}

FineTuningService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFineTuningService method instead.

func NewFineTuningService

func NewFineTuningService(opts ...option.RequestOption) (r FineTuningService)

NewFineTuningService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type FinishedChatCompletionToolCall

type FinishedChatCompletionToolCall struct {
	ChatCompletionMessageToolCallFunction
	Index int
	ID    string
}

type FunctionDefinition added in v1.1.0

type FunctionDefinition = shared.FunctionDefinition

This is an alias to an internal type.

type FunctionDefinitionParam

type FunctionDefinitionParam = shared.FunctionDefinitionParam

This is an alias to an internal type.

type FunctionParameters

type FunctionParameters = shared.FunctionParameters

The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.

Omitting `parameters` defines a function with an empty parameter list.

This is an alias to an internal type.

type FunctionTool added in v1.1.0

type FunctionTool struct {
	Function shared.FunctionDefinition `json:"function,required"`
	// The type of tool being defined: `function`
	Type constant.Function `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Function    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FunctionTool) RawJSON added in v1.1.0

func (r FunctionTool) RawJSON() string

Returns the unmodified JSON received from the API

func (FunctionTool) ToParam added in v1.1.0

func (r FunctionTool) ToParam() FunctionToolParam

ToParam converts this FunctionTool to a FunctionToolParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with FunctionToolParam.Overrides()

func (*FunctionTool) UnmarshalJSON added in v1.1.0

func (r *FunctionTool) UnmarshalJSON(data []byte) error

type FunctionToolCall added in v1.1.0

type FunctionToolCall struct {
	// The ID of the tool call object.
	ID string `json:"id,required"`
	// The definition of the function that was called.
	Function FunctionToolCallFunction `json:"function,required"`
	// The type of tool call. This is always going to be `function` for this type of
	// tool call.
	Type constant.Function `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Function    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FunctionToolCall) RawJSON added in v1.1.0

func (r FunctionToolCall) RawJSON() string

Returns the unmodified JSON received from the API

func (*FunctionToolCall) UnmarshalJSON added in v1.1.0

func (r *FunctionToolCall) UnmarshalJSON(data []byte) error

type FunctionToolCallDelta added in v1.1.0

type FunctionToolCallDelta struct {
	// The index of the tool call in the tool calls array.
	Index int64 `json:"index,required"`
	// The type of tool call. This is always going to be `function` for this type of
	// tool call.
	Type constant.Function `json:"type,required"`
	// The ID of the tool call object.
	ID string `json:"id"`
	// The definition of the function that was called.
	Function FunctionToolCallDeltaFunction `json:"function"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		ID          respjson.Field
		Function    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FunctionToolCallDelta) RawJSON added in v1.1.0

func (r FunctionToolCallDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*FunctionToolCallDelta) UnmarshalJSON added in v1.1.0

func (r *FunctionToolCallDelta) UnmarshalJSON(data []byte) error

type FunctionToolCallDeltaFunction added in v1.1.0

type FunctionToolCallDeltaFunction struct {
	// The arguments passed to the function.
	Arguments string `json:"arguments"`
	// The name of the function.
	Name string `json:"name"`
	// The output of the function. This will be `null` if the outputs have not been
	// [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
	// yet.
	Output string `json:"output,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Name        respjson.Field
		Output      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The definition of the function that was called.

func (FunctionToolCallDeltaFunction) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*FunctionToolCallDeltaFunction) UnmarshalJSON added in v1.1.0

func (r *FunctionToolCallDeltaFunction) UnmarshalJSON(data []byte) error

type FunctionToolCallFunction added in v1.1.0

type FunctionToolCallFunction struct {
	// The arguments passed to the function.
	Arguments string `json:"arguments,required"`
	// The name of the function.
	Name string `json:"name,required"`
	// The output of the function. This will be `null` if the outputs have not been
	// [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
	// yet.
	Output string `json:"output,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Name        respjson.Field
		Output      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The definition of the function that was called.

func (FunctionToolCallFunction) RawJSON added in v1.1.0

func (r FunctionToolCallFunction) RawJSON() string

Returns the unmodified JSON received from the API

func (*FunctionToolCallFunction) UnmarshalJSON added in v1.1.0

func (r *FunctionToolCallFunction) UnmarshalJSON(data []byte) error

type FunctionToolParam added in v1.1.0

type FunctionToolParam struct {
	Function shared.FunctionDefinitionParam `json:"function,omitzero,required"`
	// The type of tool being defined: `function`
	//
	// This field can be elided, and will marshal its zero value as "function".
	Type constant.Function `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Function, Type are required.

func (FunctionToolParam) MarshalJSON added in v1.1.0

func (r FunctionToolParam) MarshalJSON() (data []byte, err error)

func (*FunctionToolParam) UnmarshalJSON added in v1.1.0

func (r *FunctionToolParam) UnmarshalJSON(data []byte) error

type GraderGraderModelService

type GraderGraderModelService struct {
	Options []option.RequestOption
}

GraderGraderModelService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewGraderGraderModelService method instead.

func NewGraderGraderModelService

func NewGraderGraderModelService(opts ...option.RequestOption) (r GraderGraderModelService)

NewGraderGraderModelService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type GraderService

type GraderService struct {
	Options      []option.RequestOption
	GraderModels GraderGraderModelService
}

GraderService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewGraderService method instead.

func NewGraderService

func NewGraderService(opts ...option.RequestOption) (r GraderService)

NewGraderService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type Image

type Image struct {
	// The base64-encoded JSON of the generated image. Default value for `gpt-image-1`,
	// and only present if `response_format` is set to `b64_json` for `dall-e-2` and
	// `dall-e-3`.
	B64JSON string `json:"b64_json"`
	// For `dall-e-3` only, the revised prompt that was used to generate the image.
	RevisedPrompt string `json:"revised_prompt"`
	// When using `dall-e-2` or `dall-e-3`, the URL of the generated image if
	// `response_format` is set to `url` (default value). Unsupported for
	// `gpt-image-1`.
	URL string `json:"url"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		B64JSON       respjson.Field
		RevisedPrompt respjson.Field
		URL           respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents the content or the URL of an image generated by the OpenAI API.

func (Image) RawJSON

func (r Image) RawJSON() string

Returns the unmodified JSON received from the API

func (*Image) UnmarshalJSON

func (r *Image) UnmarshalJSON(data []byte) error

type ImageEditParams

type ImageEditParams struct {
	// The image(s) to edit. Must be a supported image file or an array of images.
	//
	// For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
	// 50MB. You can provide up to 16 images.
	//
	// For `dall-e-2`, you can only provide one image, and it should be a square `png`
	// file less than 4MB.
	Image ImageEditParamsImageUnion `json:"image,omitzero,required" format:"binary"`
	// A text description of the desired image(s). The maximum length is 1000
	// characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
	Prompt string `json:"prompt,required"`
	// The number of images to generate. Must be between 1 and 10.
	N param.Opt[int64] `json:"n,omitzero"`
	// The compression level (0-100%) for the generated images. This parameter is only
	// supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
	// defaults to 100.
	OutputCompression param.Opt[int64] `json:"output_compression,omitzero"`
	// A unique identifier representing your end-user, which can help OpenAI to monitor
	// and detect abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
	User param.Opt[string] `json:"user,omitzero"`
	// Allows to set transparency for the background of the generated image(s). This
	// parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
	// `opaque` or `auto` (default value). When `auto` is used, the model will
	// automatically determine the best background for the image.
	//
	// If `transparent`, the output format needs to support transparency, so it should
	// be set to either `png` (default value) or `webp`.
	//
	// Any of "transparent", "opaque", "auto".
	Background ImageEditParamsBackground `json:"background,omitzero"`
	// The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are
	// supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1`
	// is used.
	Model ImageModel `json:"model,omitzero"`
	// The format in which the generated images are returned. This parameter is only
	// supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
	// default value is `png`.
	//
	// Any of "png", "jpeg", "webp".
	OutputFormat ImageEditParamsOutputFormat `json:"output_format,omitzero"`
	// The quality of the image that will be generated. `high`, `medium` and `low` are
	// only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
	// Defaults to `auto`.
	//
	// Any of "standard", "low", "medium", "high", "auto".
	Quality ImageEditParamsQuality `json:"quality,omitzero"`
	// The format in which the generated images are returned. Must be one of `url` or
	// `b64_json`. URLs are only valid for 60 minutes after the image has been
	// generated. This parameter is only supported for `dall-e-2`, as `gpt-image-1`
	// will always return base64-encoded images.
	//
	// Any of "url", "b64_json".
	ResponseFormat ImageEditParamsResponseFormat `json:"response_format,omitzero"`
	// The size of the generated images. Must be one of `1024x1024`, `1536x1024`
	// (landscape), `1024x1536` (portrait), or `auto` (default value) for
	// `gpt-image-1`, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.
	//
	// Any of "256x256", "512x512", "1024x1024", "1536x1024", "1024x1536", "auto".
	Size ImageEditParamsSize `json:"size,omitzero"`
	// An additional image whose fully transparent areas (e.g. where alpha is zero)
	// indicate where `image` should be edited. If there are multiple images provided,
	// the mask will be applied on the first image. Must be a valid PNG file, less than
	// 4MB, and have the same dimensions as `image`.
	Mask io.Reader `json:"mask,omitzero" format:"binary"`
	// contains filtered or unexported fields
}

func (ImageEditParams) MarshalMultipart

func (r ImageEditParams) MarshalMultipart() (data []byte, contentType string, err error)

type ImageEditParamsBackground

type ImageEditParamsBackground string

Allows to set transparency for the background of the generated image(s). This parameter is only supported for `gpt-image-1`. Must be one of `transparent`, `opaque` or `auto` (default value). When `auto` is used, the model will automatically determine the best background for the image.

If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`.

const (
	ImageEditParamsBackgroundTransparent ImageEditParamsBackground = "transparent"
	ImageEditParamsBackgroundOpaque      ImageEditParamsBackground = "opaque"
	ImageEditParamsBackgroundAuto        ImageEditParamsBackground = "auto"
)

type ImageEditParamsImageUnion

type ImageEditParamsImageUnion struct {
	OfFile      io.Reader   `json:",omitzero,inline"`
	OfFileArray []io.Reader `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ImageEditParamsImageUnion) MarshalJSON

func (u ImageEditParamsImageUnion) MarshalJSON() ([]byte, error)

func (*ImageEditParamsImageUnion) UnmarshalJSON

func (u *ImageEditParamsImageUnion) UnmarshalJSON(data []byte) error

type ImageEditParamsOutputFormat added in v1.6.0

type ImageEditParamsOutputFormat string

The format in which the generated images are returned. This parameter is only supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The default value is `png`.

const (
	ImageEditParamsOutputFormatPNG  ImageEditParamsOutputFormat = "png"
	ImageEditParamsOutputFormatJPEG ImageEditParamsOutputFormat = "jpeg"
	ImageEditParamsOutputFormatWebP ImageEditParamsOutputFormat = "webp"
)

type ImageEditParamsQuality

type ImageEditParamsQuality string

The quality of the image that will be generated. `high`, `medium` and `low` are only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality. Defaults to `auto`.

const (
	ImageEditParamsQualityStandard ImageEditParamsQuality = "standard"
	ImageEditParamsQualityLow      ImageEditParamsQuality = "low"
	ImageEditParamsQualityMedium   ImageEditParamsQuality = "medium"
	ImageEditParamsQualityHigh     ImageEditParamsQuality = "high"
	ImageEditParamsQualityAuto     ImageEditParamsQuality = "auto"
)

type ImageEditParamsResponseFormat

type ImageEditParamsResponseFormat string

The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter is only supported for `dall-e-2`, as `gpt-image-1` will always return base64-encoded images.

const (
	ImageEditParamsResponseFormatURL     ImageEditParamsResponseFormat = "url"
	ImageEditParamsResponseFormatB64JSON ImageEditParamsResponseFormat = "b64_json"
)

type ImageEditParamsSize

type ImageEditParamsSize string

The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or `auto` (default value) for `gpt-image-1`, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.

const (
	ImageEditParamsSize256x256   ImageEditParamsSize = "256x256"
	ImageEditParamsSize512x512   ImageEditParamsSize = "512x512"
	ImageEditParamsSize1024x1024 ImageEditParamsSize = "1024x1024"
	ImageEditParamsSize1536x1024 ImageEditParamsSize = "1536x1024"
	ImageEditParamsSize1024x1536 ImageEditParamsSize = "1024x1536"
	ImageEditParamsSizeAuto      ImageEditParamsSize = "auto"
)

type ImageFile added in v1.1.0

type ImageFile struct {
	// The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
	// in the message content. Set `purpose="vision"` when uploading the File if you
	// need to later display the file content.
	FileID string `json:"file_id,required"`
	// Specifies the detail level of the image if specified by the user. `low` uses
	// fewer tokens, you can opt in to high resolution using `high`.
	//
	// Any of "auto", "low", "high".
	Detail ImageFileDetail `json:"detail"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Detail      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ImageFile) RawJSON added in v1.1.0

func (r ImageFile) RawJSON() string

Returns the unmodified JSON received from the API

func (ImageFile) ToParam added in v1.1.0

func (r ImageFile) ToParam() ImageFileParam

ToParam converts this ImageFile to a ImageFileParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ImageFileParam.Overrides()

func (*ImageFile) UnmarshalJSON added in v1.1.0

func (r *ImageFile) UnmarshalJSON(data []byte) error

type ImageFileContentBlock added in v1.1.0

type ImageFileContentBlock struct {
	ImageFile ImageFile `json:"image_file,required"`
	// Always `image_file`.
	Type constant.ImageFile `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ImageFile   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

References an image File(https://platform.openai.com/docs/api-reference/files) in the content of a message.

func (ImageFileContentBlock) RawJSON added in v1.1.0

func (r ImageFileContentBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ImageFileContentBlock) ToParam added in v1.1.0

ToParam converts this ImageFileContentBlock to a ImageFileContentBlockParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ImageFileContentBlockParam.Overrides()

func (*ImageFileContentBlock) UnmarshalJSON added in v1.1.0

func (r *ImageFileContentBlock) UnmarshalJSON(data []byte) error

type ImageFileContentBlockParam added in v1.1.0

type ImageFileContentBlockParam struct {
	ImageFile ImageFileParam `json:"image_file,omitzero,required"`
	// Always `image_file`.
	//
	// This field can be elided, and will marshal its zero value as "image_file".
	Type constant.ImageFile `json:"type,required"`
	// contains filtered or unexported fields
}

References an image File(https://platform.openai.com/docs/api-reference/files) in the content of a message.

The properties ImageFile, Type are required.

func (ImageFileContentBlockParam) MarshalJSON added in v1.1.0

func (r ImageFileContentBlockParam) MarshalJSON() (data []byte, err error)

func (*ImageFileContentBlockParam) UnmarshalJSON added in v1.1.0

func (r *ImageFileContentBlockParam) UnmarshalJSON(data []byte) error

type ImageFileDelta added in v1.1.0

type ImageFileDelta struct {
	// Specifies the detail level of the image if specified by the user. `low` uses
	// fewer tokens, you can opt in to high resolution using `high`.
	//
	// Any of "auto", "low", "high".
	Detail ImageFileDeltaDetail `json:"detail"`
	// The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
	// in the message content. Set `purpose="vision"` when uploading the File if you
	// need to later display the file content.
	FileID string `json:"file_id"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Detail      respjson.Field
		FileID      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ImageFileDelta) RawJSON added in v1.1.0

func (r ImageFileDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*ImageFileDelta) UnmarshalJSON added in v1.1.0

func (r *ImageFileDelta) UnmarshalJSON(data []byte) error

type ImageFileDeltaBlock added in v1.1.0

type ImageFileDeltaBlock struct {
	// The index of the content part in the message.
	Index int64 `json:"index,required"`
	// Always `image_file`.
	Type      constant.ImageFile `json:"type,required"`
	ImageFile ImageFileDelta     `json:"image_file"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		ImageFile   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

References an image File(https://platform.openai.com/docs/api-reference/files) in the content of a message.

func (ImageFileDeltaBlock) RawJSON added in v1.1.0

func (r ImageFileDeltaBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*ImageFileDeltaBlock) UnmarshalJSON added in v1.1.0

func (r *ImageFileDeltaBlock) UnmarshalJSON(data []byte) error

type ImageFileDeltaDetail added in v1.1.0

type ImageFileDeltaDetail string

Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

const (
	ImageFileDeltaDetailAuto ImageFileDeltaDetail = "auto"
	ImageFileDeltaDetailLow  ImageFileDeltaDetail = "low"
	ImageFileDeltaDetailHigh ImageFileDeltaDetail = "high"
)

type ImageFileDetail added in v1.1.0

type ImageFileDetail string

Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

const (
	ImageFileDetailAuto ImageFileDetail = "auto"
	ImageFileDetailLow  ImageFileDetail = "low"
	ImageFileDetailHigh ImageFileDetail = "high"
)

type ImageFileParam added in v1.1.0

type ImageFileParam struct {
	// The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
	// in the message content. Set `purpose="vision"` when uploading the File if you
	// need to later display the file content.
	FileID string `json:"file_id,required"`
	// Specifies the detail level of the image if specified by the user. `low` uses
	// fewer tokens, you can opt in to high resolution using `high`.
	//
	// Any of "auto", "low", "high".
	Detail ImageFileDetail `json:"detail,omitzero"`
	// contains filtered or unexported fields
}

The property FileID is required.

func (ImageFileParam) MarshalJSON added in v1.1.0

func (r ImageFileParam) MarshalJSON() (data []byte, err error)

func (*ImageFileParam) UnmarshalJSON added in v1.1.0

func (r *ImageFileParam) UnmarshalJSON(data []byte) error

type ImageGenerateParams

type ImageGenerateParams struct {
	// A text description of the desired image(s). The maximum length is 32000
	// characters for `gpt-image-1`, 1000 characters for `dall-e-2` and 4000 characters
	// for `dall-e-3`.
	Prompt string `json:"prompt,required"`
	// The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
	// `n=1` is supported.
	N param.Opt[int64] `json:"n,omitzero"`
	// The compression level (0-100%) for the generated images. This parameter is only
	// supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
	// defaults to 100.
	OutputCompression param.Opt[int64] `json:"output_compression,omitzero"`
	// A unique identifier representing your end-user, which can help OpenAI to monitor
	// and detect abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
	User param.Opt[string] `json:"user,omitzero"`
	// Allows to set transparency for the background of the generated image(s). This
	// parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
	// `opaque` or `auto` (default value). When `auto` is used, the model will
	// automatically determine the best background for the image.
	//
	// If `transparent`, the output format needs to support transparency, so it should
	// be set to either `png` (default value) or `webp`.
	//
	// Any of "transparent", "opaque", "auto".
	Background ImageGenerateParamsBackground `json:"background,omitzero"`
	// The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or
	// `gpt-image-1`. Defaults to `dall-e-2` unless a parameter specific to
	// `gpt-image-1` is used.
	Model ImageModel `json:"model,omitzero"`
	// Control the content-moderation level for images generated by `gpt-image-1`. Must
	// be either `low` for less restrictive filtering or `auto` (default value).
	//
	// Any of "low", "auto".
	Moderation ImageGenerateParamsModeration `json:"moderation,omitzero"`
	// The format in which the generated images are returned. This parameter is only
	// supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.
	//
	// Any of "png", "jpeg", "webp".
	OutputFormat ImageGenerateParamsOutputFormat `json:"output_format,omitzero"`
	// The quality of the image that will be generated.
	//
	//   - `auto` (default value) will automatically select the best quality for the
	//     given model.
	//   - `high`, `medium` and `low` are supported for `gpt-image-1`.
	//   - `hd` and `standard` are supported for `dall-e-3`.
	//   - `standard` is the only option for `dall-e-2`.
	//
	// Any of "standard", "hd", "low", "medium", "high", "auto".
	Quality ImageGenerateParamsQuality `json:"quality,omitzero"`
	// The format in which generated images with `dall-e-2` and `dall-e-3` are
	// returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes
	// after the image has been generated. This parameter isn't supported for
	// `gpt-image-1` which will always return base64-encoded images.
	//
	// Any of "url", "b64_json".
	ResponseFormat ImageGenerateParamsResponseFormat `json:"response_format,omitzero"`
	// The size of the generated images. Must be one of `1024x1024`, `1536x1024`
	// (landscape), `1024x1536` (portrait), or `auto` (default value) for
	// `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and
	// one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.
	//
	// Any of "auto", "1024x1024", "1536x1024", "1024x1536", "256x256", "512x512",
	// "1792x1024", "1024x1792".
	Size ImageGenerateParamsSize `json:"size,omitzero"`
	// The style of the generated images. This parameter is only supported for
	// `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean
	// towards generating hyper-real and dramatic images. Natural causes the model to
	// produce more natural, less hyper-real looking images.
	//
	// Any of "vivid", "natural".
	Style ImageGenerateParamsStyle `json:"style,omitzero"`
	// contains filtered or unexported fields
}

func (ImageGenerateParams) MarshalJSON

func (r ImageGenerateParams) MarshalJSON() (data []byte, err error)

func (*ImageGenerateParams) UnmarshalJSON

func (r *ImageGenerateParams) UnmarshalJSON(data []byte) error

type ImageGenerateParamsBackground

type ImageGenerateParamsBackground string

Allows to set transparency for the background of the generated image(s). This parameter is only supported for `gpt-image-1`. Must be one of `transparent`, `opaque` or `auto` (default value). When `auto` is used, the model will automatically determine the best background for the image.

If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`.

const (
	ImageGenerateParamsBackgroundTransparent ImageGenerateParamsBackground = "transparent"
	ImageGenerateParamsBackgroundOpaque      ImageGenerateParamsBackground = "opaque"
	ImageGenerateParamsBackgroundAuto        ImageGenerateParamsBackground = "auto"
)

type ImageGenerateParamsModeration

type ImageGenerateParamsModeration string

Control the content-moderation level for images generated by `gpt-image-1`. Must be either `low` for less restrictive filtering or `auto` (default value).

const (
	ImageGenerateParamsModerationLow  ImageGenerateParamsModeration = "low"
	ImageGenerateParamsModerationAuto ImageGenerateParamsModeration = "auto"
)

type ImageGenerateParamsOutputFormat

type ImageGenerateParamsOutputFormat string

The format in which the generated images are returned. This parameter is only supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.

const (
	ImageGenerateParamsOutputFormatPNG  ImageGenerateParamsOutputFormat = "png"
	ImageGenerateParamsOutputFormatJPEG ImageGenerateParamsOutputFormat = "jpeg"
	ImageGenerateParamsOutputFormatWebP ImageGenerateParamsOutputFormat = "webp"
)

type ImageGenerateParamsQuality

type ImageGenerateParamsQuality string

The quality of the image that will be generated.

  • `auto` (default value) will automatically select the best quality for the given model.
  • `high`, `medium` and `low` are supported for `gpt-image-1`.
  • `hd` and `standard` are supported for `dall-e-3`.
  • `standard` is the only option for `dall-e-2`.
const (
	ImageGenerateParamsQualityStandard ImageGenerateParamsQuality = "standard"
	ImageGenerateParamsQualityHD       ImageGenerateParamsQuality = "hd"
	ImageGenerateParamsQualityLow      ImageGenerateParamsQuality = "low"
	ImageGenerateParamsQualityMedium   ImageGenerateParamsQuality = "medium"
	ImageGenerateParamsQualityHigh     ImageGenerateParamsQuality = "high"
	ImageGenerateParamsQualityAuto     ImageGenerateParamsQuality = "auto"
)

type ImageGenerateParamsResponseFormat

type ImageGenerateParamsResponseFormat string

The format in which generated images with `dall-e-2` and `dall-e-3` are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter isn't supported for `gpt-image-1` which will always return base64-encoded images.

const (
	ImageGenerateParamsResponseFormatURL     ImageGenerateParamsResponseFormat = "url"
	ImageGenerateParamsResponseFormatB64JSON ImageGenerateParamsResponseFormat = "b64_json"
)

type ImageGenerateParamsSize

type ImageGenerateParamsSize string

The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or `auto` (default value) for `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.

const (
	ImageGenerateParamsSizeAuto      ImageGenerateParamsSize = "auto"
	ImageGenerateParamsSize1024x1024 ImageGenerateParamsSize = "1024x1024"
	ImageGenerateParamsSize1536x1024 ImageGenerateParamsSize = "1536x1024"
	ImageGenerateParamsSize1024x1536 ImageGenerateParamsSize = "1024x1536"
	ImageGenerateParamsSize256x256   ImageGenerateParamsSize = "256x256"
	ImageGenerateParamsSize512x512   ImageGenerateParamsSize = "512x512"
	ImageGenerateParamsSize1792x1024 ImageGenerateParamsSize = "1792x1024"
	ImageGenerateParamsSize1024x1792 ImageGenerateParamsSize = "1024x1792"
)

type ImageGenerateParamsStyle

type ImageGenerateParamsStyle string

The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images.

const (
	ImageGenerateParamsStyleVivid   ImageGenerateParamsStyle = "vivid"
	ImageGenerateParamsStyleNatural ImageGenerateParamsStyle = "natural"
)

type ImageModel

type ImageModel = string
const (
	ImageModelDallE2    ImageModel = "dall-e-2"
	ImageModelDallE3    ImageModel = "dall-e-3"
	ImageModelGPTImage1 ImageModel = "gpt-image-1"
)

type ImageNewVariationParams

type ImageNewVariationParams struct {
	// The image to use as the basis for the variation(s). Must be a valid PNG file,
	// less than 4MB, and square.
	Image io.Reader `json:"image,omitzero,required" format:"binary"`
	// The number of images to generate. Must be between 1 and 10.
	N param.Opt[int64] `json:"n,omitzero"`
	// A unique identifier representing your end-user, which can help OpenAI to monitor
	// and detect abuse.
	// [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
	User param.Opt[string] `json:"user,omitzero"`
	// The model to use for image generation. Only `dall-e-2` is supported at this
	// time.
	Model ImageModel `json:"model,omitzero"`
	// The format in which the generated images are returned. Must be one of `url` or
	// `b64_json`. URLs are only valid for 60 minutes after the image has been
	// generated.
	//
	// Any of "url", "b64_json".
	ResponseFormat ImageNewVariationParamsResponseFormat `json:"response_format,omitzero"`
	// The size of the generated images. Must be one of `256x256`, `512x512`, or
	// `1024x1024`.
	//
	// Any of "256x256", "512x512", "1024x1024".
	Size ImageNewVariationParamsSize `json:"size,omitzero"`
	// contains filtered or unexported fields
}

func (ImageNewVariationParams) MarshalMultipart

func (r ImageNewVariationParams) MarshalMultipart() (data []byte, contentType string, err error)

type ImageNewVariationParamsResponseFormat

type ImageNewVariationParamsResponseFormat string

The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.

const (
	ImageNewVariationParamsResponseFormatURL     ImageNewVariationParamsResponseFormat = "url"
	ImageNewVariationParamsResponseFormatB64JSON ImageNewVariationParamsResponseFormat = "b64_json"
)

type ImageNewVariationParamsSize

type ImageNewVariationParamsSize string

The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.

const (
	ImageNewVariationParamsSize256x256   ImageNewVariationParamsSize = "256x256"
	ImageNewVariationParamsSize512x512   ImageNewVariationParamsSize = "512x512"
	ImageNewVariationParamsSize1024x1024 ImageNewVariationParamsSize = "1024x1024"
)

type ImageService

type ImageService struct {
	Options []option.RequestOption
}

ImageService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewImageService method instead.

func NewImageService

func NewImageService(opts ...option.RequestOption) (r ImageService)

NewImageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ImageService) Edit

func (r *ImageService) Edit(ctx context.Context, body ImageEditParams, opts ...option.RequestOption) (res *ImagesResponse, err error)

Creates an edited or extended image given one or more source images and a prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.

func (*ImageService) Generate

func (r *ImageService) Generate(ctx context.Context, body ImageGenerateParams, opts ...option.RequestOption) (res *ImagesResponse, err error)

Creates an image given a prompt. [Learn more](https://platform.openai.com/docs/guides/images).

func (*ImageService) NewVariation

func (r *ImageService) NewVariation(ctx context.Context, body ImageNewVariationParams, opts ...option.RequestOption) (res *ImagesResponse, err error)

Creates a variation of a given image. This endpoint only supports `dall-e-2`.

type ImageURL added in v1.1.0

type ImageURL struct {
	// The external URL of the image, must be a supported image types: jpeg, jpg, png,
	// gif, webp.
	URL string `json:"url,required" format:"uri"`
	// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
	// to high resolution using `high`. Default value is `auto`
	//
	// Any of "auto", "low", "high".
	Detail ImageURLDetail `json:"detail"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		URL         respjson.Field
		Detail      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ImageURL) RawJSON added in v1.1.0

func (r ImageURL) RawJSON() string

Returns the unmodified JSON received from the API

func (ImageURL) ToParam added in v1.1.0

func (r ImageURL) ToParam() ImageURLParam

ToParam converts this ImageURL to a ImageURLParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ImageURLParam.Overrides()

func (*ImageURL) UnmarshalJSON added in v1.1.0

func (r *ImageURL) UnmarshalJSON(data []byte) error

type ImageURLContentBlock added in v1.1.0

type ImageURLContentBlock struct {
	ImageURL ImageURL `json:"image_url,required"`
	// The type of the content part.
	Type constant.ImageURL `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ImageURL    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

References an image URL in the content of a message.

func (ImageURLContentBlock) RawJSON added in v1.1.0

func (r ImageURLContentBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ImageURLContentBlock) ToParam added in v1.1.0

ToParam converts this ImageURLContentBlock to a ImageURLContentBlockParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ImageURLContentBlockParam.Overrides()

func (*ImageURLContentBlock) UnmarshalJSON added in v1.1.0

func (r *ImageURLContentBlock) UnmarshalJSON(data []byte) error

type ImageURLContentBlockParam added in v1.1.0

type ImageURLContentBlockParam struct {
	ImageURL ImageURLParam `json:"image_url,omitzero,required"`
	// The type of the content part.
	//
	// This field can be elided, and will marshal its zero value as "image_url".
	Type constant.ImageURL `json:"type,required"`
	// contains filtered or unexported fields
}

References an image URL in the content of a message.

The properties ImageURL, Type are required.

func (ImageURLContentBlockParam) MarshalJSON added in v1.1.0

func (r ImageURLContentBlockParam) MarshalJSON() (data []byte, err error)

func (*ImageURLContentBlockParam) UnmarshalJSON added in v1.1.0

func (r *ImageURLContentBlockParam) UnmarshalJSON(data []byte) error

type ImageURLDelta added in v1.1.0

type ImageURLDelta struct {
	// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
	// to high resolution using `high`.
	//
	// Any of "auto", "low", "high".
	Detail ImageURLDeltaDetail `json:"detail"`
	// The URL of the image, must be a supported image types: jpeg, jpg, png, gif,
	// webp.
	URL string `json:"url"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Detail      respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ImageURLDelta) RawJSON added in v1.1.0

func (r ImageURLDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*ImageURLDelta) UnmarshalJSON added in v1.1.0

func (r *ImageURLDelta) UnmarshalJSON(data []byte) error

type ImageURLDeltaBlock added in v1.1.0

type ImageURLDeltaBlock struct {
	// The index of the content part in the message.
	Index int64 `json:"index,required"`
	// Always `image_url`.
	Type     constant.ImageURL `json:"type,required"`
	ImageURL ImageURLDelta     `json:"image_url"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		ImageURL    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

References an image URL in the content of a message.

func (ImageURLDeltaBlock) RawJSON added in v1.1.0

func (r ImageURLDeltaBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*ImageURLDeltaBlock) UnmarshalJSON added in v1.1.0

func (r *ImageURLDeltaBlock) UnmarshalJSON(data []byte) error

type ImageURLDeltaDetail added in v1.1.0

type ImageURLDeltaDetail string

Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`.

const (
	ImageURLDeltaDetailAuto ImageURLDeltaDetail = "auto"
	ImageURLDeltaDetailLow  ImageURLDeltaDetail = "low"
	ImageURLDeltaDetailHigh ImageURLDeltaDetail = "high"
)

type ImageURLDetail added in v1.1.0

type ImageURLDetail string

Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

const (
	ImageURLDetailAuto ImageURLDetail = "auto"
	ImageURLDetailLow  ImageURLDetail = "low"
	ImageURLDetailHigh ImageURLDetail = "high"
)

type ImageURLParam added in v1.1.0

type ImageURLParam struct {
	// The external URL of the image, must be a supported image types: jpeg, jpg, png,
	// gif, webp.
	URL string `json:"url,required" format:"uri"`
	// Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
	// to high resolution using `high`. Default value is `auto`
	//
	// Any of "auto", "low", "high".
	Detail ImageURLDetail `json:"detail,omitzero"`
	// contains filtered or unexported fields
}

The property URL is required.

func (ImageURLParam) MarshalJSON added in v1.1.0

func (r ImageURLParam) MarshalJSON() (data []byte, err error)

func (*ImageURLParam) UnmarshalJSON added in v1.1.0

func (r *ImageURLParam) UnmarshalJSON(data []byte) error

type ImagesResponse

type ImagesResponse struct {
	// The Unix timestamp (in seconds) of when the image was created.
	Created int64 `json:"created,required"`
	// The list of generated images.
	Data []Image `json:"data"`
	// For `gpt-image-1` only, the token usage information for the image generation.
	Usage ImagesResponseUsage `json:"usage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Created     respjson.Field
		Data        respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The response from the image generation endpoint.

func (ImagesResponse) RawJSON

func (r ImagesResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ImagesResponse) UnmarshalJSON

func (r *ImagesResponse) UnmarshalJSON(data []byte) error

type ImagesResponseUsage

type ImagesResponseUsage struct {
	// The number of tokens (images and text) in the input prompt.
	InputTokens int64 `json:"input_tokens,required"`
	// The input tokens detailed information for the image generation.
	InputTokensDetails ImagesResponseUsageInputTokensDetails `json:"input_tokens_details,required"`
	// The number of image tokens in the output image.
	OutputTokens int64 `json:"output_tokens,required"`
	// The total number of tokens (images and text) used for the image generation.
	TotalTokens int64 `json:"total_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputTokens        respjson.Field
		InputTokensDetails respjson.Field
		OutputTokens       respjson.Field
		TotalTokens        respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

For `gpt-image-1` only, the token usage information for the image generation.

func (ImagesResponseUsage) RawJSON

func (r ImagesResponseUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*ImagesResponseUsage) UnmarshalJSON

func (r *ImagesResponseUsage) UnmarshalJSON(data []byte) error

type ImagesResponseUsageInputTokensDetails

type ImagesResponseUsageInputTokensDetails struct {
	// The number of image tokens in the input prompt.
	ImageTokens int64 `json:"image_tokens,required"`
	// The number of text tokens in the input prompt.
	TextTokens int64 `json:"text_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ImageTokens respjson.Field
		TextTokens  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The input tokens detailed information for the image generation.

func (ImagesResponseUsageInputTokensDetails) RawJSON

Returns the unmodified JSON received from the API

func (*ImagesResponseUsageInputTokensDetails) UnmarshalJSON

func (r *ImagesResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error

type LabelModelGrader

type LabelModelGrader struct {
	Input []LabelModelGraderInput `json:"input,required"`
	// The labels to assign to each item in the evaluation.
	Labels []string `json:"labels,required"`
	// The model to use for the evaluation. Must support structured outputs.
	Model string `json:"model,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The labels that indicate a passing result. Must be a subset of labels.
	PassingLabels []string `json:"passing_labels,required"`
	// The object type, which is always `label_model`.
	Type constant.LabelModel `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Input         respjson.Field
		Labels        respjson.Field
		Model         respjson.Field
		Name          respjson.Field
		PassingLabels respjson.Field
		Type          respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A LabelModelGrader object which uses a model to assign labels to each item in the evaluation.

func (LabelModelGrader) RawJSON

func (r LabelModelGrader) RawJSON() string

Returns the unmodified JSON received from the API

func (LabelModelGrader) ToParam

ToParam converts this LabelModelGrader to a LabelModelGraderParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with LabelModelGraderParam.Overrides()

func (*LabelModelGrader) UnmarshalJSON

func (r *LabelModelGrader) UnmarshalJSON(data []byte) error

type LabelModelGraderInput

type LabelModelGraderInput struct {
	// Text inputs to the model - can contain template strings.
	Content LabelModelGraderInputContentUnion `json:"content,required"`
	// The role of the message input. One of `user`, `assistant`, `system`, or
	// `developer`.
	//
	// Any of "user", "assistant", "system", "developer".
	Role string `json:"role,required"`
	// The type of the message input. Always `message`.
	//
	// Any of "message".
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Role        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A message input to the model with a role indicating instruction following hierarchy. Instructions given with the `developer` or `system` role take precedence over instructions given with the `user` role. Messages with the `assistant` role are presumed to have been generated by the model in previous interactions.

func (LabelModelGraderInput) RawJSON

func (r LabelModelGraderInput) RawJSON() string

Returns the unmodified JSON received from the API

func (*LabelModelGraderInput) UnmarshalJSON

func (r *LabelModelGraderInput) UnmarshalJSON(data []byte) error

type LabelModelGraderInputContentOutputText

type LabelModelGraderInputContentOutputText 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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A text output from the model.

func (LabelModelGraderInputContentOutputText) RawJSON

Returns the unmodified JSON received from the API

func (*LabelModelGraderInputContentOutputText) UnmarshalJSON

func (r *LabelModelGraderInputContentOutputText) UnmarshalJSON(data []byte) error

type LabelModelGraderInputContentOutputTextParam

type LabelModelGraderInputContentOutputTextParam struct {
	// The text output from the model.
	Text string `json:"text,required"`
	// The type of the output text. Always `output_text`.
	//
	// This field can be elided, and will marshal its zero value as "output_text".
	Type constant.OutputText `json:"type,required"`
	// contains filtered or unexported fields
}

A text output from the model.

The properties Text, Type are required.

func (LabelModelGraderInputContentOutputTextParam) MarshalJSON

func (r LabelModelGraderInputContentOutputTextParam) MarshalJSON() (data []byte, err error)

func (*LabelModelGraderInputContentOutputTextParam) UnmarshalJSON

func (r *LabelModelGraderInputContentOutputTextParam) UnmarshalJSON(data []byte) error

type LabelModelGraderInputContentUnion

type LabelModelGraderInputContentUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	Text     string `json:"text"`
	Type     string `json:"type"`
	JSON     struct {
		OfString respjson.Field
		Text     respjson.Field
		Type     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

LabelModelGraderInputContentUnion contains all possible properties and values from [string], responses.ResponseInputText, LabelModelGraderInputContentOutputText.

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfString]

func (LabelModelGraderInputContentUnion) AsInputText

func (LabelModelGraderInputContentUnion) AsOutputText

func (LabelModelGraderInputContentUnion) AsString

func (u LabelModelGraderInputContentUnion) AsString() (v string)

func (LabelModelGraderInputContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*LabelModelGraderInputContentUnion) UnmarshalJSON

func (r *LabelModelGraderInputContentUnion) UnmarshalJSON(data []byte) error

type LabelModelGraderInputContentUnionParam

type LabelModelGraderInputContentUnionParam struct {
	OfString     param.Opt[string]                            `json:",omitzero,inline"`
	OfInputText  *responses.ResponseInputTextParam            `json:",omitzero,inline"`
	OfOutputText *LabelModelGraderInputContentOutputTextParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (LabelModelGraderInputContentUnionParam) GetText

Returns a pointer to the underlying variant's property, if present.

func (LabelModelGraderInputContentUnionParam) GetType

Returns a pointer to the underlying variant's property, if present.

func (LabelModelGraderInputContentUnionParam) MarshalJSON

func (u LabelModelGraderInputContentUnionParam) MarshalJSON() ([]byte, error)

func (*LabelModelGraderInputContentUnionParam) UnmarshalJSON

func (u *LabelModelGraderInputContentUnionParam) UnmarshalJSON(data []byte) error

type LabelModelGraderInputParam

type LabelModelGraderInputParam struct {
	// Text inputs to the model - can contain template strings.
	Content LabelModelGraderInputContentUnionParam `json:"content,omitzero,required"`
	// The role of the message input. One of `user`, `assistant`, `system`, or
	// `developer`.
	//
	// Any of "user", "assistant", "system", "developer".
	Role string `json:"role,omitzero,required"`
	// The type of the message input. Always `message`.
	//
	// Any of "message".
	Type string `json:"type,omitzero"`
	// contains filtered or unexported fields
}

A message input to the model with a role indicating instruction following hierarchy. Instructions given with the `developer` or `system` role take precedence over instructions given with the `user` role. Messages with the `assistant` role are presumed to have been generated by the model in previous interactions.

The properties Content, Role are required.

func (LabelModelGraderInputParam) MarshalJSON

func (r LabelModelGraderInputParam) MarshalJSON() (data []byte, err error)

func (*LabelModelGraderInputParam) UnmarshalJSON

func (r *LabelModelGraderInputParam) UnmarshalJSON(data []byte) error

type LabelModelGraderParam

type LabelModelGraderParam struct {
	Input []LabelModelGraderInputParam `json:"input,omitzero,required"`
	// The labels to assign to each item in the evaluation.
	Labels []string `json:"labels,omitzero,required"`
	// The model to use for the evaluation. Must support structured outputs.
	Model string `json:"model,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The labels that indicate a passing result. Must be a subset of labels.
	PassingLabels []string `json:"passing_labels,omitzero,required"`
	// The object type, which is always `label_model`.
	//
	// This field can be elided, and will marshal its zero value as "label_model".
	Type constant.LabelModel `json:"type,required"`
	// contains filtered or unexported fields
}

A LabelModelGrader object which uses a model to assign labels to each item in the evaluation.

The properties Input, Labels, Model, Name, PassingLabels, Type are required.

func (LabelModelGraderParam) MarshalJSON

func (r LabelModelGraderParam) MarshalJSON() (data []byte, err error)

func (*LabelModelGraderParam) UnmarshalJSON

func (r *LabelModelGraderParam) UnmarshalJSON(data []byte) error

type Message added in v1.1.0

type Message struct {
	// The identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// If applicable, the ID of the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants) that
	// authored this message.
	AssistantID string `json:"assistant_id,required"`
	// A list of files attached to the message, and the tools they were added to.
	Attachments []MessageAttachment `json:"attachments,required"`
	// The Unix timestamp (in seconds) for when the message was completed.
	CompletedAt int64 `json:"completed_at,required"`
	// The content of the message in array of text and/or images.
	Content []MessageContentUnion `json:"content,required"`
	// The Unix timestamp (in seconds) for when the message was created.
	CreatedAt int64 `json:"created_at,required"`
	// The Unix timestamp (in seconds) for when the message was marked as incomplete.
	IncompleteAt int64 `json:"incomplete_at,required"`
	// On an incomplete message, details about why the message is incomplete.
	IncompleteDetails MessageIncompleteDetails `json:"incomplete_details,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,required"`
	// The object type, which is always `thread.message`.
	Object constant.ThreadMessage `json:"object,required"`
	// The entity that produced the message. One of `user` or `assistant`.
	//
	// Any of "user", "assistant".
	Role MessageRole `json:"role,required"`
	// The ID of the [run](https://platform.openai.com/docs/api-reference/runs)
	// associated with the creation of this message. Value is `null` when messages are
	// created manually using the create message or create thread endpoints.
	RunID string `json:"run_id,required"`
	// The status of the message, which can be either `in_progress`, `incomplete`, or
	// `completed`.
	//
	// Any of "in_progress", "incomplete", "completed".
	Status MessageStatus `json:"status,required"`
	// The [thread](https://platform.openai.com/docs/api-reference/threads) ID that
	// this message belongs to.
	ThreadID string `json:"thread_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		AssistantID       respjson.Field
		Attachments       respjson.Field
		CompletedAt       respjson.Field
		Content           respjson.Field
		CreatedAt         respjson.Field
		IncompleteAt      respjson.Field
		IncompleteDetails respjson.Field
		Metadata          respjson.Field
		Object            respjson.Field
		Role              respjson.Field
		RunID             respjson.Field
		Status            respjson.Field
		ThreadID          respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads).

func (Message) RawJSON added in v1.1.0

func (r Message) RawJSON() string

Returns the unmodified JSON received from the API

func (*Message) UnmarshalJSON added in v1.1.0

func (r *Message) UnmarshalJSON(data []byte) error

type MessageAttachment added in v1.1.0

type MessageAttachment struct {
	// The ID of the file to attach to the message.
	FileID string `json:"file_id"`
	// The tools to add this file to.
	Tools []MessageAttachmentToolUnion `json:"tools"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Tools       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageAttachment) RawJSON added in v1.1.0

func (r MessageAttachment) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageAttachment) UnmarshalJSON added in v1.1.0

func (r *MessageAttachment) UnmarshalJSON(data []byte) error

type MessageAttachmentToolFileSearchTool added in v1.1.0

type MessageAttachmentToolFileSearchTool struct {
	// The type of tool being defined: `file_search`
	Type constant.FileSearch `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageAttachmentToolFileSearchTool) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*MessageAttachmentToolFileSearchTool) UnmarshalJSON added in v1.1.0

func (r *MessageAttachmentToolFileSearchTool) UnmarshalJSON(data []byte) error

type MessageAttachmentToolUnion added in v1.1.0

type MessageAttachmentToolUnion struct {
	Type string `json:"type"`
	JSON struct {
		Type respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MessageAttachmentToolUnion contains all possible properties and values from CodeInterpreterTool, MessageAttachmentToolFileSearchTool.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (MessageAttachmentToolUnion) AsCodeInterpreterTool added in v1.1.0

func (u MessageAttachmentToolUnion) AsCodeInterpreterTool() (v CodeInterpreterTool)

func (MessageAttachmentToolUnion) AsFileSearchTool added in v1.1.0

func (MessageAttachmentToolUnion) RawJSON added in v1.1.0

func (u MessageAttachmentToolUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageAttachmentToolUnion) UnmarshalJSON added in v1.1.0

func (r *MessageAttachmentToolUnion) UnmarshalJSON(data []byte) error

type MessageContentDeltaUnion added in v1.1.0

type MessageContentDeltaUnion struct {
	Index int64 `json:"index"`
	// Any of "image_file", "text", "refusal", "image_url".
	Type string `json:"type"`
	// This field is from variant [ImageFileDeltaBlock].
	ImageFile ImageFileDelta `json:"image_file"`
	// This field is from variant [TextDeltaBlock].
	Text TextDelta `json:"text"`
	// This field is from variant [RefusalDeltaBlock].
	Refusal string `json:"refusal"`
	// This field is from variant [ImageURLDeltaBlock].
	ImageURL ImageURLDelta `json:"image_url"`
	JSON     struct {
		Index     respjson.Field
		Type      respjson.Field
		ImageFile respjson.Field
		Text      respjson.Field
		Refusal   respjson.Field
		ImageURL  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MessageContentDeltaUnion contains all possible properties and values from ImageFileDeltaBlock, TextDeltaBlock, RefusalDeltaBlock, ImageURLDeltaBlock.

Use the MessageContentDeltaUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (MessageContentDeltaUnion) AsAny added in v1.1.0

func (u MessageContentDeltaUnion) AsAny() anyMessageContentDelta

Use the following switch statement to find the correct variant

switch variant := MessageContentDeltaUnion.AsAny().(type) {
case openai.ImageFileDeltaBlock:
case openai.TextDeltaBlock:
case openai.RefusalDeltaBlock:
case openai.ImageURLDeltaBlock:
default:
  fmt.Errorf("no variant present")
}

func (MessageContentDeltaUnion) AsImageFile added in v1.1.0

func (u MessageContentDeltaUnion) AsImageFile() (v ImageFileDeltaBlock)

func (MessageContentDeltaUnion) AsImageURL added in v1.1.0

func (u MessageContentDeltaUnion) AsImageURL() (v ImageURLDeltaBlock)

func (MessageContentDeltaUnion) AsRefusal added in v1.1.0

func (u MessageContentDeltaUnion) AsRefusal() (v RefusalDeltaBlock)

func (MessageContentDeltaUnion) AsText added in v1.1.0

func (MessageContentDeltaUnion) RawJSON added in v1.1.0

func (u MessageContentDeltaUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageContentDeltaUnion) UnmarshalJSON added in v1.1.0

func (r *MessageContentDeltaUnion) UnmarshalJSON(data []byte) error

type MessageContentPartParamUnion added in v1.1.0

type MessageContentPartParamUnion struct {
	OfImageFile *ImageFileContentBlockParam `json:",omitzero,inline"`
	OfImageURL  *ImageURLContentBlockParam  `json:",omitzero,inline"`
	OfText      *TextContentBlockParam      `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func MessageContentPartParamOfImageFile added in v1.1.0

func MessageContentPartParamOfImageFile(imageFile ImageFileParam) MessageContentPartParamUnion

func MessageContentPartParamOfImageURL added in v1.1.0

func MessageContentPartParamOfImageURL(imageURL ImageURLParam) MessageContentPartParamUnion

func MessageContentPartParamOfText added in v1.1.0

func MessageContentPartParamOfText(text string) MessageContentPartParamUnion

func (MessageContentPartParamUnion) GetImageFile added in v1.1.0

func (u MessageContentPartParamUnion) GetImageFile() *ImageFileParam

Returns a pointer to the underlying variant's property, if present.

func (MessageContentPartParamUnion) GetImageURL added in v1.1.0

Returns a pointer to the underlying variant's property, if present.

func (MessageContentPartParamUnion) GetText added in v1.1.0

func (u MessageContentPartParamUnion) GetText() *string

Returns a pointer to the underlying variant's property, if present.

func (MessageContentPartParamUnion) GetType added in v1.1.0

func (u MessageContentPartParamUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (MessageContentPartParamUnion) MarshalJSON added in v1.1.0

func (u MessageContentPartParamUnion) MarshalJSON() ([]byte, error)

func (*MessageContentPartParamUnion) UnmarshalJSON added in v1.1.0

func (u *MessageContentPartParamUnion) UnmarshalJSON(data []byte) error

type MessageContentUnion added in v1.1.0

type MessageContentUnion struct {
	// This field is from variant [ImageFileContentBlock].
	ImageFile ImageFile `json:"image_file"`
	// Any of "image_file", "image_url", "text", "refusal".
	Type string `json:"type"`
	// This field is from variant [ImageURLContentBlock].
	ImageURL ImageURL `json:"image_url"`
	// This field is from variant [TextContentBlock].
	Text Text `json:"text"`
	// This field is from variant [RefusalContentBlock].
	Refusal string `json:"refusal"`
	JSON    struct {
		ImageFile respjson.Field
		Type      respjson.Field
		ImageURL  respjson.Field
		Text      respjson.Field
		Refusal   respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MessageContentUnion contains all possible properties and values from ImageFileContentBlock, ImageURLContentBlock, TextContentBlock, RefusalContentBlock.

Use the MessageContentUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (MessageContentUnion) AsAny added in v1.1.0

func (u MessageContentUnion) AsAny() anyMessageContent

Use the following switch statement to find the correct variant

switch variant := MessageContentUnion.AsAny().(type) {
case openai.ImageFileContentBlock:
case openai.ImageURLContentBlock:
case openai.TextContentBlock:
case openai.RefusalContentBlock:
default:
  fmt.Errorf("no variant present")
}

func (MessageContentUnion) AsImageFile added in v1.1.0

func (u MessageContentUnion) AsImageFile() (v ImageFileContentBlock)

func (MessageContentUnion) AsImageURL added in v1.1.0

func (u MessageContentUnion) AsImageURL() (v ImageURLContentBlock)

func (MessageContentUnion) AsRefusal added in v1.1.0

func (u MessageContentUnion) AsRefusal() (v RefusalContentBlock)

func (MessageContentUnion) AsText added in v1.1.0

func (u MessageContentUnion) AsText() (v TextContentBlock)

func (MessageContentUnion) RawJSON added in v1.1.0

func (u MessageContentUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageContentUnion) UnmarshalJSON added in v1.1.0

func (r *MessageContentUnion) UnmarshalJSON(data []byte) error

type MessageCreationStepDetails added in v1.1.0

type MessageCreationStepDetails struct {
	MessageCreation MessageCreationStepDetailsMessageCreation `json:"message_creation,required"`
	// Always `message_creation`.
	Type constant.MessageCreation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		MessageCreation respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details of the message creation by the run step.

func (MessageCreationStepDetails) RawJSON added in v1.1.0

func (r MessageCreationStepDetails) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageCreationStepDetails) UnmarshalJSON added in v1.1.0

func (r *MessageCreationStepDetails) UnmarshalJSON(data []byte) error

type MessageCreationStepDetailsMessageCreation added in v1.1.0

type MessageCreationStepDetailsMessageCreation struct {
	// The ID of the message that was created by this run step.
	MessageID string `json:"message_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		MessageID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageCreationStepDetailsMessageCreation) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*MessageCreationStepDetailsMessageCreation) UnmarshalJSON added in v1.1.0

func (r *MessageCreationStepDetailsMessageCreation) UnmarshalJSON(data []byte) error

type MessageDeleted added in v1.1.0

type MessageDeleted struct {
	ID      string                        `json:"id,required"`
	Deleted bool                          `json:"deleted,required"`
	Object  constant.ThreadMessageDeleted `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageDeleted) RawJSON added in v1.1.0

func (r MessageDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageDeleted) UnmarshalJSON added in v1.1.0

func (r *MessageDeleted) UnmarshalJSON(data []byte) error

type MessageDelta added in v1.1.0

type MessageDelta struct {
	// The content of the message in array of text and/or images.
	Content []MessageContentDeltaUnion `json:"content"`
	// The entity that produced the message. One of `user` or `assistant`.
	//
	// Any of "user", "assistant".
	Role MessageDeltaRole `json:"role"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Role        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The delta containing the fields that have changed on the Message.

func (MessageDelta) RawJSON added in v1.1.0

func (r MessageDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageDelta) UnmarshalJSON added in v1.1.0

func (r *MessageDelta) UnmarshalJSON(data []byte) error

type MessageDeltaEvent added in v1.1.0

type MessageDeltaEvent struct {
	// The identifier of the message, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The delta containing the fields that have changed on the Message.
	Delta MessageDelta `json:"delta,required"`
	// The object type, which is always `thread.message.delta`.
	Object constant.ThreadMessageDelta `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Delta       respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a message delta i.e. any changed fields on a message during streaming.

func (MessageDeltaEvent) RawJSON added in v1.1.0

func (r MessageDeltaEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageDeltaEvent) UnmarshalJSON added in v1.1.0

func (r *MessageDeltaEvent) UnmarshalJSON(data []byte) error

type MessageDeltaRole added in v1.1.0

type MessageDeltaRole string

The entity that produced the message. One of `user` or `assistant`.

const (
	MessageDeltaRoleUser      MessageDeltaRole = "user"
	MessageDeltaRoleAssistant MessageDeltaRole = "assistant"
)

type MessageIncompleteDetails added in v1.1.0

type MessageIncompleteDetails struct {
	// The reason the message is incomplete.
	//
	// Any of "content_filter", "max_tokens", "run_cancelled", "run_expired",
	// "run_failed".
	Reason string `json:"reason,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Reason      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

On an incomplete message, details about why the message is incomplete.

func (MessageIncompleteDetails) RawJSON added in v1.1.0

func (r MessageIncompleteDetails) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageIncompleteDetails) UnmarshalJSON added in v1.1.0

func (r *MessageIncompleteDetails) UnmarshalJSON(data []byte) error

type MessageRole added in v1.1.0

type MessageRole string

The entity that produced the message. One of `user` or `assistant`.

const (
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
)

type MessageStatus added in v1.1.0

type MessageStatus string

The status of the message, which can be either `in_progress`, `incomplete`, or `completed`.

const (
	MessageStatusInProgress MessageStatus = "in_progress"
	MessageStatusIncomplete MessageStatus = "incomplete"
	MessageStatusCompleted  MessageStatus = "completed"
)

type Metadata

type Metadata = shared.Metadata

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.

Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

This is an alias to an internal type.

type Model

type Model struct {
	// The model identifier, which can be referenced in the API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) when the model was created.
	Created int64 `json:"created,required"`
	// The object type, which is always "model".
	Object constant.Model `json:"object,required"`
	// The organization that owns the model.
	OwnedBy string `json:"owned_by,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Created     respjson.Field
		Object      respjson.Field
		OwnedBy     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Describes an OpenAI model offering that can be used with the API.

func (Model) RawJSON

func (r Model) RawJSON() string

Returns the unmodified JSON received from the API

func (*Model) UnmarshalJSON

func (r *Model) UnmarshalJSON(data []byte) error

type ModelDeleted

type ModelDeleted struct {
	ID      string `json:"id,required"`
	Deleted bool   `json:"deleted,required"`
	Object  string `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ModelDeleted) RawJSON

func (r ModelDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*ModelDeleted) UnmarshalJSON

func (r *ModelDeleted) UnmarshalJSON(data []byte) error

type ModelService

type ModelService struct {
	Options []option.RequestOption
}

ModelService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewModelService method instead.

func NewModelService

func NewModelService(opts ...option.RequestOption) (r ModelService)

NewModelService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ModelService) Delete

func (r *ModelService) Delete(ctx context.Context, model string, opts ...option.RequestOption) (res *ModelDeleted, err error)

Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.

func (*ModelService) Get

func (r *ModelService) Get(ctx context.Context, model string, opts ...option.RequestOption) (res *Model, err error)

Retrieves a model instance, providing basic information about the model such as the owner and permissioning.

func (*ModelService) List

func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.Page[Model], err error)

Lists the currently available models, and provides basic information about each one such as the owner and availability.

func (*ModelService) ListAutoPaging

func (r *ModelService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.PageAutoPager[Model]

Lists the currently available models, and provides basic information about each one such as the owner and availability.

type Moderation

type Moderation struct {
	// A list of the categories, and whether they are flagged or not.
	Categories ModerationCategories `json:"categories,required"`
	// A list of the categories along with the input type(s) that the score applies to.
	CategoryAppliedInputTypes ModerationCategoryAppliedInputTypes `json:"category_applied_input_types,required"`
	// A list of the categories along with their scores as predicted by model.
	CategoryScores ModerationCategoryScores `json:"category_scores,required"`
	// Whether any of the below categories are flagged.
	Flagged bool `json:"flagged,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Categories                respjson.Field
		CategoryAppliedInputTypes respjson.Field
		CategoryScores            respjson.Field
		Flagged                   respjson.Field
		ExtraFields               map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Moderation) RawJSON

func (r Moderation) RawJSON() string

Returns the unmodified JSON received from the API

func (*Moderation) UnmarshalJSON

func (r *Moderation) UnmarshalJSON(data []byte) error

type ModerationCategories

type ModerationCategories struct {
	// Content that expresses, incites, or promotes harassing language towards any
	// target.
	Harassment bool `json:"harassment,required"`
	// Harassment content that also includes violence or serious harm towards any
	// target.
	HarassmentThreatening bool `json:"harassment/threatening,required"`
	// Content that expresses, incites, or promotes hate based on race, gender,
	// ethnicity, religion, nationality, sexual orientation, disability status, or
	// caste. Hateful content aimed at non-protected groups (e.g., chess players) is
	// harassment.
	Hate bool `json:"hate,required"`
	// Hateful content that also includes violence or serious harm towards the targeted
	// group based on race, gender, ethnicity, religion, nationality, sexual
	// orientation, disability status, or caste.
	HateThreatening bool `json:"hate/threatening,required"`
	// Content that includes instructions or advice that facilitate the planning or
	// execution of wrongdoing, or that gives advice or instruction on how to commit
	// illicit acts. For example, "how to shoplift" would fit this category.
	Illicit bool `json:"illicit,required"`
	// Content that includes instructions or advice that facilitate the planning or
	// execution of wrongdoing that also includes violence, or that gives advice or
	// instruction on the procurement of any weapon.
	IllicitViolent bool `json:"illicit/violent,required"`
	// Content that promotes, encourages, or depicts acts of self-harm, such as
	// suicide, cutting, and eating disorders.
	SelfHarm bool `json:"self-harm,required"`
	// Content that encourages performing acts of self-harm, such as suicide, cutting,
	// and eating disorders, or that gives instructions or advice on how to commit such
	// acts.
	SelfHarmInstructions bool `json:"self-harm/instructions,required"`
	// Content where the speaker expresses that they are engaging or intend to engage
	// in acts of self-harm, such as suicide, cutting, and eating disorders.
	SelfHarmIntent bool `json:"self-harm/intent,required"`
	// Content meant to arouse sexual excitement, such as the description of sexual
	// activity, or that promotes sexual services (excluding sex education and
	// wellness).
	Sexual bool `json:"sexual,required"`
	// Sexual content that includes an individual who is under 18 years old.
	SexualMinors bool `json:"sexual/minors,required"`
	// Content that depicts death, violence, or physical injury.
	Violence bool `json:"violence,required"`
	// Content that depicts death, violence, or physical injury in graphic detail.
	ViolenceGraphic bool `json:"violence/graphic,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Harassment            respjson.Field
		HarassmentThreatening respjson.Field
		Hate                  respjson.Field
		HateThreatening       respjson.Field
		Illicit               respjson.Field
		IllicitViolent        respjson.Field
		SelfHarm              respjson.Field
		SelfHarmInstructions  respjson.Field
		SelfHarmIntent        respjson.Field
		Sexual                respjson.Field
		SexualMinors          respjson.Field
		Violence              respjson.Field
		ViolenceGraphic       respjson.Field
		ExtraFields           map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A list of the categories, and whether they are flagged or not.

func (ModerationCategories) RawJSON

func (r ModerationCategories) RawJSON() string

Returns the unmodified JSON received from the API

func (*ModerationCategories) UnmarshalJSON

func (r *ModerationCategories) UnmarshalJSON(data []byte) error

type ModerationCategoryAppliedInputTypes

type ModerationCategoryAppliedInputTypes struct {
	// The applied input type(s) for the category 'harassment'.
	//
	// Any of "text".
	Harassment []string `json:"harassment,required"`
	// The applied input type(s) for the category 'harassment/threatening'.
	//
	// Any of "text".
	HarassmentThreatening []string `json:"harassment/threatening,required"`
	// The applied input type(s) for the category 'hate'.
	//
	// Any of "text".
	Hate []string `json:"hate,required"`
	// The applied input type(s) for the category 'hate/threatening'.
	//
	// Any of "text".
	HateThreatening []string `json:"hate/threatening,required"`
	// The applied input type(s) for the category 'illicit'.
	//
	// Any of "text".
	Illicit []string `json:"illicit,required"`
	// The applied input type(s) for the category 'illicit/violent'.
	//
	// Any of "text".
	IllicitViolent []string `json:"illicit/violent,required"`
	// The applied input type(s) for the category 'self-harm'.
	//
	// Any of "text", "image".
	SelfHarm []string `json:"self-harm,required"`
	// The applied input type(s) for the category 'self-harm/instructions'.
	//
	// Any of "text", "image".
	SelfHarmInstructions []string `json:"self-harm/instructions,required"`
	// The applied input type(s) for the category 'self-harm/intent'.
	//
	// Any of "text", "image".
	SelfHarmIntent []string `json:"self-harm/intent,required"`
	// The applied input type(s) for the category 'sexual'.
	//
	// Any of "text", "image".
	Sexual []string `json:"sexual,required"`
	// The applied input type(s) for the category 'sexual/minors'.
	//
	// Any of "text".
	SexualMinors []string `json:"sexual/minors,required"`
	// The applied input type(s) for the category 'violence'.
	//
	// Any of "text", "image".
	Violence []string `json:"violence,required"`
	// The applied input type(s) for the category 'violence/graphic'.
	//
	// Any of "text", "image".
	ViolenceGraphic []string `json:"violence/graphic,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Harassment            respjson.Field
		HarassmentThreatening respjson.Field
		Hate                  respjson.Field
		HateThreatening       respjson.Field
		Illicit               respjson.Field
		IllicitViolent        respjson.Field
		SelfHarm              respjson.Field
		SelfHarmInstructions  respjson.Field
		SelfHarmIntent        respjson.Field
		Sexual                respjson.Field
		SexualMinors          respjson.Field
		Violence              respjson.Field
		ViolenceGraphic       respjson.Field
		ExtraFields           map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A list of the categories along with the input type(s) that the score applies to.

func (ModerationCategoryAppliedInputTypes) RawJSON

Returns the unmodified JSON received from the API

func (*ModerationCategoryAppliedInputTypes) UnmarshalJSON

func (r *ModerationCategoryAppliedInputTypes) UnmarshalJSON(data []byte) error

type ModerationCategoryScores

type ModerationCategoryScores struct {
	// The score for the category 'harassment'.
	Harassment float64 `json:"harassment,required"`
	// The score for the category 'harassment/threatening'.
	HarassmentThreatening float64 `json:"harassment/threatening,required"`
	// The score for the category 'hate'.
	Hate float64 `json:"hate,required"`
	// The score for the category 'hate/threatening'.
	HateThreatening float64 `json:"hate/threatening,required"`
	// The score for the category 'illicit'.
	Illicit float64 `json:"illicit,required"`
	// The score for the category 'illicit/violent'.
	IllicitViolent float64 `json:"illicit/violent,required"`
	// The score for the category 'self-harm'.
	SelfHarm float64 `json:"self-harm,required"`
	// The score for the category 'self-harm/instructions'.
	SelfHarmInstructions float64 `json:"self-harm/instructions,required"`
	// The score for the category 'self-harm/intent'.
	SelfHarmIntent float64 `json:"self-harm/intent,required"`
	// The score for the category 'sexual'.
	Sexual float64 `json:"sexual,required"`
	// The score for the category 'sexual/minors'.
	SexualMinors float64 `json:"sexual/minors,required"`
	// The score for the category 'violence'.
	Violence float64 `json:"violence,required"`
	// The score for the category 'violence/graphic'.
	ViolenceGraphic float64 `json:"violence/graphic,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Harassment            respjson.Field
		HarassmentThreatening respjson.Field
		Hate                  respjson.Field
		HateThreatening       respjson.Field
		Illicit               respjson.Field
		IllicitViolent        respjson.Field
		SelfHarm              respjson.Field
		SelfHarmInstructions  respjson.Field
		SelfHarmIntent        respjson.Field
		Sexual                respjson.Field
		SexualMinors          respjson.Field
		Violence              respjson.Field
		ViolenceGraphic       respjson.Field
		ExtraFields           map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A list of the categories along with their scores as predicted by model.

func (ModerationCategoryScores) RawJSON

func (r ModerationCategoryScores) RawJSON() string

Returns the unmodified JSON received from the API

func (*ModerationCategoryScores) UnmarshalJSON

func (r *ModerationCategoryScores) UnmarshalJSON(data []byte) error

type ModerationImageURLInputImageURLParam

type ModerationImageURLInputImageURLParam struct {
	// Either a URL of the image or the base64 encoded image data.
	URL string `json:"url,required" format:"uri"`
	// contains filtered or unexported fields
}

Contains either an image URL or a data URL for a base64 encoded image.

The property URL is required.

func (ModerationImageURLInputImageURLParam) MarshalJSON

func (r ModerationImageURLInputImageURLParam) MarshalJSON() (data []byte, err error)

func (*ModerationImageURLInputImageURLParam) UnmarshalJSON

func (r *ModerationImageURLInputImageURLParam) UnmarshalJSON(data []byte) error

type ModerationImageURLInputParam

type ModerationImageURLInputParam struct {
	// Contains either an image URL or a data URL for a base64 encoded image.
	ImageURL ModerationImageURLInputImageURLParam `json:"image_url,omitzero,required"`
	// Always `image_url`.
	//
	// This field can be elided, and will marshal its zero value as "image_url".
	Type constant.ImageURL `json:"type,required"`
	// contains filtered or unexported fields
}

An object describing an image to classify.

The properties ImageURL, Type are required.

func (ModerationImageURLInputParam) MarshalJSON

func (r ModerationImageURLInputParam) MarshalJSON() (data []byte, err error)

func (*ModerationImageURLInputParam) UnmarshalJSON

func (r *ModerationImageURLInputParam) UnmarshalJSON(data []byte) error

type ModerationModel

type ModerationModel = string
const (
	ModerationModelOmniModerationLatest     ModerationModel = "omni-moderation-latest"
	ModerationModelOmniModeration2024_09_26 ModerationModel = "omni-moderation-2024-09-26"
	ModerationModelTextModerationLatest     ModerationModel = "text-moderation-latest"
	ModerationModelTextModerationStable     ModerationModel = "text-moderation-stable"
)

type ModerationMultiModalInputUnionParam

type ModerationMultiModalInputUnionParam struct {
	OfImageURL *ModerationImageURLInputParam `json:",omitzero,inline"`
	OfText     *ModerationTextInputParam     `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func ModerationMultiModalInputParamOfText

func ModerationMultiModalInputParamOfText(text string) ModerationMultiModalInputUnionParam

func (ModerationMultiModalInputUnionParam) GetImageURL

Returns a pointer to the underlying variant's property, if present.

func (ModerationMultiModalInputUnionParam) GetText

Returns a pointer to the underlying variant's property, if present.

func (ModerationMultiModalInputUnionParam) GetType

Returns a pointer to the underlying variant's property, if present.

func (ModerationMultiModalInputUnionParam) MarshalJSON

func (u ModerationMultiModalInputUnionParam) MarshalJSON() ([]byte, error)

func (*ModerationMultiModalInputUnionParam) UnmarshalJSON

func (u *ModerationMultiModalInputUnionParam) UnmarshalJSON(data []byte) error

type ModerationNewParams

type ModerationNewParams struct {
	// Input (or inputs) to classify. Can be a single string, an array of strings, or
	// an array of multi-modal input objects similar to other models.
	Input ModerationNewParamsInputUnion `json:"input,omitzero,required"`
	// The content moderation model you would like to use. Learn more in
	// [the moderation guide](https://platform.openai.com/docs/guides/moderation), and
	// learn about available models
	// [here](https://platform.openai.com/docs/models#moderation).
	Model ModerationModel `json:"model,omitzero"`
	// contains filtered or unexported fields
}

func (ModerationNewParams) MarshalJSON

func (r ModerationNewParams) MarshalJSON() (data []byte, err error)

func (*ModerationNewParams) UnmarshalJSON

func (r *ModerationNewParams) UnmarshalJSON(data []byte) error

type ModerationNewParamsInputUnion

type ModerationNewParamsInputUnion struct {
	OfString                    param.Opt[string]                     `json:",omitzero,inline"`
	OfStringArray               []string                              `json:",omitzero,inline"`
	OfModerationMultiModalArray []ModerationMultiModalInputUnionParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ModerationNewParamsInputUnion) MarshalJSON

func (u ModerationNewParamsInputUnion) MarshalJSON() ([]byte, error)

func (*ModerationNewParamsInputUnion) UnmarshalJSON

func (u *ModerationNewParamsInputUnion) UnmarshalJSON(data []byte) error

type ModerationNewResponse

type ModerationNewResponse struct {
	// The unique identifier for the moderation request.
	ID string `json:"id,required"`
	// The model used to generate the moderation results.
	Model string `json:"model,required"`
	// A list of moderation objects.
	Results []Moderation `json:"results,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Model       respjson.Field
		Results     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents if a given text input is potentially harmful.

func (ModerationNewResponse) RawJSON

func (r ModerationNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ModerationNewResponse) UnmarshalJSON

func (r *ModerationNewResponse) UnmarshalJSON(data []byte) error

type ModerationService

type ModerationService struct {
	Options []option.RequestOption
}

ModerationService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewModerationService method instead.

func NewModerationService

func NewModerationService(opts ...option.RequestOption) (r ModerationService)

NewModerationService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ModerationService) New

Classifies if text and/or image inputs are potentially harmful. Learn more in the [moderation guide](https://platform.openai.com/docs/guides/moderation).

type ModerationTextInputParam

type ModerationTextInputParam struct {
	// A string of text to classify.
	Text string `json:"text,required"`
	// Always `text`.
	//
	// This field can be elided, and will marshal its zero value as "text".
	Type constant.Text `json:"type,required"`
	// contains filtered or unexported fields
}

An object describing text to classify.

The properties Text, Type are required.

func (ModerationTextInputParam) MarshalJSON

func (r ModerationTextInputParam) MarshalJSON() (data []byte, err error)

func (*ModerationTextInputParam) UnmarshalJSON

func (r *ModerationTextInputParam) UnmarshalJSON(data []byte) error

type MultiGrader

type MultiGrader struct {
	// A formula to calculate the output based on grader results.
	CalculateOutput string `json:"calculate_output,required"`
	// A StringCheckGrader object that performs a string comparison between input and
	// reference using a specified operation.
	Graders MultiGraderGradersUnion `json:"graders,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The object type, which is always `multi`.
	Type constant.Multi `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CalculateOutput respjson.Field
		Graders         respjson.Field
		Name            respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A MultiGrader object combines the output of multiple graders to produce a single score.

func (MultiGrader) RawJSON

func (r MultiGrader) RawJSON() string

Returns the unmodified JSON received from the API

func (MultiGrader) ToParam

func (r MultiGrader) ToParam() MultiGraderParam

ToParam converts this MultiGrader to a MultiGraderParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with MultiGraderParam.Overrides()

func (*MultiGrader) UnmarshalJSON

func (r *MultiGrader) UnmarshalJSON(data []byte) error

type MultiGraderGradersUnion added in v1.2.1

type MultiGraderGradersUnion struct {
	// This field is a union of [string], [string], [[]ScoreModelGraderInput],
	// [[]LabelModelGraderInput]
	Input MultiGraderGradersUnionInput `json:"input"`
	Name  string                       `json:"name"`
	// This field is from variant [StringCheckGrader].
	Operation StringCheckGraderOperation `json:"operation"`
	Reference string                     `json:"reference"`
	Type      string                     `json:"type"`
	// This field is from variant [TextSimilarityGrader].
	EvaluationMetric TextSimilarityGraderEvaluationMetric `json:"evaluation_metric"`
	// This field is from variant [PythonGrader].
	Source string `json:"source"`
	// This field is from variant [PythonGrader].
	ImageTag string `json:"image_tag"`
	Model    string `json:"model"`
	// This field is from variant [ScoreModelGrader].
	Range []float64 `json:"range"`
	// This field is from variant [ScoreModelGrader].
	SamplingParams any `json:"sampling_params"`
	// This field is from variant [LabelModelGrader].
	Labels []string `json:"labels"`
	// This field is from variant [LabelModelGrader].
	PassingLabels []string `json:"passing_labels"`
	JSON          struct {
		Input            respjson.Field
		Name             respjson.Field
		Operation        respjson.Field
		Reference        respjson.Field
		Type             respjson.Field
		EvaluationMetric respjson.Field
		Source           respjson.Field
		ImageTag         respjson.Field
		Model            respjson.Field
		Range            respjson.Field
		SamplingParams   respjson.Field
		Labels           respjson.Field
		PassingLabels    respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MultiGraderGradersUnion contains all possible properties and values from StringCheckGrader, TextSimilarityGrader, PythonGrader, ScoreModelGrader, LabelModelGrader.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (MultiGraderGradersUnion) AsLabelModelGrader added in v1.2.1

func (u MultiGraderGradersUnion) AsLabelModelGrader() (v LabelModelGrader)

func (MultiGraderGradersUnion) AsPythonGrader added in v1.2.1

func (u MultiGraderGradersUnion) AsPythonGrader() (v PythonGrader)

func (MultiGraderGradersUnion) AsScoreModelGrader added in v1.2.1

func (u MultiGraderGradersUnion) AsScoreModelGrader() (v ScoreModelGrader)

func (MultiGraderGradersUnion) AsStringCheckGrader added in v1.2.1

func (u MultiGraderGradersUnion) AsStringCheckGrader() (v StringCheckGrader)

func (MultiGraderGradersUnion) AsTextSimilarityGrader added in v1.2.1

func (u MultiGraderGradersUnion) AsTextSimilarityGrader() (v TextSimilarityGrader)

func (MultiGraderGradersUnion) RawJSON added in v1.2.1

func (u MultiGraderGradersUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*MultiGraderGradersUnion) UnmarshalJSON added in v1.2.1

func (r *MultiGraderGradersUnion) UnmarshalJSON(data []byte) error

type MultiGraderGradersUnionInput added in v1.2.1

type MultiGraderGradersUnionInput struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]ScoreModelGraderInput] instead
	// of an object.
	OfScoreModelGraderInputArray []ScoreModelGraderInput `json:",inline"`
	// This field will be present if the value is a [[]LabelModelGraderInput] instead
	// of an object.
	OfLabelModelGraderInputArray []LabelModelGraderInput `json:",inline"`
	JSON                         struct {
		OfString                     respjson.Field
		OfScoreModelGraderInputArray respjson.Field
		OfLabelModelGraderInputArray respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MultiGraderGradersUnionInput is an implicit subunion of MultiGraderGradersUnion. MultiGraderGradersUnionInput provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the MultiGraderGradersUnion.

If the underlying value is not a json object, one of the following properties will be valid: OfString OfScoreModelGraderInputArray OfLabelModelGraderInputArray]

func (*MultiGraderGradersUnionInput) UnmarshalJSON added in v1.2.1

func (r *MultiGraderGradersUnionInput) UnmarshalJSON(data []byte) error

type MultiGraderGradersUnionParam added in v1.2.1

type MultiGraderGradersUnionParam struct {
	OfStringCheckGrader    *StringCheckGraderParam    `json:",omitzero,inline"`
	OfTextSimilarityGrader *TextSimilarityGraderParam `json:",omitzero,inline"`
	OfPythonGrader         *PythonGraderParam         `json:",omitzero,inline"`
	OfScoreModelGrader     *ScoreModelGraderParam     `json:",omitzero,inline"`
	OfLabelModelGrader     *LabelModelGraderParam     `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (MultiGraderGradersUnionParam) GetEvaluationMetric added in v1.2.1

func (u MultiGraderGradersUnionParam) GetEvaluationMetric() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetImageTag added in v1.2.1

func (u MultiGraderGradersUnionParam) GetImageTag() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetInput added in v1.2.1

func (u MultiGraderGradersUnionParam) GetInput() (res multiGraderGradersUnionParamInput)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (MultiGraderGradersUnionParam) GetLabels added in v1.2.1

func (u MultiGraderGradersUnionParam) GetLabels() []string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetModel added in v1.2.1

func (u MultiGraderGradersUnionParam) GetModel() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetName added in v1.2.1

func (u MultiGraderGradersUnionParam) GetName() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetOperation added in v1.2.1

func (u MultiGraderGradersUnionParam) GetOperation() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetPassingLabels added in v1.2.1

func (u MultiGraderGradersUnionParam) GetPassingLabels() []string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetRange added in v1.2.1

func (u MultiGraderGradersUnionParam) GetRange() []float64

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetReference added in v1.2.1

func (u MultiGraderGradersUnionParam) GetReference() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetSamplingParams added in v1.2.1

func (u MultiGraderGradersUnionParam) GetSamplingParams() *any

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetSource added in v1.2.1

func (u MultiGraderGradersUnionParam) GetSource() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) GetType added in v1.2.1

func (u MultiGraderGradersUnionParam) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (MultiGraderGradersUnionParam) MarshalJSON added in v1.2.1

func (u MultiGraderGradersUnionParam) MarshalJSON() ([]byte, error)

func (*MultiGraderGradersUnionParam) UnmarshalJSON added in v1.2.1

func (u *MultiGraderGradersUnionParam) UnmarshalJSON(data []byte) error

type MultiGraderParam

type MultiGraderParam struct {
	// A formula to calculate the output based on grader results.
	CalculateOutput string `json:"calculate_output,required"`
	// A StringCheckGrader object that performs a string comparison between input and
	// reference using a specified operation.
	Graders MultiGraderGradersUnionParam `json:"graders,omitzero,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The object type, which is always `multi`.
	//
	// This field can be elided, and will marshal its zero value as "multi".
	Type constant.Multi `json:"type,required"`
	// contains filtered or unexported fields
}

A MultiGrader object combines the output of multiple graders to produce a single score.

The properties CalculateOutput, Graders, Name, Type are required.

func (MultiGraderParam) MarshalJSON

func (r MultiGraderParam) MarshalJSON() (data []byte, err error)

func (*MultiGraderParam) UnmarshalJSON

func (r *MultiGraderParam) UnmarshalJSON(data []byte) error

type OtherFileChunkingStrategyObject

type OtherFileChunkingStrategyObject struct {
	// Always `other`.
	Type constant.Other `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.

func (OtherFileChunkingStrategyObject) RawJSON

Returns the unmodified JSON received from the API

func (*OtherFileChunkingStrategyObject) UnmarshalJSON

func (r *OtherFileChunkingStrategyObject) UnmarshalJSON(data []byte) error

type PythonGrader

type PythonGrader struct {
	// The name of the grader.
	Name string `json:"name,required"`
	// The source code of the python script.
	Source string `json:"source,required"`
	// The object type, which is always `python`.
	Type constant.Python `json:"type,required"`
	// The image tag to use for the python script.
	ImageTag string `json:"image_tag"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		Source      respjson.Field
		Type        respjson.Field
		ImageTag    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A PythonGrader object that runs a python script on the input.

func (PythonGrader) RawJSON

func (r PythonGrader) RawJSON() string

Returns the unmodified JSON received from the API

func (PythonGrader) ToParam

func (r PythonGrader) ToParam() PythonGraderParam

ToParam converts this PythonGrader to a PythonGraderParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with PythonGraderParam.Overrides()

func (*PythonGrader) UnmarshalJSON

func (r *PythonGrader) UnmarshalJSON(data []byte) error

type PythonGraderParam

type PythonGraderParam struct {
	// The name of the grader.
	Name string `json:"name,required"`
	// The source code of the python script.
	Source string `json:"source,required"`
	// The image tag to use for the python script.
	ImageTag param.Opt[string] `json:"image_tag,omitzero"`
	// The object type, which is always `python`.
	//
	// This field can be elided, and will marshal its zero value as "python".
	Type constant.Python `json:"type,required"`
	// contains filtered or unexported fields
}

A PythonGrader object that runs a python script on the input.

The properties Name, Source, Type are required.

func (PythonGraderParam) MarshalJSON

func (r PythonGraderParam) MarshalJSON() (data []byte, err error)

func (*PythonGraderParam) UnmarshalJSON

func (r *PythonGraderParam) UnmarshalJSON(data []byte) error

type Reasoning

type Reasoning = shared.Reasoning

**o-series models only**

Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).

This is an alias to an internal type.

type ReasoningEffort

type ReasoningEffort = shared.ReasoningEffort

**o-series models only**

Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.

This is an alias to an internal type.

type ReasoningGenerateSummary

type ReasoningGenerateSummary = shared.ReasoningGenerateSummary

**Deprecated:** use `summary` instead.

A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`.

This is an alias to an internal type.

type ReasoningParam

type ReasoningParam = shared.ReasoningParam

**o-series models only**

Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).

This is an alias to an internal type.

type ReasoningSummary

type ReasoningSummary = shared.ReasoningSummary

A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`.

This is an alias to an internal type.

type RefusalContentBlock added in v1.1.0

type RefusalContentBlock struct {
	Refusal string `json:"refusal,required"`
	// Always `refusal`.
	Type constant.Refusal `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Refusal     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The refusal content generated by the assistant.

func (RefusalContentBlock) RawJSON added in v1.1.0

func (r RefusalContentBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*RefusalContentBlock) UnmarshalJSON added in v1.1.0

func (r *RefusalContentBlock) UnmarshalJSON(data []byte) error

type RefusalDeltaBlock added in v1.1.0

type RefusalDeltaBlock struct {
	// The index of the refusal part in the message.
	Index int64 `json:"index,required"`
	// Always `refusal`.
	Type    constant.Refusal `json:"type,required"`
	Refusal string           `json:"refusal"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		Refusal     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The refusal content that is part of a message.

func (RefusalDeltaBlock) RawJSON added in v1.1.0

func (r RefusalDeltaBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*RefusalDeltaBlock) UnmarshalJSON added in v1.1.0

func (r *RefusalDeltaBlock) UnmarshalJSON(data []byte) error

type ReinforcementHyperparameters

type ReinforcementHyperparameters struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize ReinforcementHyperparametersBatchSizeUnion `json:"batch_size,omitzero"`
	// Multiplier on amount of compute used for exploring search space during training.
	ComputeMultiplier ReinforcementHyperparametersComputeMultiplierUnion `json:"compute_multiplier,omitzero"`
	// The number of training steps between evaluation runs.
	EvalInterval ReinforcementHyperparametersEvalIntervalUnion `json:"eval_interval,omitzero"`
	// Number of evaluation samples to generate per training step.
	EvalSamples ReinforcementHyperparametersEvalSamplesUnion `json:"eval_samples,omitzero"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier ReinforcementHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier,omitzero"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs ReinforcementHyperparametersNEpochsUnion `json:"n_epochs,omitzero"`
	// Level of reasoning effort.
	//
	// Any of "default", "low", "medium", "high".
	ReasoningEffort ReinforcementHyperparametersReasoningEffort `json:"reasoning_effort,omitzero"`
	// contains filtered or unexported fields
}

The hyperparameters used for the reinforcement fine-tuning job.

func (ReinforcementHyperparameters) MarshalJSON

func (r ReinforcementHyperparameters) MarshalJSON() (data []byte, err error)

func (*ReinforcementHyperparameters) UnmarshalJSON

func (r *ReinforcementHyperparameters) UnmarshalJSON(data []byte) error

type ReinforcementHyperparametersBatchSizeUnion

type ReinforcementHyperparametersBatchSizeUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ReinforcementHyperparametersBatchSizeUnion) MarshalJSON

func (*ReinforcementHyperparametersBatchSizeUnion) UnmarshalJSON

func (u *ReinforcementHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error

type ReinforcementHyperparametersBatchSizeUnionResp

type ReinforcementHyperparametersBatchSizeUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementHyperparametersBatchSizeUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (ReinforcementHyperparametersBatchSizeUnionResp) AsAuto

func (ReinforcementHyperparametersBatchSizeUnionResp) AsInt

func (ReinforcementHyperparametersBatchSizeUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*ReinforcementHyperparametersBatchSizeUnionResp) UnmarshalJSON

type ReinforcementHyperparametersComputeMultiplierUnion added in v1.1.0

type ReinforcementHyperparametersComputeMultiplierUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto  constant.Auto      `json:",omitzero,inline"`
	OfFloat param.Opt[float64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ReinforcementHyperparametersComputeMultiplierUnion) MarshalJSON added in v1.1.0

func (*ReinforcementHyperparametersComputeMultiplierUnion) UnmarshalJSON added in v1.1.0

type ReinforcementHyperparametersComputeMultiplierUnionResp added in v1.1.0

type ReinforcementHyperparametersComputeMultiplierUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfAuto  respjson.Field
		OfFloat respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementHyperparametersComputeMultiplierUnionResp contains all possible properties and values from constant.Auto, [float64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfFloat]

func (ReinforcementHyperparametersComputeMultiplierUnionResp) AsAuto added in v1.1.0

func (ReinforcementHyperparametersComputeMultiplierUnionResp) AsFloat added in v1.1.0

func (ReinforcementHyperparametersComputeMultiplierUnionResp) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ReinforcementHyperparametersComputeMultiplierUnionResp) UnmarshalJSON added in v1.1.0

type ReinforcementHyperparametersEvalIntervalUnion

type ReinforcementHyperparametersEvalIntervalUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ReinforcementHyperparametersEvalIntervalUnion) MarshalJSON

func (*ReinforcementHyperparametersEvalIntervalUnion) UnmarshalJSON

func (u *ReinforcementHyperparametersEvalIntervalUnion) UnmarshalJSON(data []byte) error

type ReinforcementHyperparametersEvalIntervalUnionResp

type ReinforcementHyperparametersEvalIntervalUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementHyperparametersEvalIntervalUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (ReinforcementHyperparametersEvalIntervalUnionResp) AsAuto

func (ReinforcementHyperparametersEvalIntervalUnionResp) AsInt

func (ReinforcementHyperparametersEvalIntervalUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*ReinforcementHyperparametersEvalIntervalUnionResp) UnmarshalJSON

type ReinforcementHyperparametersEvalSamplesUnion added in v1.1.0

type ReinforcementHyperparametersEvalSamplesUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ReinforcementHyperparametersEvalSamplesUnion) MarshalJSON added in v1.1.0

func (*ReinforcementHyperparametersEvalSamplesUnion) UnmarshalJSON added in v1.1.0

func (u *ReinforcementHyperparametersEvalSamplesUnion) UnmarshalJSON(data []byte) error

type ReinforcementHyperparametersEvalSamplesUnionResp added in v1.1.0

type ReinforcementHyperparametersEvalSamplesUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementHyperparametersEvalSamplesUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (ReinforcementHyperparametersEvalSamplesUnionResp) AsAuto added in v1.1.0

func (ReinforcementHyperparametersEvalSamplesUnionResp) AsInt added in v1.1.0

func (ReinforcementHyperparametersEvalSamplesUnionResp) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ReinforcementHyperparametersEvalSamplesUnionResp) UnmarshalJSON added in v1.1.0

type ReinforcementHyperparametersLearningRateMultiplierUnion added in v1.1.0

type ReinforcementHyperparametersLearningRateMultiplierUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto  constant.Auto      `json:",omitzero,inline"`
	OfFloat param.Opt[float64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ReinforcementHyperparametersLearningRateMultiplierUnion) MarshalJSON added in v1.1.0

func (*ReinforcementHyperparametersLearningRateMultiplierUnion) UnmarshalJSON added in v1.1.0

type ReinforcementHyperparametersLearningRateMultiplierUnionResp added in v1.1.0

type ReinforcementHyperparametersLearningRateMultiplierUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfAuto  respjson.Field
		OfFloat respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementHyperparametersLearningRateMultiplierUnionResp contains all possible properties and values from constant.Auto, [float64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfFloat]

func (ReinforcementHyperparametersLearningRateMultiplierUnionResp) AsAuto added in v1.1.0

func (ReinforcementHyperparametersLearningRateMultiplierUnionResp) AsFloat added in v1.1.0

func (ReinforcementHyperparametersLearningRateMultiplierUnionResp) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ReinforcementHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON added in v1.1.0

type ReinforcementHyperparametersNEpochsUnion

type ReinforcementHyperparametersNEpochsUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ReinforcementHyperparametersNEpochsUnion) MarshalJSON

func (*ReinforcementHyperparametersNEpochsUnion) UnmarshalJSON

func (u *ReinforcementHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error

type ReinforcementHyperparametersNEpochsUnionResp

type ReinforcementHyperparametersNEpochsUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementHyperparametersNEpochsUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (ReinforcementHyperparametersNEpochsUnionResp) AsAuto

func (ReinforcementHyperparametersNEpochsUnionResp) AsInt

func (ReinforcementHyperparametersNEpochsUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*ReinforcementHyperparametersNEpochsUnionResp) UnmarshalJSON

func (r *ReinforcementHyperparametersNEpochsUnionResp) UnmarshalJSON(data []byte) error

type ReinforcementHyperparametersReasoningEffort

type ReinforcementHyperparametersReasoningEffort string

Level of reasoning effort.

const (
	ReinforcementHyperparametersReasoningEffortDefault ReinforcementHyperparametersReasoningEffort = "default"
	ReinforcementHyperparametersReasoningEffortLow     ReinforcementHyperparametersReasoningEffort = "low"
	ReinforcementHyperparametersReasoningEffortMedium  ReinforcementHyperparametersReasoningEffort = "medium"
	ReinforcementHyperparametersReasoningEffortHigh    ReinforcementHyperparametersReasoningEffort = "high"
)

type ReinforcementHyperparametersResp

type ReinforcementHyperparametersResp struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize ReinforcementHyperparametersBatchSizeUnionResp `json:"batch_size"`
	// Multiplier on amount of compute used for exploring search space during training.
	ComputeMultiplier ReinforcementHyperparametersComputeMultiplierUnionResp `json:"compute_multiplier"`
	// The number of training steps between evaluation runs.
	EvalInterval ReinforcementHyperparametersEvalIntervalUnionResp `json:"eval_interval"`
	// Number of evaluation samples to generate per training step.
	EvalSamples ReinforcementHyperparametersEvalSamplesUnionResp `json:"eval_samples"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier ReinforcementHyperparametersLearningRateMultiplierUnionResp `json:"learning_rate_multiplier"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs ReinforcementHyperparametersNEpochsUnionResp `json:"n_epochs"`
	// Level of reasoning effort.
	//
	// Any of "default", "low", "medium", "high".
	ReasoningEffort ReinforcementHyperparametersReasoningEffort `json:"reasoning_effort"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BatchSize              respjson.Field
		ComputeMultiplier      respjson.Field
		EvalInterval           respjson.Field
		EvalSamples            respjson.Field
		LearningRateMultiplier respjson.Field
		NEpochs                respjson.Field
		ReasoningEffort        respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The hyperparameters used for the reinforcement fine-tuning job.

func (ReinforcementHyperparametersResp) RawJSON

Returns the unmodified JSON received from the API

func (ReinforcementHyperparametersResp) ToParam

ToParam converts this ReinforcementHyperparametersResp to a ReinforcementHyperparameters.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ReinforcementHyperparameters.Overrides()

func (*ReinforcementHyperparametersResp) UnmarshalJSON

func (r *ReinforcementHyperparametersResp) UnmarshalJSON(data []byte) error

type ReinforcementMethod

type ReinforcementMethod struct {
	// The grader used for the fine-tuning job.
	Grader ReinforcementMethodGraderUnion `json:"grader,required"`
	// The hyperparameters used for the reinforcement fine-tuning job.
	Hyperparameters ReinforcementHyperparametersResp `json:"hyperparameters"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Grader          respjson.Field
		Hyperparameters respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Configuration for the reinforcement fine-tuning method.

func (ReinforcementMethod) RawJSON

func (r ReinforcementMethod) RawJSON() string

Returns the unmodified JSON received from the API

func (ReinforcementMethod) ToParam

ToParam converts this ReinforcementMethod to a ReinforcementMethodParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ReinforcementMethodParam.Overrides()

func (*ReinforcementMethod) UnmarshalJSON

func (r *ReinforcementMethod) UnmarshalJSON(data []byte) error

type ReinforcementMethodGraderUnion

type ReinforcementMethodGraderUnion struct {
	// This field is a union of [string], [string], [[]ScoreModelGraderInput]
	Input ReinforcementMethodGraderUnionInput `json:"input"`
	Name  string                              `json:"name"`
	// This field is from variant [StringCheckGrader].
	Operation StringCheckGraderOperation `json:"operation"`
	Reference string                     `json:"reference"`
	Type      string                     `json:"type"`
	// This field is from variant [TextSimilarityGrader].
	EvaluationMetric TextSimilarityGraderEvaluationMetric `json:"evaluation_metric"`
	// This field is from variant [PythonGrader].
	Source string `json:"source"`
	// This field is from variant [PythonGrader].
	ImageTag string `json:"image_tag"`
	// This field is from variant [ScoreModelGrader].
	Model string `json:"model"`
	// This field is from variant [ScoreModelGrader].
	Range []float64 `json:"range"`
	// This field is from variant [ScoreModelGrader].
	SamplingParams any `json:"sampling_params"`
	// This field is from variant [MultiGrader].
	CalculateOutput string `json:"calculate_output"`
	// This field is from variant [MultiGrader].
	Graders MultiGraderGradersUnion `json:"graders"`
	JSON    struct {
		Input            respjson.Field
		Name             respjson.Field
		Operation        respjson.Field
		Reference        respjson.Field
		Type             respjson.Field
		EvaluationMetric respjson.Field
		Source           respjson.Field
		ImageTag         respjson.Field
		Model            respjson.Field
		Range            respjson.Field
		SamplingParams   respjson.Field
		CalculateOutput  respjson.Field
		Graders          respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementMethodGraderUnion contains all possible properties and values from StringCheckGrader, TextSimilarityGrader, PythonGrader, ScoreModelGrader, MultiGrader.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (ReinforcementMethodGraderUnion) AsMultiGrader

func (u ReinforcementMethodGraderUnion) AsMultiGrader() (v MultiGrader)

func (ReinforcementMethodGraderUnion) AsPythonGrader

func (u ReinforcementMethodGraderUnion) AsPythonGrader() (v PythonGrader)

func (ReinforcementMethodGraderUnion) AsScoreModelGrader

func (u ReinforcementMethodGraderUnion) AsScoreModelGrader() (v ScoreModelGrader)

func (ReinforcementMethodGraderUnion) AsStringCheckGrader

func (u ReinforcementMethodGraderUnion) AsStringCheckGrader() (v StringCheckGrader)

func (ReinforcementMethodGraderUnion) AsTextSimilarityGrader

func (u ReinforcementMethodGraderUnion) AsTextSimilarityGrader() (v TextSimilarityGrader)

func (ReinforcementMethodGraderUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ReinforcementMethodGraderUnion) UnmarshalJSON

func (r *ReinforcementMethodGraderUnion) UnmarshalJSON(data []byte) error

type ReinforcementMethodGraderUnionInput

type ReinforcementMethodGraderUnionInput struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]ScoreModelGraderInput] instead
	// of an object.
	OfScoreModelGraderInputArray []ScoreModelGraderInput `json:",inline"`
	JSON                         struct {
		OfString                     respjson.Field
		OfScoreModelGraderInputArray respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ReinforcementMethodGraderUnionInput is an implicit subunion of ReinforcementMethodGraderUnion. ReinforcementMethodGraderUnionInput provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the ReinforcementMethodGraderUnion.

If the underlying value is not a json object, one of the following properties will be valid: OfString OfScoreModelGraderInputArray]

func (*ReinforcementMethodGraderUnionInput) UnmarshalJSON

func (r *ReinforcementMethodGraderUnionInput) UnmarshalJSON(data []byte) error

type ReinforcementMethodGraderUnionParam

type ReinforcementMethodGraderUnionParam struct {
	OfStringCheckGrader    *StringCheckGraderParam    `json:",omitzero,inline"`
	OfTextSimilarityGrader *TextSimilarityGraderParam `json:",omitzero,inline"`
	OfPythonGrader         *PythonGraderParam         `json:",omitzero,inline"`
	OfScoreModelGrader     *ScoreModelGraderParam     `json:",omitzero,inline"`
	OfMultiGrader          *MultiGraderParam          `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ReinforcementMethodGraderUnionParam) GetCalculateOutput

func (u ReinforcementMethodGraderUnionParam) GetCalculateOutput() *string

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetEvaluationMetric

func (u ReinforcementMethodGraderUnionParam) GetEvaluationMetric() *string

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetGraders

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetImageTag

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetInput

func (u ReinforcementMethodGraderUnionParam) GetInput() (res reinforcementMethodGraderUnionParamInput)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (ReinforcementMethodGraderUnionParam) GetModel

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetName

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetOperation

func (u ReinforcementMethodGraderUnionParam) GetOperation() *string

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetRange

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetReference

func (u ReinforcementMethodGraderUnionParam) GetReference() *string

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetSamplingParams

func (u ReinforcementMethodGraderUnionParam) GetSamplingParams() *any

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetSource

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) GetType

Returns a pointer to the underlying variant's property, if present.

func (ReinforcementMethodGraderUnionParam) MarshalJSON

func (u ReinforcementMethodGraderUnionParam) MarshalJSON() ([]byte, error)

func (*ReinforcementMethodGraderUnionParam) UnmarshalJSON

func (u *ReinforcementMethodGraderUnionParam) UnmarshalJSON(data []byte) error

type ReinforcementMethodParam

type ReinforcementMethodParam struct {
	// The grader used for the fine-tuning job.
	Grader ReinforcementMethodGraderUnionParam `json:"grader,omitzero,required"`
	// The hyperparameters used for the reinforcement fine-tuning job.
	Hyperparameters ReinforcementHyperparameters `json:"hyperparameters,omitzero"`
	// contains filtered or unexported fields
}

Configuration for the reinforcement fine-tuning method.

The property Grader is required.

func (ReinforcementMethodParam) MarshalJSON

func (r ReinforcementMethodParam) MarshalJSON() (data []byte, err error)

func (*ReinforcementMethodParam) UnmarshalJSON

func (r *ReinforcementMethodParam) UnmarshalJSON(data []byte) error

type RequiredActionFunctionToolCall added in v1.1.0

type RequiredActionFunctionToolCall struct {
	// The ID of the tool call. This ID must be referenced when you submit the tool
	// outputs in using the
	// [Submit tool outputs to run](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
	// endpoint.
	ID string `json:"id,required"`
	// The function definition.
	Function RequiredActionFunctionToolCallFunction `json:"function,required"`
	// The type of tool call the output is required for. For now, this is always
	// `function`.
	Type constant.Function `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Function    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Tool call objects

func (RequiredActionFunctionToolCall) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*RequiredActionFunctionToolCall) UnmarshalJSON added in v1.1.0

func (r *RequiredActionFunctionToolCall) UnmarshalJSON(data []byte) error

type RequiredActionFunctionToolCallFunction added in v1.1.0

type RequiredActionFunctionToolCallFunction struct {
	// The arguments that the model expects you to pass to the function.
	Arguments string `json:"arguments,required"`
	// The name of the function.
	Name string `json:"name,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Arguments   respjson.Field
		Name        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The function definition.

func (RequiredActionFunctionToolCallFunction) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*RequiredActionFunctionToolCallFunction) UnmarshalJSON added in v1.1.0

func (r *RequiredActionFunctionToolCallFunction) UnmarshalJSON(data []byte) error

type ResponseFormatJSONObject

type ResponseFormatJSONObject = shared.ResponseFormatJSONObject

JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

This is an alias to an internal type.

type ResponseFormatJSONObjectParam

type ResponseFormatJSONObjectParam = shared.ResponseFormatJSONObjectParam

JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.

This is an alias to an internal type.

type ResponseFormatJSONSchema added in v1.1.0

type ResponseFormatJSONSchema = shared.ResponseFormatJSONSchema

JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).

This is an alias to an internal type.

type ResponseFormatJSONSchemaJSONSchema added in v1.1.0

type ResponseFormatJSONSchemaJSONSchema = shared.ResponseFormatJSONSchemaJSONSchema

Structured Outputs configuration options, including a JSON Schema.

This is an alias to an internal type.

type ResponseFormatJSONSchemaJSONSchemaParam

type ResponseFormatJSONSchemaJSONSchemaParam = shared.ResponseFormatJSONSchemaJSONSchemaParam

Structured Outputs configuration options, including a JSON Schema.

This is an alias to an internal type.

type ResponseFormatJSONSchemaParam

type ResponseFormatJSONSchemaParam = shared.ResponseFormatJSONSchemaParam

JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).

This is an alias to an internal type.

type ResponseFormatText

type ResponseFormatText = shared.ResponseFormatText

Default response format. Used to generate text responses.

This is an alias to an internal type.

type ResponseFormatTextParam

type ResponseFormatTextParam = shared.ResponseFormatTextParam

Default response format. Used to generate text responses.

This is an alias to an internal type.

type ResponsesModel

type ResponsesModel = shared.ResponsesModel

This is an alias to an internal type.

type Run added in v1.1.0

type Run struct {
	// The identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The ID of the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
	// execution of this run.
	AssistantID string `json:"assistant_id,required"`
	// The Unix timestamp (in seconds) for when the run was cancelled.
	CancelledAt int64 `json:"cancelled_at,required"`
	// The Unix timestamp (in seconds) for when the run was completed.
	CompletedAt int64 `json:"completed_at,required"`
	// The Unix timestamp (in seconds) for when the run was created.
	CreatedAt int64 `json:"created_at,required"`
	// The Unix timestamp (in seconds) for when the run will expire.
	ExpiresAt int64 `json:"expires_at,required"`
	// The Unix timestamp (in seconds) for when the run failed.
	FailedAt int64 `json:"failed_at,required"`
	// Details on why the run is incomplete. Will be `null` if the run is not
	// incomplete.
	IncompleteDetails RunIncompleteDetails `json:"incomplete_details,required"`
	// The instructions that the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
	// this run.
	Instructions string `json:"instructions,required"`
	// The last error associated with this run. Will be `null` if there are no errors.
	LastError RunLastError `json:"last_error,required"`
	// The maximum number of completion tokens specified to have been used over the
	// course of the run.
	MaxCompletionTokens int64 `json:"max_completion_tokens,required"`
	// The maximum number of prompt tokens specified to have been used over the course
	// of the run.
	MaxPromptTokens int64 `json:"max_prompt_tokens,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,required"`
	// The model that the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
	// this run.
	Model string `json:"model,required"`
	// The object type, which is always `thread.run`.
	Object constant.ThreadRun `json:"object,required"`
	// Whether to enable
	// [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
	// during tool use.
	ParallelToolCalls bool `json:"parallel_tool_calls,required"`
	// Details on the action required to continue the run. Will be `null` if no action
	// is required.
	RequiredAction RunRequiredAction `json:"required_action,required"`
	// Specifies the format that the model must output. Compatible with
	// [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
	// [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
	// and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
	//
	// Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
	// Outputs which ensures the model will match your supplied JSON schema. Learn more
	// in the
	// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
	//
	// Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
	// message the model generates is valid JSON.
	//
	// **Important:** when using JSON mode, you **must** also instruct the model to
	// produce JSON yourself via a system or user message. Without this, the model may
	// generate an unending stream of whitespace until the generation reaches the token
	// limit, resulting in a long-running and seemingly "stuck" request. Also note that
	// the message content may be partially cut off if `finish_reason="length"`, which
	// indicates the generation exceeded `max_tokens` or the conversation exceeded the
	// max context length.
	ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format,required"`
	// The Unix timestamp (in seconds) for when the run was started.
	StartedAt int64 `json:"started_at,required"`
	// The status of the run, which can be either `queued`, `in_progress`,
	// `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
	// `incomplete`, or `expired`.
	//
	// Any of "queued", "in_progress", "requires_action", "cancelling", "cancelled",
	// "failed", "completed", "incomplete", "expired".
	Status RunStatus `json:"status,required"`
	// The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
	// that was executed on as a part of this run.
	ThreadID string `json:"thread_id,required"`
	// Controls which (if any) tool is called by the model. `none` means the model will
	// not call any tools and instead generates a message. `auto` is the default value
	// and means the model can pick between generating a message or calling one or more
	// tools. `required` means the model must call one or more tools before responding
	// to the user. Specifying a particular tool like `{"type": "file_search"}` or
	// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
	// call that tool.
	ToolChoice AssistantToolChoiceOptionUnion `json:"tool_choice,required"`
	// The list of tools that the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
	// this run.
	Tools []AssistantToolUnion `json:"tools,required"`
	// Controls for how a thread will be truncated prior to the run. Use this to
	// control the intial context window of the run.
	TruncationStrategy RunTruncationStrategy `json:"truncation_strategy,required"`
	// Usage statistics related to the run. This value will be `null` if the run is not
	// in a terminal state (i.e. `in_progress`, `queued`, etc.).
	Usage RunUsage `json:"usage,required"`
	// The sampling temperature used for this run. If not set, defaults to 1.
	Temperature float64 `json:"temperature,nullable"`
	// The nucleus sampling value used for this run. If not set, defaults to 1.
	TopP float64 `json:"top_p,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                  respjson.Field
		AssistantID         respjson.Field
		CancelledAt         respjson.Field
		CompletedAt         respjson.Field
		CreatedAt           respjson.Field
		ExpiresAt           respjson.Field
		FailedAt            respjson.Field
		IncompleteDetails   respjson.Field
		Instructions        respjson.Field
		LastError           respjson.Field
		MaxCompletionTokens respjson.Field
		MaxPromptTokens     respjson.Field
		Metadata            respjson.Field
		Model               respjson.Field
		Object              respjson.Field
		ParallelToolCalls   respjson.Field
		RequiredAction      respjson.Field
		ResponseFormat      respjson.Field
		StartedAt           respjson.Field
		Status              respjson.Field
		ThreadID            respjson.Field
		ToolChoice          respjson.Field
		Tools               respjson.Field
		TruncationStrategy  respjson.Field
		Usage               respjson.Field
		Temperature         respjson.Field
		TopP                respjson.Field
		ExtraFields         map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents an execution run on a [thread](https://platform.openai.com/docs/api-reference/threads).

func (Run) RawJSON added in v1.1.0

func (r Run) RawJSON() string

Returns the unmodified JSON received from the API

func (*Run) UnmarshalJSON added in v1.1.0

func (r *Run) UnmarshalJSON(data []byte) error

type RunIncompleteDetails added in v1.1.0

type RunIncompleteDetails struct {
	// The reason why the run is incomplete. This will point to which specific token
	// limit was reached over the course of the run.
	//
	// Any of "max_completion_tokens", "max_prompt_tokens".
	Reason string `json:"reason"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Reason      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details on why the run is incomplete. Will be `null` if the run is not incomplete.

func (RunIncompleteDetails) RawJSON added in v1.1.0

func (r RunIncompleteDetails) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunIncompleteDetails) UnmarshalJSON added in v1.1.0

func (r *RunIncompleteDetails) UnmarshalJSON(data []byte) error

type RunLastError added in v1.1.0

type RunLastError struct {
	// One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
	//
	// Any of "server_error", "rate_limit_exceeded", "invalid_prompt".
	Code string `json:"code,required"`
	// A human-readable description of the error.
	Message string `json:"message,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The last error associated with this run. Will be `null` if there are no errors.

func (RunLastError) RawJSON added in v1.1.0

func (r RunLastError) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunLastError) UnmarshalJSON added in v1.1.0

func (r *RunLastError) UnmarshalJSON(data []byte) error

type RunRequiredAction added in v1.1.0

type RunRequiredAction struct {
	// Details on the tool outputs needed for this run to continue.
	SubmitToolOutputs RunRequiredActionSubmitToolOutputs `json:"submit_tool_outputs,required"`
	// For now, this is always `submit_tool_outputs`.
	Type constant.SubmitToolOutputs `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		SubmitToolOutputs respjson.Field
		Type              respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details on the action required to continue the run. Will be `null` if no action is required.

func (RunRequiredAction) RawJSON added in v1.1.0

func (r RunRequiredAction) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunRequiredAction) UnmarshalJSON added in v1.1.0

func (r *RunRequiredAction) UnmarshalJSON(data []byte) error

type RunRequiredActionSubmitToolOutputs added in v1.1.0

type RunRequiredActionSubmitToolOutputs struct {
	// A list of the relevant tool calls.
	ToolCalls []RequiredActionFunctionToolCall `json:"tool_calls,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolCalls   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details on the tool outputs needed for this run to continue.

func (RunRequiredActionSubmitToolOutputs) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*RunRequiredActionSubmitToolOutputs) UnmarshalJSON added in v1.1.0

func (r *RunRequiredActionSubmitToolOutputs) UnmarshalJSON(data []byte) error

type RunStatus added in v1.1.0

type RunStatus string

The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

const (
	RunStatusQueued         RunStatus = "queued"
	RunStatusInProgress     RunStatus = "in_progress"
	RunStatusRequiresAction RunStatus = "requires_action"
	RunStatusCancelling     RunStatus = "cancelling"
	RunStatusCancelled      RunStatus = "cancelled"
	RunStatusFailed         RunStatus = "failed"
	RunStatusCompleted      RunStatus = "completed"
	RunStatusIncomplete     RunStatus = "incomplete"
	RunStatusExpired        RunStatus = "expired"
)

type RunStep added in v1.1.0

type RunStep struct {
	// The identifier of the run step, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The ID of the
	// [assistant](https://platform.openai.com/docs/api-reference/assistants)
	// associated with the run step.
	AssistantID string `json:"assistant_id,required"`
	// The Unix timestamp (in seconds) for when the run step was cancelled.
	CancelledAt int64 `json:"cancelled_at,required"`
	// The Unix timestamp (in seconds) for when the run step completed.
	CompletedAt int64 `json:"completed_at,required"`
	// The Unix timestamp (in seconds) for when the run step was created.
	CreatedAt int64 `json:"created_at,required"`
	// The Unix timestamp (in seconds) for when the run step expired. A step is
	// considered expired if the parent run is expired.
	ExpiredAt int64 `json:"expired_at,required"`
	// The Unix timestamp (in seconds) for when the run step failed.
	FailedAt int64 `json:"failed_at,required"`
	// The last error associated with this run step. Will be `null` if there are no
	// errors.
	LastError RunStepLastError `json:"last_error,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,required"`
	// The object type, which is always `thread.run.step`.
	Object constant.ThreadRunStep `json:"object,required"`
	// The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that
	// this run step is a part of.
	RunID string `json:"run_id,required"`
	// The status of the run step, which can be either `in_progress`, `cancelled`,
	// `failed`, `completed`, or `expired`.
	//
	// Any of "in_progress", "cancelled", "failed", "completed", "expired".
	Status RunStepStatus `json:"status,required"`
	// The details of the run step.
	StepDetails RunStepStepDetailsUnion `json:"step_details,required"`
	// The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
	// that was run.
	ThreadID string `json:"thread_id,required"`
	// The type of run step, which can be either `message_creation` or `tool_calls`.
	//
	// Any of "message_creation", "tool_calls".
	Type RunStepType `json:"type,required"`
	// Usage statistics related to the run step. This value will be `null` while the
	// run step's status is `in_progress`.
	Usage RunStepUsage `json:"usage,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		AssistantID respjson.Field
		CancelledAt respjson.Field
		CompletedAt respjson.Field
		CreatedAt   respjson.Field
		ExpiredAt   respjson.Field
		FailedAt    respjson.Field
		LastError   respjson.Field
		Metadata    respjson.Field
		Object      respjson.Field
		RunID       respjson.Field
		Status      respjson.Field
		StepDetails respjson.Field
		ThreadID    respjson.Field
		Type        respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a step in execution of a run.

func (RunStep) RawJSON added in v1.1.0

func (r RunStep) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunStep) UnmarshalJSON added in v1.1.0

func (r *RunStep) UnmarshalJSON(data []byte) error

type RunStepDelta added in v1.1.0

type RunStepDelta struct {
	// The details of the run step.
	StepDetails RunStepDeltaStepDetailsUnion `json:"step_details"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		StepDetails respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The delta containing the fields that have changed on the run step.

func (RunStepDelta) RawJSON added in v1.1.0

func (r RunStepDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunStepDelta) UnmarshalJSON added in v1.1.0

func (r *RunStepDelta) UnmarshalJSON(data []byte) error

type RunStepDeltaEvent added in v1.1.0

type RunStepDeltaEvent struct {
	// The identifier of the run step, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The delta containing the fields that have changed on the run step.
	Delta RunStepDelta `json:"delta,required"`
	// The object type, which is always `thread.run.step.delta`.
	Object constant.ThreadRunStepDelta `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Delta       respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a run step delta i.e. any changed fields on a run step during streaming.

func (RunStepDeltaEvent) RawJSON added in v1.1.0

func (r RunStepDeltaEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunStepDeltaEvent) UnmarshalJSON added in v1.1.0

func (r *RunStepDeltaEvent) UnmarshalJSON(data []byte) error

type RunStepDeltaMessageDelta added in v1.1.0

type RunStepDeltaMessageDelta struct {
	// Always `message_creation`.
	Type            constant.MessageCreation                `json:"type,required"`
	MessageCreation RunStepDeltaMessageDeltaMessageCreation `json:"message_creation"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type            respjson.Field
		MessageCreation respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details of the message creation by the run step.

func (RunStepDeltaMessageDelta) RawJSON added in v1.1.0

func (r RunStepDeltaMessageDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunStepDeltaMessageDelta) UnmarshalJSON added in v1.1.0

func (r *RunStepDeltaMessageDelta) UnmarshalJSON(data []byte) error

type RunStepDeltaMessageDeltaMessageCreation added in v1.1.0

type RunStepDeltaMessageDeltaMessageCreation struct {
	// The ID of the message that was created by this run step.
	MessageID string `json:"message_id"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		MessageID   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (RunStepDeltaMessageDeltaMessageCreation) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*RunStepDeltaMessageDeltaMessageCreation) UnmarshalJSON added in v1.1.0

func (r *RunStepDeltaMessageDeltaMessageCreation) UnmarshalJSON(data []byte) error

type RunStepDeltaStepDetailsUnion added in v1.1.0

type RunStepDeltaStepDetailsUnion struct {
	// Any of "message_creation", "tool_calls".
	Type string `json:"type"`
	// This field is from variant [RunStepDeltaMessageDelta].
	MessageCreation RunStepDeltaMessageDeltaMessageCreation `json:"message_creation"`
	// This field is from variant [ToolCallDeltaObject].
	ToolCalls []ToolCallDeltaUnion `json:"tool_calls"`
	JSON      struct {
		Type            respjson.Field
		MessageCreation respjson.Field
		ToolCalls       respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

RunStepDeltaStepDetailsUnion contains all possible properties and values from RunStepDeltaMessageDelta, ToolCallDeltaObject.

Use the RunStepDeltaStepDetailsUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (RunStepDeltaStepDetailsUnion) AsAny added in v1.1.0

func (u RunStepDeltaStepDetailsUnion) AsAny() anyRunStepDeltaStepDetails

Use the following switch statement to find the correct variant

switch variant := RunStepDeltaStepDetailsUnion.AsAny().(type) {
case openai.RunStepDeltaMessageDelta:
case openai.ToolCallDeltaObject:
default:
  fmt.Errorf("no variant present")
}

func (RunStepDeltaStepDetailsUnion) AsMessageCreation added in v1.1.0

func (u RunStepDeltaStepDetailsUnion) AsMessageCreation() (v RunStepDeltaMessageDelta)

func (RunStepDeltaStepDetailsUnion) AsToolCalls added in v1.1.0

func (RunStepDeltaStepDetailsUnion) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*RunStepDeltaStepDetailsUnion) UnmarshalJSON added in v1.1.0

func (r *RunStepDeltaStepDetailsUnion) UnmarshalJSON(data []byte) error

type RunStepInclude added in v1.1.0

type RunStepInclude string
const (
	RunStepIncludeStepDetailsToolCallsFileSearchResultsContent RunStepInclude = "step_details.tool_calls[*].file_search.results[*].content"
)

type RunStepLastError added in v1.1.0

type RunStepLastError struct {
	// One of `server_error` or `rate_limit_exceeded`.
	//
	// Any of "server_error", "rate_limit_exceeded".
	Code string `json:"code,required"`
	// A human-readable description of the error.
	Message string `json:"message,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The last error associated with this run step. Will be `null` if there are no errors.

func (RunStepLastError) RawJSON added in v1.1.0

func (r RunStepLastError) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunStepLastError) UnmarshalJSON added in v1.1.0

func (r *RunStepLastError) UnmarshalJSON(data []byte) error

type RunStepStatus added in v1.1.0

type RunStepStatus string

The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.

const (
	RunStepStatusInProgress RunStepStatus = "in_progress"
	RunStepStatusCancelled  RunStepStatus = "cancelled"
	RunStepStatusFailed     RunStepStatus = "failed"
	RunStepStatusCompleted  RunStepStatus = "completed"
	RunStepStatusExpired    RunStepStatus = "expired"
)

type RunStepStepDetailsUnion added in v1.1.0

type RunStepStepDetailsUnion struct {
	// This field is from variant [MessageCreationStepDetails].
	MessageCreation MessageCreationStepDetailsMessageCreation `json:"message_creation"`
	// Any of "message_creation", "tool_calls".
	Type string `json:"type"`
	// This field is from variant [ToolCallsStepDetails].
	ToolCalls []ToolCallUnion `json:"tool_calls"`
	JSON      struct {
		MessageCreation respjson.Field
		Type            respjson.Field
		ToolCalls       respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

RunStepStepDetailsUnion contains all possible properties and values from MessageCreationStepDetails, ToolCallsStepDetails.

Use the RunStepStepDetailsUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (RunStepStepDetailsUnion) AsAny added in v1.1.0

func (u RunStepStepDetailsUnion) AsAny() anyRunStepStepDetails

Use the following switch statement to find the correct variant

switch variant := RunStepStepDetailsUnion.AsAny().(type) {
case openai.MessageCreationStepDetails:
case openai.ToolCallsStepDetails:
default:
  fmt.Errorf("no variant present")
}

func (RunStepStepDetailsUnion) AsMessageCreation added in v1.1.0

func (u RunStepStepDetailsUnion) AsMessageCreation() (v MessageCreationStepDetails)

func (RunStepStepDetailsUnion) AsToolCalls added in v1.1.0

func (u RunStepStepDetailsUnion) AsToolCalls() (v ToolCallsStepDetails)

func (RunStepStepDetailsUnion) RawJSON added in v1.1.0

func (u RunStepStepDetailsUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunStepStepDetailsUnion) UnmarshalJSON added in v1.1.0

func (r *RunStepStepDetailsUnion) UnmarshalJSON(data []byte) error

type RunStepType added in v1.1.0

type RunStepType string

The type of run step, which can be either `message_creation` or `tool_calls`.

const (
	RunStepTypeMessageCreation RunStepType = "message_creation"
	RunStepTypeToolCalls       RunStepType = "tool_calls"
)

type RunStepUsage added in v1.1.0

type RunStepUsage struct {
	// Number of completion tokens used over the course of the run step.
	CompletionTokens int64 `json:"completion_tokens,required"`
	// Number of prompt tokens used over the course of the run step.
	PromptTokens int64 `json:"prompt_tokens,required"`
	// Total number of tokens used (prompt + completion).
	TotalTokens int64 `json:"total_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CompletionTokens respjson.Field
		PromptTokens     respjson.Field
		TotalTokens      respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`.

func (RunStepUsage) RawJSON added in v1.1.0

func (r RunStepUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunStepUsage) UnmarshalJSON added in v1.1.0

func (r *RunStepUsage) UnmarshalJSON(data []byte) error

type RunTruncationStrategy added in v1.1.0

type RunTruncationStrategy struct {
	// The truncation strategy to use for the thread. The default is `auto`. If set to
	// `last_messages`, the thread will be truncated to the n most recent messages in
	// the thread. When set to `auto`, messages in the middle of the thread will be
	// dropped to fit the context length of the model, `max_prompt_tokens`.
	//
	// Any of "auto", "last_messages".
	Type string `json:"type,required"`
	// The number of most recent messages from the thread when constructing the context
	// for the run.
	LastMessages int64 `json:"last_messages,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type         respjson.Field
		LastMessages respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run.

func (RunTruncationStrategy) RawJSON added in v1.1.0

func (r RunTruncationStrategy) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunTruncationStrategy) UnmarshalJSON added in v1.1.0

func (r *RunTruncationStrategy) UnmarshalJSON(data []byte) error

type RunUsage added in v1.1.0

type RunUsage struct {
	// Number of completion tokens used over the course of the run.
	CompletionTokens int64 `json:"completion_tokens,required"`
	// Number of prompt tokens used over the course of the run.
	PromptTokens int64 `json:"prompt_tokens,required"`
	// Total number of tokens used (prompt + completion).
	TotalTokens int64 `json:"total_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CompletionTokens respjson.Field
		PromptTokens     respjson.Field
		TotalTokens      respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

func (RunUsage) RawJSON added in v1.1.0

func (r RunUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*RunUsage) UnmarshalJSON added in v1.1.0

func (r *RunUsage) UnmarshalJSON(data []byte) error

type ScoreModelGrader

type ScoreModelGrader struct {
	// The input text. This may include template strings.
	Input []ScoreModelGraderInput `json:"input,required"`
	// The model to use for the evaluation.
	Model string `json:"model,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The object type, which is always `score_model`.
	Type constant.ScoreModel `json:"type,required"`
	// The range of the score. Defaults to `[0, 1]`.
	Range []float64 `json:"range"`
	// The sampling parameters for the model.
	SamplingParams any `json:"sampling_params"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Input          respjson.Field
		Model          respjson.Field
		Name           respjson.Field
		Type           respjson.Field
		Range          respjson.Field
		SamplingParams respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A ScoreModelGrader object that uses a model to assign a score to the input.

func (ScoreModelGrader) RawJSON

func (r ScoreModelGrader) RawJSON() string

Returns the unmodified JSON received from the API

func (ScoreModelGrader) ToParam

ToParam converts this ScoreModelGrader to a ScoreModelGraderParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ScoreModelGraderParam.Overrides()

func (*ScoreModelGrader) UnmarshalJSON

func (r *ScoreModelGrader) UnmarshalJSON(data []byte) error

type ScoreModelGraderInput

type ScoreModelGraderInput struct {
	// Text inputs to the model - can contain template strings.
	Content ScoreModelGraderInputContentUnion `json:"content,required"`
	// The role of the message input. One of `user`, `assistant`, `system`, or
	// `developer`.
	//
	// Any of "user", "assistant", "system", "developer".
	Role string `json:"role,required"`
	// The type of the message input. Always `message`.
	//
	// Any of "message".
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Role        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A message input to the model with a role indicating instruction following hierarchy. Instructions given with the `developer` or `system` role take precedence over instructions given with the `user` role. Messages with the `assistant` role are presumed to have been generated by the model in previous interactions.

func (ScoreModelGraderInput) RawJSON

func (r ScoreModelGraderInput) RawJSON() string

Returns the unmodified JSON received from the API

func (*ScoreModelGraderInput) UnmarshalJSON

func (r *ScoreModelGraderInput) UnmarshalJSON(data []byte) error

type ScoreModelGraderInputContentOutputText

type ScoreModelGraderInputContentOutputText 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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A text output from the model.

func (ScoreModelGraderInputContentOutputText) RawJSON

Returns the unmodified JSON received from the API

func (*ScoreModelGraderInputContentOutputText) UnmarshalJSON

func (r *ScoreModelGraderInputContentOutputText) UnmarshalJSON(data []byte) error

type ScoreModelGraderInputContentOutputTextParam

type ScoreModelGraderInputContentOutputTextParam struct {
	// The text output from the model.
	Text string `json:"text,required"`
	// The type of the output text. Always `output_text`.
	//
	// This field can be elided, and will marshal its zero value as "output_text".
	Type constant.OutputText `json:"type,required"`
	// contains filtered or unexported fields
}

A text output from the model.

The properties Text, Type are required.

func (ScoreModelGraderInputContentOutputTextParam) MarshalJSON

func (r ScoreModelGraderInputContentOutputTextParam) MarshalJSON() (data []byte, err error)

func (*ScoreModelGraderInputContentOutputTextParam) UnmarshalJSON

func (r *ScoreModelGraderInputContentOutputTextParam) UnmarshalJSON(data []byte) error

type ScoreModelGraderInputContentUnion

type ScoreModelGraderInputContentUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	Text     string `json:"text"`
	Type     string `json:"type"`
	JSON     struct {
		OfString respjson.Field
		Text     respjson.Field
		Type     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ScoreModelGraderInputContentUnion contains all possible properties and values from [string], responses.ResponseInputText, ScoreModelGraderInputContentOutputText.

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfString]

func (ScoreModelGraderInputContentUnion) AsInputText

func (ScoreModelGraderInputContentUnion) AsOutputText

func (ScoreModelGraderInputContentUnion) AsString

func (u ScoreModelGraderInputContentUnion) AsString() (v string)

func (ScoreModelGraderInputContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ScoreModelGraderInputContentUnion) UnmarshalJSON

func (r *ScoreModelGraderInputContentUnion) UnmarshalJSON(data []byte) error

type ScoreModelGraderInputContentUnionParam

type ScoreModelGraderInputContentUnionParam struct {
	OfString     param.Opt[string]                            `json:",omitzero,inline"`
	OfInputText  *responses.ResponseInputTextParam            `json:",omitzero,inline"`
	OfOutputText *ScoreModelGraderInputContentOutputTextParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ScoreModelGraderInputContentUnionParam) GetText

Returns a pointer to the underlying variant's property, if present.

func (ScoreModelGraderInputContentUnionParam) GetType

Returns a pointer to the underlying variant's property, if present.

func (ScoreModelGraderInputContentUnionParam) MarshalJSON

func (u ScoreModelGraderInputContentUnionParam) MarshalJSON() ([]byte, error)

func (*ScoreModelGraderInputContentUnionParam) UnmarshalJSON

func (u *ScoreModelGraderInputContentUnionParam) UnmarshalJSON(data []byte) error

type ScoreModelGraderInputParam

type ScoreModelGraderInputParam struct {
	// Text inputs to the model - can contain template strings.
	Content ScoreModelGraderInputContentUnionParam `json:"content,omitzero,required"`
	// The role of the message input. One of `user`, `assistant`, `system`, or
	// `developer`.
	//
	// Any of "user", "assistant", "system", "developer".
	Role string `json:"role,omitzero,required"`
	// The type of the message input. Always `message`.
	//
	// Any of "message".
	Type string `json:"type,omitzero"`
	// contains filtered or unexported fields
}

A message input to the model with a role indicating instruction following hierarchy. Instructions given with the `developer` or `system` role take precedence over instructions given with the `user` role. Messages with the `assistant` role are presumed to have been generated by the model in previous interactions.

The properties Content, Role are required.

func (ScoreModelGraderInputParam) MarshalJSON

func (r ScoreModelGraderInputParam) MarshalJSON() (data []byte, err error)

func (*ScoreModelGraderInputParam) UnmarshalJSON

func (r *ScoreModelGraderInputParam) UnmarshalJSON(data []byte) error

type ScoreModelGraderParam

type ScoreModelGraderParam struct {
	// The input text. This may include template strings.
	Input []ScoreModelGraderInputParam `json:"input,omitzero,required"`
	// The model to use for the evaluation.
	Model string `json:"model,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The range of the score. Defaults to `[0, 1]`.
	Range []float64 `json:"range,omitzero"`
	// The sampling parameters for the model.
	SamplingParams any `json:"sampling_params,omitzero"`
	// The object type, which is always `score_model`.
	//
	// This field can be elided, and will marshal its zero value as "score_model".
	Type constant.ScoreModel `json:"type,required"`
	// contains filtered or unexported fields
}

A ScoreModelGrader object that uses a model to assign a score to the input.

The properties Input, Model, Name, Type are required.

func (ScoreModelGraderParam) MarshalJSON

func (r ScoreModelGraderParam) MarshalJSON() (data []byte, err error)

func (*ScoreModelGraderParam) UnmarshalJSON

func (r *ScoreModelGraderParam) UnmarshalJSON(data []byte) error

type SpeechModel

type SpeechModel = string
const (
	SpeechModelTTS1         SpeechModel = "tts-1"
	SpeechModelTTS1HD       SpeechModel = "tts-1-hd"
	SpeechModelGPT4oMiniTTS SpeechModel = "gpt-4o-mini-tts"
)

type StaticFileChunkingStrategy

type StaticFileChunkingStrategy struct {
	// The number of tokens that overlap between chunks. The default value is `400`.
	//
	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
	// The maximum number of tokens in each chunk. The default value is `800`. The
	// minimum value is `100` and the maximum value is `4096`.
	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ChunkOverlapTokens respjson.Field
		MaxChunkSizeTokens respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (StaticFileChunkingStrategy) RawJSON

func (r StaticFileChunkingStrategy) RawJSON() string

Returns the unmodified JSON received from the API

func (StaticFileChunkingStrategy) ToParam

ToParam converts this StaticFileChunkingStrategy to a StaticFileChunkingStrategyParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with StaticFileChunkingStrategyParam.Overrides()

func (*StaticFileChunkingStrategy) UnmarshalJSON

func (r *StaticFileChunkingStrategy) UnmarshalJSON(data []byte) error

type StaticFileChunkingStrategyObject

type StaticFileChunkingStrategyObject struct {
	Static StaticFileChunkingStrategy `json:"static,required"`
	// Always `static`.
	Type constant.Static `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Static      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (StaticFileChunkingStrategyObject) RawJSON

Returns the unmodified JSON received from the API

func (*StaticFileChunkingStrategyObject) UnmarshalJSON

func (r *StaticFileChunkingStrategyObject) UnmarshalJSON(data []byte) error

type StaticFileChunkingStrategyObjectParam

type StaticFileChunkingStrategyObjectParam struct {
	Static StaticFileChunkingStrategyParam `json:"static,omitzero,required"`
	// Always `static`.
	//
	// This field can be elided, and will marshal its zero value as "static".
	Type constant.Static `json:"type,required"`
	// contains filtered or unexported fields
}

Customize your own chunking strategy by setting chunk size and chunk overlap.

The properties Static, Type are required.

func (StaticFileChunkingStrategyObjectParam) MarshalJSON

func (r StaticFileChunkingStrategyObjectParam) MarshalJSON() (data []byte, err error)

func (*StaticFileChunkingStrategyObjectParam) UnmarshalJSON

func (r *StaticFileChunkingStrategyObjectParam) UnmarshalJSON(data []byte) error

type StaticFileChunkingStrategyParam

type StaticFileChunkingStrategyParam struct {
	// The number of tokens that overlap between chunks. The default value is `400`.
	//
	// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
	ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
	// The maximum number of tokens in each chunk. The default value is `800`. The
	// minimum value is `100` and the maximum value is `4096`.
	MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
	// contains filtered or unexported fields
}

The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.

func (StaticFileChunkingStrategyParam) MarshalJSON

func (r StaticFileChunkingStrategyParam) MarshalJSON() (data []byte, err error)

func (*StaticFileChunkingStrategyParam) UnmarshalJSON

func (r *StaticFileChunkingStrategyParam) UnmarshalJSON(data []byte) error

type StringCheckGrader

type StringCheckGrader struct {
	// The input text. This may include template strings.
	Input string `json:"input,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
	//
	// Any of "eq", "ne", "like", "ilike".
	Operation StringCheckGraderOperation `json:"operation,required"`
	// The reference text. This may include template strings.
	Reference string `json:"reference,required"`
	// The object type, which is always `string_check`.
	Type constant.StringCheck `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Input       respjson.Field
		Name        respjson.Field
		Operation   respjson.Field
		Reference   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.

func (StringCheckGrader) RawJSON

func (r StringCheckGrader) RawJSON() string

Returns the unmodified JSON received from the API

func (StringCheckGrader) ToParam

ToParam converts this StringCheckGrader to a StringCheckGraderParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with StringCheckGraderParam.Overrides()

func (*StringCheckGrader) UnmarshalJSON

func (r *StringCheckGrader) UnmarshalJSON(data []byte) error

type StringCheckGraderOperation

type StringCheckGraderOperation string

The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.

const (
	StringCheckGraderOperationEq    StringCheckGraderOperation = "eq"
	StringCheckGraderOperationNe    StringCheckGraderOperation = "ne"
	StringCheckGraderOperationLike  StringCheckGraderOperation = "like"
	StringCheckGraderOperationIlike StringCheckGraderOperation = "ilike"
)

type StringCheckGraderParam

type StringCheckGraderParam struct {
	// The input text. This may include template strings.
	Input string `json:"input,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
	//
	// Any of "eq", "ne", "like", "ilike".
	Operation StringCheckGraderOperation `json:"operation,omitzero,required"`
	// The reference text. This may include template strings.
	Reference string `json:"reference,required"`
	// The object type, which is always `string_check`.
	//
	// This field can be elided, and will marshal its zero value as "string_check".
	Type constant.StringCheck `json:"type,required"`
	// contains filtered or unexported fields
}

A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.

The properties Input, Name, Operation, Reference, Type are required.

func (StringCheckGraderParam) MarshalJSON

func (r StringCheckGraderParam) MarshalJSON() (data []byte, err error)

func (*StringCheckGraderParam) UnmarshalJSON

func (r *StringCheckGraderParam) UnmarshalJSON(data []byte) error

type SupervisedHyperparameters

type SupervisedHyperparameters struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize SupervisedHyperparametersBatchSizeUnion `json:"batch_size,omitzero"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier SupervisedHyperparametersLearningRateMultiplierUnion `json:"learning_rate_multiplier,omitzero"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs SupervisedHyperparametersNEpochsUnion `json:"n_epochs,omitzero"`
	// contains filtered or unexported fields
}

The hyperparameters used for the fine-tuning job.

func (SupervisedHyperparameters) MarshalJSON

func (r SupervisedHyperparameters) MarshalJSON() (data []byte, err error)

func (*SupervisedHyperparameters) UnmarshalJSON

func (r *SupervisedHyperparameters) UnmarshalJSON(data []byte) error

type SupervisedHyperparametersBatchSizeUnion

type SupervisedHyperparametersBatchSizeUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SupervisedHyperparametersBatchSizeUnion) MarshalJSON

func (u SupervisedHyperparametersBatchSizeUnion) MarshalJSON() ([]byte, error)

func (*SupervisedHyperparametersBatchSizeUnion) UnmarshalJSON

func (u *SupervisedHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error

type SupervisedHyperparametersBatchSizeUnionResp

type SupervisedHyperparametersBatchSizeUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

SupervisedHyperparametersBatchSizeUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (SupervisedHyperparametersBatchSizeUnionResp) AsAuto

func (SupervisedHyperparametersBatchSizeUnionResp) AsInt

func (SupervisedHyperparametersBatchSizeUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*SupervisedHyperparametersBatchSizeUnionResp) UnmarshalJSON

func (r *SupervisedHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error

type SupervisedHyperparametersLearningRateMultiplierUnion

type SupervisedHyperparametersLearningRateMultiplierUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto  constant.Auto      `json:",omitzero,inline"`
	OfFloat param.Opt[float64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SupervisedHyperparametersLearningRateMultiplierUnion) MarshalJSON

func (*SupervisedHyperparametersLearningRateMultiplierUnion) UnmarshalJSON

type SupervisedHyperparametersLearningRateMultiplierUnionResp

type SupervisedHyperparametersLearningRateMultiplierUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	JSON    struct {
		OfAuto  respjson.Field
		OfFloat respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

SupervisedHyperparametersLearningRateMultiplierUnionResp contains all possible properties and values from constant.Auto, [float64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfFloat]

func (SupervisedHyperparametersLearningRateMultiplierUnionResp) AsAuto

func (SupervisedHyperparametersLearningRateMultiplierUnionResp) AsFloat

func (SupervisedHyperparametersLearningRateMultiplierUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*SupervisedHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON

type SupervisedHyperparametersNEpochsUnion

type SupervisedHyperparametersNEpochsUnion struct {
	// Construct this variant with constant.ValueOf[constant.Auto]()
	OfAuto constant.Auto    `json:",omitzero,inline"`
	OfInt  param.Opt[int64] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SupervisedHyperparametersNEpochsUnion) MarshalJSON

func (u SupervisedHyperparametersNEpochsUnion) MarshalJSON() ([]byte, error)

func (*SupervisedHyperparametersNEpochsUnion) UnmarshalJSON

func (u *SupervisedHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error

type SupervisedHyperparametersNEpochsUnionResp

type SupervisedHyperparametersNEpochsUnionResp struct {
	// This field will be present if the value is a [constant.Auto] instead of an
	// object.
	OfAuto constant.Auto `json:",inline"`
	// This field will be present if the value is a [int64] instead of an object.
	OfInt int64 `json:",inline"`
	JSON  struct {
		OfAuto respjson.Field
		OfInt  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

SupervisedHyperparametersNEpochsUnionResp contains all possible properties and values from constant.Auto, [int64].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfAuto OfInt]

func (SupervisedHyperparametersNEpochsUnionResp) AsAuto

func (SupervisedHyperparametersNEpochsUnionResp) AsInt

func (SupervisedHyperparametersNEpochsUnionResp) RawJSON

Returns the unmodified JSON received from the API

func (*SupervisedHyperparametersNEpochsUnionResp) UnmarshalJSON

func (r *SupervisedHyperparametersNEpochsUnionResp) UnmarshalJSON(data []byte) error

type SupervisedHyperparametersResp

type SupervisedHyperparametersResp struct {
	// Number of examples in each batch. A larger batch size means that model
	// parameters are updated less frequently, but with lower variance.
	BatchSize SupervisedHyperparametersBatchSizeUnionResp `json:"batch_size"`
	// Scaling factor for the learning rate. A smaller learning rate may be useful to
	// avoid overfitting.
	LearningRateMultiplier SupervisedHyperparametersLearningRateMultiplierUnionResp `json:"learning_rate_multiplier"`
	// The number of epochs to train the model for. An epoch refers to one full cycle
	// through the training dataset.
	NEpochs SupervisedHyperparametersNEpochsUnionResp `json:"n_epochs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		BatchSize              respjson.Field
		LearningRateMultiplier respjson.Field
		NEpochs                respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The hyperparameters used for the fine-tuning job.

func (SupervisedHyperparametersResp) RawJSON

Returns the unmodified JSON received from the API

func (SupervisedHyperparametersResp) ToParam

ToParam converts this SupervisedHyperparametersResp to a SupervisedHyperparameters.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with SupervisedHyperparameters.Overrides()

func (*SupervisedHyperparametersResp) UnmarshalJSON

func (r *SupervisedHyperparametersResp) UnmarshalJSON(data []byte) error

type SupervisedMethod

type SupervisedMethod struct {
	// The hyperparameters used for the fine-tuning job.
	Hyperparameters SupervisedHyperparametersResp `json:"hyperparameters"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Hyperparameters respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Configuration for the supervised fine-tuning method.

func (SupervisedMethod) RawJSON

func (r SupervisedMethod) RawJSON() string

Returns the unmodified JSON received from the API

func (SupervisedMethod) ToParam

ToParam converts this SupervisedMethod to a SupervisedMethodParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with SupervisedMethodParam.Overrides()

func (*SupervisedMethod) UnmarshalJSON

func (r *SupervisedMethod) UnmarshalJSON(data []byte) error

type SupervisedMethodParam

type SupervisedMethodParam struct {
	// The hyperparameters used for the fine-tuning job.
	Hyperparameters SupervisedHyperparameters `json:"hyperparameters,omitzero"`
	// contains filtered or unexported fields
}

Configuration for the supervised fine-tuning method.

func (SupervisedMethodParam) MarshalJSON

func (r SupervisedMethodParam) MarshalJSON() (data []byte, err error)

func (*SupervisedMethodParam) UnmarshalJSON

func (r *SupervisedMethodParam) UnmarshalJSON(data []byte) error

type Text added in v1.1.0

type Text struct {
	Annotations []AnnotationUnion `json:"annotations,required"`
	// The data that makes up the text.
	Value string `json:"value,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Annotations respjson.Field
		Value       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Text) RawJSON added in v1.1.0

func (r Text) RawJSON() string

Returns the unmodified JSON received from the API

func (*Text) UnmarshalJSON added in v1.1.0

func (r *Text) UnmarshalJSON(data []byte) error

type TextContentBlock added in v1.1.0

type TextContentBlock struct {
	Text Text `json:"text,required"`
	// Always `text`.
	Type constant.Text `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The text content that is part of a message.

func (TextContentBlock) RawJSON added in v1.1.0

func (r TextContentBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*TextContentBlock) UnmarshalJSON added in v1.1.0

func (r *TextContentBlock) UnmarshalJSON(data []byte) error

type TextContentBlockParam added in v1.1.0

type TextContentBlockParam struct {
	// Text content to be sent to the model
	Text string `json:"text,required"`
	// Always `text`.
	//
	// This field can be elided, and will marshal its zero value as "text".
	Type constant.Text `json:"type,required"`
	// contains filtered or unexported fields
}

The text content that is part of a message.

The properties Text, Type are required.

func (TextContentBlockParam) MarshalJSON added in v1.1.0

func (r TextContentBlockParam) MarshalJSON() (data []byte, err error)

func (*TextContentBlockParam) UnmarshalJSON added in v1.1.0

func (r *TextContentBlockParam) UnmarshalJSON(data []byte) error

type TextDelta added in v1.1.0

type TextDelta struct {
	Annotations []AnnotationDeltaUnion `json:"annotations"`
	// The data that makes up the text.
	Value string `json:"value"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Annotations respjson.Field
		Value       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextDelta) RawJSON added in v1.1.0

func (r TextDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*TextDelta) UnmarshalJSON added in v1.1.0

func (r *TextDelta) UnmarshalJSON(data []byte) error

type TextDeltaBlock added in v1.1.0

type TextDeltaBlock struct {
	// The index of the content part in the message.
	Index int64 `json:"index,required"`
	// Always `text`.
	Type constant.Text `json:"type,required"`
	Text TextDelta     `json:"text"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		Text        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The text content that is part of a message.

func (TextDeltaBlock) RawJSON added in v1.1.0

func (r TextDeltaBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*TextDeltaBlock) UnmarshalJSON added in v1.1.0

func (r *TextDeltaBlock) UnmarshalJSON(data []byte) error

type TextSimilarityGrader

type TextSimilarityGrader struct {
	// The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`,
	// `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, or `rouge_l`.
	//
	// Any of "fuzzy_match", "bleu", "gleu", "meteor", "rouge_1", "rouge_2", "rouge_3",
	// "rouge_4", "rouge_5", "rouge_l".
	EvaluationMetric TextSimilarityGraderEvaluationMetric `json:"evaluation_metric,required"`
	// The text being graded.
	Input string `json:"input,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The text being graded against.
	Reference string `json:"reference,required"`
	// The type of grader.
	Type constant.TextSimilarity `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EvaluationMetric respjson.Field
		Input            respjson.Field
		Name             respjson.Field
		Reference        respjson.Field
		Type             respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A TextSimilarityGrader object which grades text based on similarity metrics.

func (TextSimilarityGrader) RawJSON

func (r TextSimilarityGrader) RawJSON() string

Returns the unmodified JSON received from the API

func (TextSimilarityGrader) ToParam

ToParam converts this TextSimilarityGrader to a TextSimilarityGraderParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with TextSimilarityGraderParam.Overrides()

func (*TextSimilarityGrader) UnmarshalJSON

func (r *TextSimilarityGrader) UnmarshalJSON(data []byte) error

type TextSimilarityGraderEvaluationMetric

type TextSimilarityGraderEvaluationMetric string

The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`, `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, or `rouge_l`.

const (
	TextSimilarityGraderEvaluationMetricFuzzyMatch TextSimilarityGraderEvaluationMetric = "fuzzy_match"
	TextSimilarityGraderEvaluationMetricBleu       TextSimilarityGraderEvaluationMetric = "bleu"
	TextSimilarityGraderEvaluationMetricGleu       TextSimilarityGraderEvaluationMetric = "gleu"
	TextSimilarityGraderEvaluationMetricMeteor     TextSimilarityGraderEvaluationMetric = "meteor"
	TextSimilarityGraderEvaluationMetricRouge1     TextSimilarityGraderEvaluationMetric = "rouge_1"
	TextSimilarityGraderEvaluationMetricRouge2     TextSimilarityGraderEvaluationMetric = "rouge_2"
	TextSimilarityGraderEvaluationMetricRouge3     TextSimilarityGraderEvaluationMetric = "rouge_3"
	TextSimilarityGraderEvaluationMetricRouge4     TextSimilarityGraderEvaluationMetric = "rouge_4"
	TextSimilarityGraderEvaluationMetricRouge5     TextSimilarityGraderEvaluationMetric = "rouge_5"
	TextSimilarityGraderEvaluationMetricRougeL     TextSimilarityGraderEvaluationMetric = "rouge_l"
)

type TextSimilarityGraderParam

type TextSimilarityGraderParam struct {
	// The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`,
	// `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, or `rouge_l`.
	//
	// Any of "fuzzy_match", "bleu", "gleu", "meteor", "rouge_1", "rouge_2", "rouge_3",
	// "rouge_4", "rouge_5", "rouge_l".
	EvaluationMetric TextSimilarityGraderEvaluationMetric `json:"evaluation_metric,omitzero,required"`
	// The text being graded.
	Input string `json:"input,required"`
	// The name of the grader.
	Name string `json:"name,required"`
	// The text being graded against.
	Reference string `json:"reference,required"`
	// The type of grader.
	//
	// This field can be elided, and will marshal its zero value as "text_similarity".
	Type constant.TextSimilarity `json:"type,required"`
	// contains filtered or unexported fields
}

A TextSimilarityGrader object which grades text based on similarity metrics.

The properties EvaluationMetric, Input, Name, Reference, Type are required.

func (TextSimilarityGraderParam) MarshalJSON

func (r TextSimilarityGraderParam) MarshalJSON() (data []byte, err error)

func (*TextSimilarityGraderParam) UnmarshalJSON

func (r *TextSimilarityGraderParam) UnmarshalJSON(data []byte) error

type Thread added in v1.1.0

type Thread struct {
	// The identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the thread was created.
	CreatedAt int64 `json:"created_at,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,required"`
	// The object type, which is always `thread`.
	Object constant.Thread `json:"object,required"`
	// A set of resources that are made available to the assistant's tools in this
	// thread. The resources are specific to the type of tool. For example, the
	// `code_interpreter` tool requires a list of file IDs, while the `file_search`
	// tool requires a list of vector store IDs.
	ToolResources ThreadToolResources `json:"tool_resources,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		CreatedAt     respjson.Field
		Metadata      respjson.Field
		Object        respjson.Field
		ToolResources respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a thread that contains [messages](https://platform.openai.com/docs/api-reference/messages).

func (Thread) RawJSON added in v1.1.0

func (r Thread) RawJSON() string

Returns the unmodified JSON received from the API

func (*Thread) UnmarshalJSON added in v1.1.0

func (r *Thread) UnmarshalJSON(data []byte) error

type ThreadDeleted added in v1.1.0

type ThreadDeleted struct {
	ID      string                 `json:"id,required"`
	Deleted bool                   `json:"deleted,required"`
	Object  constant.ThreadDeleted `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ThreadDeleted) RawJSON added in v1.1.0

func (r ThreadDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*ThreadDeleted) UnmarshalJSON added in v1.1.0

func (r *ThreadDeleted) UnmarshalJSON(data []byte) error

type ThreadToolResources added in v1.1.0

type ThreadToolResources struct {
	CodeInterpreter ThreadToolResourcesCodeInterpreter `json:"code_interpreter"`
	FileSearch      ThreadToolResourcesFileSearch      `json:"file_search"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CodeInterpreter respjson.Field
		FileSearch      respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

func (ThreadToolResources) RawJSON added in v1.1.0

func (r ThreadToolResources) RawJSON() string

Returns the unmodified JSON received from the API

func (*ThreadToolResources) UnmarshalJSON added in v1.1.0

func (r *ThreadToolResources) UnmarshalJSON(data []byte) error

type ThreadToolResourcesCodeInterpreter added in v1.1.0

type ThreadToolResourcesCodeInterpreter struct {
	// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
	// available to the `code_interpreter` tool. There can be a maximum of 20 files
	// associated with the tool.
	FileIDs []string `json:"file_ids"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileIDs     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ThreadToolResourcesCodeInterpreter) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ThreadToolResourcesCodeInterpreter) UnmarshalJSON added in v1.1.0

func (r *ThreadToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error

type ThreadToolResourcesFileSearch added in v1.1.0

type ThreadToolResourcesFileSearch struct {
	// The
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// attached to this thread. There can be a maximum of 1 vector store attached to
	// the thread.
	VectorStoreIDs []string `json:"vector_store_ids"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		VectorStoreIDs respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ThreadToolResourcesFileSearch) RawJSON added in v1.1.0

Returns the unmodified JSON received from the API

func (*ThreadToolResourcesFileSearch) UnmarshalJSON added in v1.1.0

func (r *ThreadToolResourcesFileSearch) UnmarshalJSON(data []byte) error

type ToolCallDeltaObject added in v1.1.0

type ToolCallDeltaObject struct {
	// Always `tool_calls`.
	Type constant.ToolCalls `json:"type,required"`
	// An array of tool calls the run step was involved in. These can be associated
	// with one of three types of tools: `code_interpreter`, `file_search`, or
	// `function`.
	ToolCalls []ToolCallDeltaUnion `json:"tool_calls"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ToolCalls   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details of the tool call.

func (ToolCallDeltaObject) RawJSON added in v1.1.0

func (r ToolCallDeltaObject) RawJSON() string

Returns the unmodified JSON received from the API

func (*ToolCallDeltaObject) UnmarshalJSON added in v1.1.0

func (r *ToolCallDeltaObject) UnmarshalJSON(data []byte) error

type ToolCallDeltaUnion added in v1.1.0

type ToolCallDeltaUnion struct {
	Index int64 `json:"index"`
	// Any of "code_interpreter", "file_search", "function".
	Type string `json:"type"`
	ID   string `json:"id"`
	// This field is from variant [CodeInterpreterToolCallDelta].
	CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter `json:"code_interpreter"`
	// This field is from variant [FileSearchToolCallDelta].
	FileSearch any `json:"file_search"`
	// This field is from variant [FunctionToolCallDelta].
	Function FunctionToolCallDeltaFunction `json:"function"`
	JSON     struct {
		Index           respjson.Field
		Type            respjson.Field
		ID              respjson.Field
		CodeInterpreter respjson.Field
		FileSearch      respjson.Field
		Function        respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ToolCallDeltaUnion contains all possible properties and values from CodeInterpreterToolCallDelta, FileSearchToolCallDelta, FunctionToolCallDelta.

Use the ToolCallDeltaUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (ToolCallDeltaUnion) AsAny added in v1.1.0

func (u ToolCallDeltaUnion) AsAny() anyToolCallDelta

Use the following switch statement to find the correct variant

switch variant := ToolCallDeltaUnion.AsAny().(type) {
case openai.CodeInterpreterToolCallDelta:
case openai.FileSearchToolCallDelta:
case openai.FunctionToolCallDelta:
default:
  fmt.Errorf("no variant present")
}

func (ToolCallDeltaUnion) AsCodeInterpreter added in v1.1.0

func (u ToolCallDeltaUnion) AsCodeInterpreter() (v CodeInterpreterToolCallDelta)

func (ToolCallDeltaUnion) AsFileSearch added in v1.1.0

func (u ToolCallDeltaUnion) AsFileSearch() (v FileSearchToolCallDelta)

func (ToolCallDeltaUnion) AsFunction added in v1.1.0

func (u ToolCallDeltaUnion) AsFunction() (v FunctionToolCallDelta)

func (ToolCallDeltaUnion) RawJSON added in v1.1.0

func (u ToolCallDeltaUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*ToolCallDeltaUnion) UnmarshalJSON added in v1.1.0

func (r *ToolCallDeltaUnion) UnmarshalJSON(data []byte) error

type ToolCallUnion added in v1.1.0

type ToolCallUnion struct {
	ID string `json:"id"`
	// This field is from variant [CodeInterpreterToolCall].
	CodeInterpreter CodeInterpreterToolCallCodeInterpreter `json:"code_interpreter"`
	// Any of "code_interpreter", "file_search", "function".
	Type string `json:"type"`
	// This field is from variant [FileSearchToolCall].
	FileSearch FileSearchToolCallFileSearch `json:"file_search"`
	// This field is from variant [FunctionToolCall].
	Function FunctionToolCallFunction `json:"function"`
	JSON     struct {
		ID              respjson.Field
		CodeInterpreter respjson.Field
		Type            respjson.Field
		FileSearch      respjson.Field
		Function        respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ToolCallUnion contains all possible properties and values from CodeInterpreterToolCall, FileSearchToolCall, FunctionToolCall.

Use the ToolCallUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (ToolCallUnion) AsAny added in v1.1.0

func (u ToolCallUnion) AsAny() anyToolCall

Use the following switch statement to find the correct variant

switch variant := ToolCallUnion.AsAny().(type) {
case openai.CodeInterpreterToolCall:
case openai.FileSearchToolCall:
case openai.FunctionToolCall:
default:
  fmt.Errorf("no variant present")
}

func (ToolCallUnion) AsCodeInterpreter added in v1.1.0

func (u ToolCallUnion) AsCodeInterpreter() (v CodeInterpreterToolCall)

func (ToolCallUnion) AsFileSearch added in v1.1.0

func (u ToolCallUnion) AsFileSearch() (v FileSearchToolCall)

func (ToolCallUnion) AsFunction added in v1.1.0

func (u ToolCallUnion) AsFunction() (v FunctionToolCall)

func (ToolCallUnion) RawJSON added in v1.1.0

func (u ToolCallUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*ToolCallUnion) UnmarshalJSON added in v1.1.0

func (r *ToolCallUnion) UnmarshalJSON(data []byte) error

type ToolCallsStepDetails added in v1.1.0

type ToolCallsStepDetails struct {
	// An array of tool calls the run step was involved in. These can be associated
	// with one of three types of tools: `code_interpreter`, `file_search`, or
	// `function`.
	ToolCalls []ToolCallUnion `json:"tool_calls,required"`
	// Always `tool_calls`.
	Type constant.ToolCalls `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolCalls   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details of the tool call.

func (ToolCallsStepDetails) RawJSON added in v1.1.0

func (r ToolCallsStepDetails) RawJSON() string

Returns the unmodified JSON received from the API

func (*ToolCallsStepDetails) UnmarshalJSON added in v1.1.0

func (r *ToolCallsStepDetails) UnmarshalJSON(data []byte) error

type Transcription

type Transcription struct {
	// The transcribed text.
	Text string `json:"text,required"`
	// The log probabilities of the tokens in the transcription. Only returned with the
	// models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
	// to the `include` array.
	Logprobs []TranscriptionLogprob `json:"logprobs"`
	// Token usage statistics for the request.
	Usage TranscriptionUsageUnion `json:"usage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Logprobs    respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Represents a transcription response returned by model, based on the provided input.

func (Transcription) RawJSON

func (r Transcription) RawJSON() string

Returns the unmodified JSON received from the API

func (*Transcription) UnmarshalJSON

func (r *Transcription) UnmarshalJSON(data []byte) error

type TranscriptionInclude

type TranscriptionInclude string
const (
	TranscriptionIncludeLogprobs TranscriptionInclude = "logprobs"
)

type TranscriptionLogprob

type TranscriptionLogprob struct {
	// The token in the transcription.
	Token string `json:"token"`
	// The bytes of the token.
	Bytes []float64 `json:"bytes"`
	// The log probability of the token.
	Logprob float64 `json:"logprob"`
	// 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
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TranscriptionLogprob) RawJSON

func (r TranscriptionLogprob) RawJSON() string

Returns the unmodified JSON received from the API

func (*TranscriptionLogprob) UnmarshalJSON

func (r *TranscriptionLogprob) UnmarshalJSON(data []byte) error

type TranscriptionStreamEventUnion

type TranscriptionStreamEventUnion struct {
	// This field is from variant [TranscriptionTextDeltaEvent].
	Delta string `json:"delta"`
	// Any of "transcript.text.delta", "transcript.text.done".
	Type string `json:"type"`
	// This field is a union of [[]TranscriptionTextDeltaEventLogprob],
	// [[]TranscriptionTextDoneEventLogprob]
	Logprobs TranscriptionStreamEventUnionLogprobs `json:"logprobs"`
	// This field is from variant [TranscriptionTextDoneEvent].
	Text string `json:"text"`
	// This field is from variant [TranscriptionTextDoneEvent].
	Usage TranscriptionTextDoneEventUsage `json:"usage"`
	JSON  struct {
		Delta    respjson.Field
		Type     respjson.Field
		Logprobs respjson.Field
		Text     respjson.Field
		Usage    respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

TranscriptionStreamEventUnion contains all possible properties and values from TranscriptionTextDeltaEvent, TranscriptionTextDoneEvent.

Use the TranscriptionStreamEventUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (TranscriptionStreamEventUnion) AsAny

func (u TranscriptionStreamEventUnion) AsAny() anyTranscriptionStreamEvent

Use the following switch statement to find the correct variant

switch variant := TranscriptionStreamEventUnion.AsAny().(type) {
case openai.TranscriptionTextDeltaEvent:
case openai.TranscriptionTextDoneEvent:
default:
  fmt.Errorf("no variant present")
}

func (TranscriptionStreamEventUnion) AsTranscriptTextDelta

func (u TranscriptionStreamEventUnion) AsTranscriptTextDelta() (v TranscriptionTextDeltaEvent)

func (TranscriptionStreamEventUnion) AsTranscriptTextDone

func (u TranscriptionStreamEventUnion) AsTranscriptTextDone() (v TranscriptionTextDoneEvent)

func (TranscriptionStreamEventUnion) RawJSON

Returns the unmodified JSON received from the API

func (*TranscriptionStreamEventUnion) UnmarshalJSON

func (r *TranscriptionStreamEventUnion) UnmarshalJSON(data []byte) error

type TranscriptionStreamEventUnionLogprobs

type TranscriptionStreamEventUnionLogprobs struct {
	// This field will be present if the value is a
	// [[]TranscriptionTextDeltaEventLogprob] instead of an object.
	OfTranscriptionTextDeltaEventLogprobs []TranscriptionTextDeltaEventLogprob `json:",inline"`
	// This field will be present if the value is a
	// [[]TranscriptionTextDoneEventLogprob] instead of an object.
	OfTranscriptionTextDoneEventLogprobs []TranscriptionTextDoneEventLogprob `json:",inline"`
	JSON                                 struct {
		OfTranscriptionTextDeltaEventLogprobs respjson.Field
		OfTranscriptionTextDoneEventLogprobs  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

TranscriptionStreamEventUnionLogprobs is an implicit subunion of TranscriptionStreamEventUnion. TranscriptionStreamEventUnionLogprobs provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the TranscriptionStreamEventUnion.

If the underlying value is not a json object, one of the following properties will be valid: OfTranscriptionTextDeltaEventLogprobs OfTranscriptionTextDoneEventLogprobs]

func (*TranscriptionStreamEventUnionLogprobs) UnmarshalJSON

func (r *TranscriptionStreamEventUnionLogprobs) UnmarshalJSON(data []byte) error

type TranscriptionTextDeltaEvent

type TranscriptionTextDeltaEvent struct {
	// The text delta that was additionally transcribed.
	Delta string `json:"delta,required"`
	// The type of the event. Always `transcript.text.delta`.
	Type constant.TranscriptTextDelta `json:"type,required"`
	// The log probabilities of the delta. Only included if you
	// [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
	// with the `include[]` parameter set to `logprobs`.
	Logprobs []TranscriptionTextDeltaEventLogprob `json:"logprobs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta       respjson.Field
		Type        respjson.Field
		Logprobs    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.

func (TranscriptionTextDeltaEvent) RawJSON

func (r TranscriptionTextDeltaEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*TranscriptionTextDeltaEvent) UnmarshalJSON

func (r *TranscriptionTextDeltaEvent) UnmarshalJSON(data []byte) error

type TranscriptionTextDeltaEventLogprob

type TranscriptionTextDeltaEventLogprob struct {
	// The token that was used to generate the log probability.
	Token string `json:"token"`
	// The bytes that were used to generate the log probability.
	Bytes []int64 `json:"bytes"`
	// The log probability of the token.
	Logprob float64 `json:"logprob"`
	// 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
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TranscriptionTextDeltaEventLogprob) RawJSON

Returns the unmodified JSON received from the API

func (*TranscriptionTextDeltaEventLogprob) UnmarshalJSON

func (r *TranscriptionTextDeltaEventLogprob) UnmarshalJSON(data []byte) error

type TranscriptionTextDoneEvent

type TranscriptionTextDoneEvent struct {
	// The text that was transcribed.
	Text string `json:"text,required"`
	// The type of the event. Always `transcript.text.done`.
	Type constant.TranscriptTextDone `json:"type,required"`
	// The log probabilities of the individual tokens in the transcription. Only
	// included if you
	// [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
	// with the `include[]` parameter set to `logprobs`.
	Logprobs []TranscriptionTextDoneEventLogprob `json:"logprobs"`
	// Usage statistics for models billed by token usage.
	Usage TranscriptionTextDoneEventUsage `json:"usage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		Logprobs    respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.

func (TranscriptionTextDoneEvent) RawJSON

func (r TranscriptionTextDoneEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*TranscriptionTextDoneEvent) UnmarshalJSON

func (r *TranscriptionTextDoneEvent) UnmarshalJSON(data []byte) error

type TranscriptionTextDoneEventLogprob

type TranscriptionTextDoneEventLogprob struct {
	// The token that was used to generate the log probability.
	Token string `json:"token"`
	// The bytes that were used to generate the log probability.
	Bytes []int64 `json:"bytes"`
	// The log probability of the token.
	Logprob float64 `json:"logprob"`
	// 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
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TranscriptionTextDoneEventLogprob) RawJSON

Returns the unmodified JSON received from the API

func (*TranscriptionTextDoneEventLogprob) UnmarshalJSON

func (r *TranscriptionTextDoneEventLogprob) UnmarshalJSON(data []byte) error

type TranscriptionTextDoneEventUsage added in v1.7.0

type TranscriptionTextDoneEventUsage struct {
	// Number of input tokens billed for this request.
	InputTokens int64 `json:"input_tokens,required"`
	// Number of output tokens generated.
	OutputTokens int64 `json:"output_tokens,required"`
	// Total number of tokens used (input + output).
	TotalTokens int64 `json:"total_tokens,required"`
	// The type of the usage object. Always `tokens` for this variant.
	Type constant.Tokens `json:"type,required"`
	// Details about the input tokens billed for this request.
	InputTokenDetails TranscriptionTextDoneEventUsageInputTokenDetails `json:"input_token_details"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputTokens       respjson.Field
		OutputTokens      respjson.Field
		TotalTokens       respjson.Field
		Type              respjson.Field
		InputTokenDetails respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Usage statistics for models billed by token usage.

func (TranscriptionTextDoneEventUsage) RawJSON added in v1.7.0

Returns the unmodified JSON received from the API

func (*TranscriptionTextDoneEventUsage) UnmarshalJSON added in v1.7.0

func (r *TranscriptionTextDoneEventUsage) UnmarshalJSON(data []byte) error

type TranscriptionTextDoneEventUsageInputTokenDetails added in v1.7.0

type TranscriptionTextDoneEventUsageInputTokenDetails struct {
	// Number of audio tokens billed for this request.
	AudioTokens int64 `json:"audio_tokens"`
	// Number of text tokens billed for this request.
	TextTokens int64 `json:"text_tokens"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AudioTokens respjson.Field
		TextTokens  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the input tokens billed for this request.

func (TranscriptionTextDoneEventUsageInputTokenDetails) RawJSON added in v1.7.0

Returns the unmodified JSON received from the API

func (*TranscriptionTextDoneEventUsageInputTokenDetails) UnmarshalJSON added in v1.7.0

type TranscriptionUsageDuration added in v1.7.0

type TranscriptionUsageDuration struct {
	// Duration of the input audio in seconds.
	Duration float64 `json:"duration,required"`
	// The type of the usage object. Always `duration` for this variant.
	Type constant.Duration `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Duration    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Usage statistics for models billed by audio input duration.

func (TranscriptionUsageDuration) RawJSON added in v1.7.0

func (r TranscriptionUsageDuration) RawJSON() string

Returns the unmodified JSON received from the API

func (*TranscriptionUsageDuration) UnmarshalJSON added in v1.7.0

func (r *TranscriptionUsageDuration) UnmarshalJSON(data []byte) error

type TranscriptionUsageTokens added in v1.7.0

type TranscriptionUsageTokens struct {
	// Number of input tokens billed for this request.
	InputTokens int64 `json:"input_tokens,required"`
	// Number of output tokens generated.
	OutputTokens int64 `json:"output_tokens,required"`
	// Total number of tokens used (input + output).
	TotalTokens int64 `json:"total_tokens,required"`
	// The type of the usage object. Always `tokens` for this variant.
	Type constant.Tokens `json:"type,required"`
	// Details about the input tokens billed for this request.
	InputTokenDetails TranscriptionUsageTokensInputTokenDetails `json:"input_token_details"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputTokens       respjson.Field
		OutputTokens      respjson.Field
		TotalTokens       respjson.Field
		Type              respjson.Field
		InputTokenDetails respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Usage statistics for models billed by token usage.

func (TranscriptionUsageTokens) RawJSON added in v1.7.0

func (r TranscriptionUsageTokens) RawJSON() string

Returns the unmodified JSON received from the API

func (*TranscriptionUsageTokens) UnmarshalJSON added in v1.7.0

func (r *TranscriptionUsageTokens) UnmarshalJSON(data []byte) error

type TranscriptionUsageTokensInputTokenDetails added in v1.7.0

type TranscriptionUsageTokensInputTokenDetails struct {
	// Number of audio tokens billed for this request.
	AudioTokens int64 `json:"audio_tokens"`
	// Number of text tokens billed for this request.
	TextTokens int64 `json:"text_tokens"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AudioTokens respjson.Field
		TextTokens  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Details about the input tokens billed for this request.

func (TranscriptionUsageTokensInputTokenDetails) RawJSON added in v1.7.0

Returns the unmodified JSON received from the API

func (*TranscriptionUsageTokensInputTokenDetails) UnmarshalJSON added in v1.7.0

func (r *TranscriptionUsageTokensInputTokenDetails) UnmarshalJSON(data []byte) error

type TranscriptionUsageUnion added in v1.7.0

type TranscriptionUsageUnion struct {
	// This field is from variant [TranscriptionUsageTokens].
	InputTokens int64 `json:"input_tokens"`
	// This field is from variant [TranscriptionUsageTokens].
	OutputTokens int64 `json:"output_tokens"`
	// This field is from variant [TranscriptionUsageTokens].
	TotalTokens int64 `json:"total_tokens"`
	// Any of "tokens", "duration".
	Type string `json:"type"`
	// This field is from variant [TranscriptionUsageTokens].
	InputTokenDetails TranscriptionUsageTokensInputTokenDetails `json:"input_token_details"`
	// This field is from variant [TranscriptionUsageDuration].
	Duration float64 `json:"duration"`
	JSON     struct {
		InputTokens       respjson.Field
		OutputTokens      respjson.Field
		TotalTokens       respjson.Field
		Type              respjson.Field
		InputTokenDetails respjson.Field
		Duration          respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

TranscriptionUsageUnion contains all possible properties and values from TranscriptionUsageTokens, TranscriptionUsageDuration.

Use the TranscriptionUsageUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (TranscriptionUsageUnion) AsAny added in v1.7.0

func (u TranscriptionUsageUnion) AsAny() anyTranscriptionUsage

Use the following switch statement to find the correct variant

switch variant := TranscriptionUsageUnion.AsAny().(type) {
case openai.TranscriptionUsageTokens:
case openai.TranscriptionUsageDuration:
default:
  fmt.Errorf("no variant present")
}

func (TranscriptionUsageUnion) AsDuration added in v1.7.0

func (TranscriptionUsageUnion) AsTokens added in v1.7.0

func (TranscriptionUsageUnion) RawJSON added in v1.7.0

func (u TranscriptionUsageUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*TranscriptionUsageUnion) UnmarshalJSON added in v1.7.0

func (r *TranscriptionUsageUnion) UnmarshalJSON(data []byte) error

type Translation

type Translation struct {
	Text string `json:"text,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Translation) RawJSON

func (r Translation) RawJSON() string

Returns the unmodified JSON received from the API

func (*Translation) UnmarshalJSON

func (r *Translation) UnmarshalJSON(data []byte) error

type Upload

type Upload struct {
	// The Upload unique identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The intended number of bytes to be uploaded.
	Bytes int64 `json:"bytes,required"`
	// The Unix timestamp (in seconds) for when the Upload was created.
	CreatedAt int64 `json:"created_at,required"`
	// The Unix timestamp (in seconds) for when the Upload will expire.
	ExpiresAt int64 `json:"expires_at,required"`
	// The name of the file to be uploaded.
	Filename string `json:"filename,required"`
	// The object type, which is always "upload".
	Object constant.Upload `json:"object,required"`
	// The intended purpose of the file.
	// [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose)
	// for acceptable values.
	Purpose string `json:"purpose,required"`
	// The status of the Upload.
	//
	// Any of "pending", "completed", "cancelled", "expired".
	Status UploadStatus `json:"status,required"`
	// The `File` object represents a document that has been uploaded to OpenAI.
	File FileObject `json:"file,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Bytes       respjson.Field
		CreatedAt   respjson.Field
		ExpiresAt   respjson.Field
		Filename    respjson.Field
		Object      respjson.Field
		Purpose     respjson.Field
		Status      respjson.Field
		File        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The Upload object can accept byte chunks in the form of Parts.

func (Upload) RawJSON

func (r Upload) RawJSON() string

Returns the unmodified JSON received from the API

func (*Upload) UnmarshalJSON

func (r *Upload) UnmarshalJSON(data []byte) error

type UploadCompleteParams

type UploadCompleteParams struct {
	// The ordered list of Part IDs.
	PartIDs []string `json:"part_ids,omitzero,required"`
	// The optional md5 checksum for the file contents to verify if the bytes uploaded
	// matches what you expect.
	Md5 param.Opt[string] `json:"md5,omitzero"`
	// contains filtered or unexported fields
}

func (UploadCompleteParams) MarshalJSON

func (r UploadCompleteParams) MarshalJSON() (data []byte, err error)

func (*UploadCompleteParams) UnmarshalJSON

func (r *UploadCompleteParams) UnmarshalJSON(data []byte) error

type UploadNewParams

type UploadNewParams struct {
	// The number of bytes in the file you are uploading.
	Bytes int64 `json:"bytes,required"`
	// The name of the file to upload.
	Filename string `json:"filename,required"`
	// The MIME type of the file.
	//
	// This must fall within the supported MIME types for your file purpose. See the
	// supported MIME types for assistants and vision.
	MimeType string `json:"mime_type,required"`
	// The intended purpose of the uploaded file.
	//
	// See the
	// [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose).
	//
	// Any of "assistants", "batch", "fine-tune", "vision", "user_data", "evals".
	Purpose FilePurpose `json:"purpose,omitzero,required"`
	// contains filtered or unexported fields
}

func (UploadNewParams) MarshalJSON

func (r UploadNewParams) MarshalJSON() (data []byte, err error)

func (*UploadNewParams) UnmarshalJSON

func (r *UploadNewParams) UnmarshalJSON(data []byte) error

type UploadPart

type UploadPart struct {
	// The upload Part unique identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the Part was created.
	CreatedAt int64 `json:"created_at,required"`
	// The object type, which is always `upload.part`.
	Object constant.UploadPart `json:"object,required"`
	// The ID of the Upload object that this Part was added to.
	UploadID string `json:"upload_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Object      respjson.Field
		UploadID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The upload Part represents a chunk of bytes we can add to an Upload object.

func (UploadPart) RawJSON

func (r UploadPart) RawJSON() string

Returns the unmodified JSON received from the API

func (*UploadPart) UnmarshalJSON

func (r *UploadPart) UnmarshalJSON(data []byte) error

type UploadPartNewParams

type UploadPartNewParams struct {
	// The chunk of bytes for this Part.
	Data io.Reader `json:"data,omitzero,required" format:"binary"`
	// contains filtered or unexported fields
}

func (UploadPartNewParams) MarshalMultipart

func (r UploadPartNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type UploadPartService

type UploadPartService struct {
	Options []option.RequestOption
}

UploadPartService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUploadPartService method instead.

func NewUploadPartService

func NewUploadPartService(opts ...option.RequestOption) (r UploadPartService)

NewUploadPartService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*UploadPartService) New

func (r *UploadPartService) New(ctx context.Context, uploadID string, body UploadPartNewParams, opts ...option.RequestOption) (res *UploadPart, err error)

Adds 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.

Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.

It 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).

type UploadService

type UploadService struct {
	Options []option.RequestOption
	Parts   UploadPartService
}

UploadService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUploadService method instead.

func NewUploadService

func NewUploadService(opts ...option.RequestOption) (r UploadService)

NewUploadService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*UploadService) Cancel

func (r *UploadService) Cancel(ctx context.Context, uploadID string, opts ...option.RequestOption) (res *Upload, err error)

Cancels the Upload. No Parts may be added after an Upload is cancelled.

func (*UploadService) Complete

func (r *UploadService) Complete(ctx context.Context, uploadID string, body UploadCompleteParams, opts ...option.RequestOption) (res *Upload, err error)

Completes the Upload(https://platform.openai.com/docs/api-reference/uploads/object).

Within the returned Upload object, there is a nested File(https://platform.openai.com/docs/api-reference/files/object) object that is ready to use in the rest of the platform.

You can specify the order of the Parts by passing in an ordered list of the Part IDs.

The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.

func (*UploadService) New

func (r *UploadService) New(ctx context.Context, body UploadNewParams, opts ...option.RequestOption) (res *Upload, err error)

Creates an intermediate Upload(https://platform.openai.com/docs/api-reference/uploads/object) object that you can add [Parts](https://platform.openai.com/docs/api-reference/uploads/part-object) to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it.

Once you complete the Upload, we will create a File(https://platform.openai.com/docs/api-reference/files/object) object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object.

For certain `purpose` values, the correct `mime_type` must be specified. Please refer to documentation for the [supported MIME types for your use case](https://platform.openai.com/docs/assistants/tools/file-search#supported-files).

For guidance on the proper filename extensions for each purpose, please follow the documentation on [creating a File](https://platform.openai.com/docs/api-reference/files/create).

type UploadStatus

type UploadStatus string

The status of the Upload.

const (
	UploadStatusPending   UploadStatus = "pending"
	UploadStatusCompleted UploadStatus = "completed"
	UploadStatusCancelled UploadStatus = "cancelled"
	UploadStatusExpired   UploadStatus = "expired"
)

type VectorStore

type VectorStore struct {
	// The identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the vector store was created.
	CreatedAt  int64                 `json:"created_at,required"`
	FileCounts VectorStoreFileCounts `json:"file_counts,required"`
	// The Unix timestamp (in seconds) for when the vector store was last active.
	LastActiveAt int64 `json:"last_active_at,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,required"`
	// The name of the vector store.
	Name string `json:"name,required"`
	// The object type, which is always `vector_store`.
	Object constant.VectorStore `json:"object,required"`
	// The status of the vector store, which can be either `expired`, `in_progress`, or
	// `completed`. A status of `completed` indicates that the vector store is ready
	// for use.
	//
	// Any of "expired", "in_progress", "completed".
	Status VectorStoreStatus `json:"status,required"`
	// The total number of bytes used by the files in the vector store.
	UsageBytes int64 `json:"usage_bytes,required"`
	// The expiration policy for a vector store.
	ExpiresAfter VectorStoreExpiresAfter `json:"expires_after"`
	// The Unix timestamp (in seconds) for when the vector store will expire.
	ExpiresAt int64 `json:"expires_at,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CreatedAt    respjson.Field
		FileCounts   respjson.Field
		LastActiveAt respjson.Field
		Metadata     respjson.Field
		Name         respjson.Field
		Object       respjson.Field
		Status       respjson.Field
		UsageBytes   respjson.Field
		ExpiresAfter respjson.Field
		ExpiresAt    respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A vector store is a collection of processed files can be used by the `file_search` tool.

func (VectorStore) RawJSON

func (r VectorStore) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStore) UnmarshalJSON

func (r *VectorStore) UnmarshalJSON(data []byte) error

type VectorStoreDeleted

type VectorStoreDeleted struct {
	ID      string                      `json:"id,required"`
	Deleted bool                        `json:"deleted,required"`
	Object  constant.VectorStoreDeleted `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (VectorStoreDeleted) RawJSON

func (r VectorStoreDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreDeleted) UnmarshalJSON

func (r *VectorStoreDeleted) UnmarshalJSON(data []byte) error

type VectorStoreExpiresAfter

type VectorStoreExpiresAfter struct {
	// Anchor timestamp after which the expiration policy applies. Supported anchors:
	// `last_active_at`.
	Anchor constant.LastActiveAt `json:"anchor,required"`
	// The number of days after the anchor time that the vector store will expire.
	Days int64 `json:"days,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Anchor      respjson.Field
		Days        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The expiration policy for a vector store.

func (VectorStoreExpiresAfter) RawJSON

func (r VectorStoreExpiresAfter) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreExpiresAfter) UnmarshalJSON

func (r *VectorStoreExpiresAfter) UnmarshalJSON(data []byte) error

type VectorStoreFile

type VectorStoreFile struct {
	// The identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the vector store file was created.
	CreatedAt int64 `json:"created_at,required"`
	// The last error associated with this vector store file. Will be `null` if there
	// are no errors.
	LastError VectorStoreFileLastError `json:"last_error,required"`
	// The object type, which is always `vector_store.file`.
	Object constant.VectorStoreFile `json:"object,required"`
	// The status of the vector store file, which can be either `in_progress`,
	// `completed`, `cancelled`, or `failed`. The status `completed` indicates that the
	// vector store file is ready for use.
	//
	// Any of "in_progress", "completed", "cancelled", "failed".
	Status VectorStoreFileStatus `json:"status,required"`
	// The total vector store usage in bytes. Note that this may be different from the
	// original file size.
	UsageBytes int64 `json:"usage_bytes,required"`
	// The ID of the
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// that the [File](https://platform.openai.com/docs/api-reference/files) is
	// attached to.
	VectorStoreID string `json:"vector_store_id,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard. Keys are strings with a maximum
	// length of 64 characters. Values are strings with a maximum length of 512
	// characters, booleans, or numbers.
	Attributes map[string]VectorStoreFileAttributeUnion `json:"attributes,nullable"`
	// The strategy used to chunk the file.
	ChunkingStrategy FileChunkingStrategyUnion `json:"chunking_strategy"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID               respjson.Field
		CreatedAt        respjson.Field
		LastError        respjson.Field
		Object           respjson.Field
		Status           respjson.Field
		UsageBytes       respjson.Field
		VectorStoreID    respjson.Field
		Attributes       respjson.Field
		ChunkingStrategy respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A list of files attached to a vector store.

func (VectorStoreFile) RawJSON

func (r VectorStoreFile) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreFile) UnmarshalJSON

func (r *VectorStoreFile) UnmarshalJSON(data []byte) error

type VectorStoreFileAttributeUnion

type VectorStoreFileAttributeUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	// This field will be present if the value is a [bool] instead of an object.
	OfBool bool `json:",inline"`
	JSON   struct {
		OfString respjson.Field
		OfFloat  respjson.Field
		OfBool   respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

VectorStoreFileAttributeUnion contains all possible properties and values from [string], [float64], [bool].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfString OfFloat OfBool]

func (VectorStoreFileAttributeUnion) AsBool

func (u VectorStoreFileAttributeUnion) AsBool() (v bool)

func (VectorStoreFileAttributeUnion) AsFloat

func (u VectorStoreFileAttributeUnion) AsFloat() (v float64)

func (VectorStoreFileAttributeUnion) AsString

func (u VectorStoreFileAttributeUnion) AsString() (v string)

func (VectorStoreFileAttributeUnion) RawJSON

Returns the unmodified JSON received from the API

func (*VectorStoreFileAttributeUnion) UnmarshalJSON

func (r *VectorStoreFileAttributeUnion) UnmarshalJSON(data []byte) error

type VectorStoreFileBatch

type VectorStoreFileBatch struct {
	// The identifier, which can be referenced in API endpoints.
	ID string `json:"id,required"`
	// The Unix timestamp (in seconds) for when the vector store files batch was
	// created.
	CreatedAt  int64                          `json:"created_at,required"`
	FileCounts VectorStoreFileBatchFileCounts `json:"file_counts,required"`
	// The object type, which is always `vector_store.file_batch`.
	Object constant.VectorStoreFilesBatch `json:"object,required"`
	// The status of the vector store files batch, which can be either `in_progress`,
	// `completed`, `cancelled` or `failed`.
	//
	// Any of "in_progress", "completed", "cancelled", "failed".
	Status VectorStoreFileBatchStatus `json:"status,required"`
	// The ID of the
	// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
	// that the [File](https://platform.openai.com/docs/api-reference/files) is
	// attached to.
	VectorStoreID string `json:"vector_store_id,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		CreatedAt     respjson.Field
		FileCounts    respjson.Field
		Object        respjson.Field
		Status        respjson.Field
		VectorStoreID respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A batch of files attached to a vector store.

func (VectorStoreFileBatch) RawJSON

func (r VectorStoreFileBatch) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreFileBatch) UnmarshalJSON

func (r *VectorStoreFileBatch) UnmarshalJSON(data []byte) error

type VectorStoreFileBatchFileCounts

type VectorStoreFileBatchFileCounts struct {
	// The number of files that where cancelled.
	Cancelled int64 `json:"cancelled,required"`
	// The number of files that have been processed.
	Completed int64 `json:"completed,required"`
	// The number of files that have failed to process.
	Failed int64 `json:"failed,required"`
	// The number of files that are currently being processed.
	InProgress int64 `json:"in_progress,required"`
	// The total number of files.
	Total int64 `json:"total,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Cancelled   respjson.Field
		Completed   respjson.Field
		Failed      respjson.Field
		InProgress  respjson.Field
		Total       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (VectorStoreFileBatchFileCounts) RawJSON

Returns the unmodified JSON received from the API

func (*VectorStoreFileBatchFileCounts) UnmarshalJSON

func (r *VectorStoreFileBatchFileCounts) UnmarshalJSON(data []byte) error

type VectorStoreFileBatchListFilesParams

type VectorStoreFileBatchListFilesParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A cursor for use in pagination. `before` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// starting with obj_foo, your subsequent call can include before=obj_foo in order
	// to fetch the previous page of the list.
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
	//
	// Any of "in_progress", "completed", "failed", "cancelled".
	Filter VectorStoreFileBatchListFilesParamsFilter `query:"filter,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order VectorStoreFileBatchListFilesParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (VectorStoreFileBatchListFilesParams) URLQuery

func (r VectorStoreFileBatchListFilesParams) URLQuery() (v url.Values, err error)

URLQuery serializes VectorStoreFileBatchListFilesParams's query parameters as `url.Values`.

type VectorStoreFileBatchListFilesParamsFilter

type VectorStoreFileBatchListFilesParamsFilter string

Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.

const (
	VectorStoreFileBatchListFilesParamsFilterInProgress VectorStoreFileBatchListFilesParamsFilter = "in_progress"
	VectorStoreFileBatchListFilesParamsFilterCompleted  VectorStoreFileBatchListFilesParamsFilter = "completed"
	VectorStoreFileBatchListFilesParamsFilterFailed     VectorStoreFileBatchListFilesParamsFilter = "failed"
	VectorStoreFileBatchListFilesParamsFilterCancelled  VectorStoreFileBatchListFilesParamsFilter = "cancelled"
)

type VectorStoreFileBatchListFilesParamsOrder

type VectorStoreFileBatchListFilesParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	VectorStoreFileBatchListFilesParamsOrderAsc  VectorStoreFileBatchListFilesParamsOrder = "asc"
	VectorStoreFileBatchListFilesParamsOrderDesc VectorStoreFileBatchListFilesParamsOrder = "desc"
)

type VectorStoreFileBatchNewParams

type VectorStoreFileBatchNewParams struct {
	// A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
	// the vector store should use. Useful for tools like `file_search` that can access
	// files.
	FileIDs []string `json:"file_ids,omitzero,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard. Keys are strings with a maximum
	// length of 64 characters. Values are strings with a maximum length of 512
	// characters, booleans, or numbers.
	Attributes map[string]VectorStoreFileBatchNewParamsAttributeUnion `json:"attributes,omitzero"`
	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
	// strategy. Only applicable if `file_ids` is non-empty.
	ChunkingStrategy FileChunkingStrategyParamUnion `json:"chunking_strategy,omitzero"`
	// contains filtered or unexported fields
}

func (VectorStoreFileBatchNewParams) MarshalJSON

func (r VectorStoreFileBatchNewParams) MarshalJSON() (data []byte, err error)

func (*VectorStoreFileBatchNewParams) UnmarshalJSON

func (r *VectorStoreFileBatchNewParams) UnmarshalJSON(data []byte) error

type VectorStoreFileBatchNewParamsAttributeUnion

type VectorStoreFileBatchNewParamsAttributeUnion struct {
	OfString param.Opt[string]  `json:",omitzero,inline"`
	OfFloat  param.Opt[float64] `json:",omitzero,inline"`
	OfBool   param.Opt[bool]    `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (VectorStoreFileBatchNewParamsAttributeUnion) MarshalJSON

func (*VectorStoreFileBatchNewParamsAttributeUnion) UnmarshalJSON

func (u *VectorStoreFileBatchNewParamsAttributeUnion) UnmarshalJSON(data []byte) error

type VectorStoreFileBatchService

type VectorStoreFileBatchService struct {
	Options []option.RequestOption
}

VectorStoreFileBatchService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewVectorStoreFileBatchService method instead.

func NewVectorStoreFileBatchService

func NewVectorStoreFileBatchService(opts ...option.RequestOption) (r VectorStoreFileBatchService)

NewVectorStoreFileBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*VectorStoreFileBatchService) Cancel

func (r *VectorStoreFileBatchService) Cancel(ctx context.Context, vectorStoreID string, batchID string, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error)

Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.

func (*VectorStoreFileBatchService) Get

func (r *VectorStoreFileBatchService) Get(ctx context.Context, vectorStoreID string, batchID string, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error)

Retrieves a vector store file batch.

func (*VectorStoreFileBatchService) ListFiles

Returns a list of vector store files in a batch.

func (*VectorStoreFileBatchService) ListFilesAutoPaging

Returns a list of vector store files in a batch.

func (*VectorStoreFileBatchService) New

Create a vector store file batch.

func (*VectorStoreFileBatchService) NewAndPoll

func (r *VectorStoreFileBatchService) NewAndPoll(ctx context.Context, vectorStoreId string, body VectorStoreFileBatchNewParams, pollIntervalMs int, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error)

Create a vector store file batch and polls the API until the task is complete. Pass 0 for pollIntervalMs to enable default polling interval.

func (*VectorStoreFileBatchService) PollStatus

func (r *VectorStoreFileBatchService) PollStatus(ctx context.Context, vectorStoreID string, batchID string, pollIntervalMs int, opts ...option.RequestOption) (*VectorStoreFileBatch, error)

PollStatus waits until a BetaVectorStoreFileBatch is no longer in an incomplete state and returns it. Pass 0 as pollIntervalMs to use the default polling interval of 1 second.

func (*VectorStoreFileBatchService) UploadAndPoll

func (r *VectorStoreFileBatchService) UploadAndPoll(ctx context.Context, vectorStoreID string, files []FileNewParams, fileIDs []string, pollIntervalMs int, opts ...option.RequestOption) (*VectorStoreFileBatch, error)

Uploads the given files concurrently and then creates a vector store file batch.

If you've already uploaded certain files that you want to include in this batch then you can pass their IDs through the file_ids argument.

Pass 0 for pollIntervalMs to enable default polling interval.

By default, if any file upload fails then an exception will be eagerly raised.

type VectorStoreFileBatchStatus

type VectorStoreFileBatchStatus string

The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.

const (
	VectorStoreFileBatchStatusInProgress VectorStoreFileBatchStatus = "in_progress"
	VectorStoreFileBatchStatusCompleted  VectorStoreFileBatchStatus = "completed"
	VectorStoreFileBatchStatusCancelled  VectorStoreFileBatchStatus = "cancelled"
	VectorStoreFileBatchStatusFailed     VectorStoreFileBatchStatus = "failed"
)

type VectorStoreFileContentResponse

type VectorStoreFileContentResponse struct {
	// The text content
	Text string `json:"text"`
	// The content type (currently only `"text"`)
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (VectorStoreFileContentResponse) RawJSON

Returns the unmodified JSON received from the API

func (*VectorStoreFileContentResponse) UnmarshalJSON

func (r *VectorStoreFileContentResponse) UnmarshalJSON(data []byte) error

type VectorStoreFileCounts

type VectorStoreFileCounts struct {
	// The number of files that were cancelled.
	Cancelled int64 `json:"cancelled,required"`
	// The number of files that have been successfully processed.
	Completed int64 `json:"completed,required"`
	// The number of files that have failed to process.
	Failed int64 `json:"failed,required"`
	// The number of files that are currently being processed.
	InProgress int64 `json:"in_progress,required"`
	// The total number of files.
	Total int64 `json:"total,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Cancelled   respjson.Field
		Completed   respjson.Field
		Failed      respjson.Field
		InProgress  respjson.Field
		Total       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (VectorStoreFileCounts) RawJSON

func (r VectorStoreFileCounts) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreFileCounts) UnmarshalJSON

func (r *VectorStoreFileCounts) UnmarshalJSON(data []byte) error

type VectorStoreFileDeleted

type VectorStoreFileDeleted struct {
	ID      string                          `json:"id,required"`
	Deleted bool                            `json:"deleted,required"`
	Object  constant.VectorStoreFileDeleted `json:"object,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Deleted     respjson.Field
		Object      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (VectorStoreFileDeleted) RawJSON

func (r VectorStoreFileDeleted) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreFileDeleted) UnmarshalJSON

func (r *VectorStoreFileDeleted) UnmarshalJSON(data []byte) error

type VectorStoreFileLastError

type VectorStoreFileLastError struct {
	// One of `server_error` or `rate_limit_exceeded`.
	//
	// Any of "server_error", "unsupported_file", "invalid_file".
	Code string `json:"code,required"`
	// A human-readable description of the error.
	Message string `json:"message,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Code        respjson.Field
		Message     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

The last error associated with this vector store file. Will be `null` if there are no errors.

func (VectorStoreFileLastError) RawJSON

func (r VectorStoreFileLastError) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreFileLastError) UnmarshalJSON

func (r *VectorStoreFileLastError) UnmarshalJSON(data []byte) error

type VectorStoreFileListParams

type VectorStoreFileListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A cursor for use in pagination. `before` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// starting with obj_foo, your subsequent call can include before=obj_foo in order
	// to fetch the previous page of the list.
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
	//
	// Any of "in_progress", "completed", "failed", "cancelled".
	Filter VectorStoreFileListParamsFilter `query:"filter,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order VectorStoreFileListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (VectorStoreFileListParams) URLQuery

func (r VectorStoreFileListParams) URLQuery() (v url.Values, err error)

URLQuery serializes VectorStoreFileListParams's query parameters as `url.Values`.

type VectorStoreFileListParamsFilter

type VectorStoreFileListParamsFilter string

Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.

const (
	VectorStoreFileListParamsFilterInProgress VectorStoreFileListParamsFilter = "in_progress"
	VectorStoreFileListParamsFilterCompleted  VectorStoreFileListParamsFilter = "completed"
	VectorStoreFileListParamsFilterFailed     VectorStoreFileListParamsFilter = "failed"
	VectorStoreFileListParamsFilterCancelled  VectorStoreFileListParamsFilter = "cancelled"
)

type VectorStoreFileListParamsOrder

type VectorStoreFileListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	VectorStoreFileListParamsOrderAsc  VectorStoreFileListParamsOrder = "asc"
	VectorStoreFileListParamsOrderDesc VectorStoreFileListParamsOrder = "desc"
)

type VectorStoreFileNewParams

type VectorStoreFileNewParams struct {
	// A [File](https://platform.openai.com/docs/api-reference/files) ID that the
	// vector store should use. Useful for tools like `file_search` that can access
	// files.
	FileID string `json:"file_id,required"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard. Keys are strings with a maximum
	// length of 64 characters. Values are strings with a maximum length of 512
	// characters, booleans, or numbers.
	Attributes map[string]VectorStoreFileNewParamsAttributeUnion `json:"attributes,omitzero"`
	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
	// strategy. Only applicable if `file_ids` is non-empty.
	ChunkingStrategy FileChunkingStrategyParamUnion `json:"chunking_strategy,omitzero"`
	// contains filtered or unexported fields
}

func (VectorStoreFileNewParams) MarshalJSON

func (r VectorStoreFileNewParams) MarshalJSON() (data []byte, err error)

func (*VectorStoreFileNewParams) UnmarshalJSON

func (r *VectorStoreFileNewParams) UnmarshalJSON(data []byte) error

type VectorStoreFileNewParamsAttributeUnion

type VectorStoreFileNewParamsAttributeUnion struct {
	OfString param.Opt[string]  `json:",omitzero,inline"`
	OfFloat  param.Opt[float64] `json:",omitzero,inline"`
	OfBool   param.Opt[bool]    `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (VectorStoreFileNewParamsAttributeUnion) MarshalJSON

func (u VectorStoreFileNewParamsAttributeUnion) MarshalJSON() ([]byte, error)

func (*VectorStoreFileNewParamsAttributeUnion) UnmarshalJSON

func (u *VectorStoreFileNewParamsAttributeUnion) UnmarshalJSON(data []byte) error

type VectorStoreFileService

type VectorStoreFileService struct {
	Options []option.RequestOption
}

VectorStoreFileService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewVectorStoreFileService method instead.

func NewVectorStoreFileService

func NewVectorStoreFileService(opts ...option.RequestOption) (r VectorStoreFileService)

NewVectorStoreFileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*VectorStoreFileService) Content

func (r *VectorStoreFileService) Content(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *pagination.Page[VectorStoreFileContentResponse], err error)

Retrieve the parsed contents of a vector store file.

func (*VectorStoreFileService) ContentAutoPaging

Retrieve the parsed contents of a vector store file.

func (*VectorStoreFileService) Delete

func (r *VectorStoreFileService) Delete(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFileDeleted, err error)

Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the [delete file](https://platform.openai.com/docs/api-reference/files/delete) endpoint.

func (*VectorStoreFileService) Get

func (r *VectorStoreFileService) Get(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFile, err error)

Retrieves a vector store file.

func (*VectorStoreFileService) List

Returns a list of vector store files.

func (*VectorStoreFileService) ListAutoPaging

Returns a list of vector store files.

func (*VectorStoreFileService) New

func (r *VectorStoreFileService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileNewParams, opts ...option.RequestOption) (res *VectorStoreFile, err error)

Create a vector store file by attaching a File(https://platform.openai.com/docs/api-reference/files) to a [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).

func (*VectorStoreFileService) NewAndPoll

func (r *VectorStoreFileService) NewAndPoll(ctx context.Context, vectorStoreId string, body VectorStoreFileNewParams, pollIntervalMs int, opts ...option.RequestOption) (res *VectorStoreFile, err error)

Create a vector store file by attaching a File(https://platform.openai.com/docs/api-reference/files) to a [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).

Polls the API and blocks until the task is complete. Default polling interval is 1 second.

func (*VectorStoreFileService) PollStatus

func (r *VectorStoreFileService) PollStatus(ctx context.Context, vectorStoreID string, fileID string, pollIntervalMs int, opts ...option.RequestOption) (*VectorStoreFile, error)

PollStatus waits until a VectorStoreFile is no longer in an incomplete state and returns it. Pass 0 as pollIntervalMs to use the default polling interval of 1 second.

func (*VectorStoreFileService) Update

func (r *VectorStoreFileService) Update(ctx context.Context, vectorStoreID string, fileID string, body VectorStoreFileUpdateParams, opts ...option.RequestOption) (res *VectorStoreFile, err error)

Update attributes on a vector store file.

func (*VectorStoreFileService) Upload

func (r *VectorStoreFileService) Upload(ctx context.Context, vectorStoreID string, body FileNewParams, opts ...option.RequestOption) (*VectorStoreFile, error)

Upload a file to the `files` API and then attach it to the given vector store.

Note the file will be asynchronously processed (you can use the alternative polling helper method to wait for processing to complete).

func (*VectorStoreFileService) UploadAndPoll

func (r *VectorStoreFileService) UploadAndPoll(ctx context.Context, vectorStoreID string, body FileNewParams, pollIntervalMs int, opts ...option.RequestOption) (*VectorStoreFile, error)

Add a file to a vector store and poll until processing is complete. Default polling interval is 1 second.

type VectorStoreFileStatus

type VectorStoreFileStatus string

The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.

const (
	VectorStoreFileStatusInProgress VectorStoreFileStatus = "in_progress"
	VectorStoreFileStatusCompleted  VectorStoreFileStatus = "completed"
	VectorStoreFileStatusCancelled  VectorStoreFileStatus = "cancelled"
	VectorStoreFileStatusFailed     VectorStoreFileStatus = "failed"
)

type VectorStoreFileUpdateParams

type VectorStoreFileUpdateParams struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard. Keys are strings with a maximum
	// length of 64 characters. Values are strings with a maximum length of 512
	// characters, booleans, or numbers.
	Attributes map[string]VectorStoreFileUpdateParamsAttributeUnion `json:"attributes,omitzero,required"`
	// contains filtered or unexported fields
}

func (VectorStoreFileUpdateParams) MarshalJSON

func (r VectorStoreFileUpdateParams) MarshalJSON() (data []byte, err error)

func (*VectorStoreFileUpdateParams) UnmarshalJSON

func (r *VectorStoreFileUpdateParams) UnmarshalJSON(data []byte) error

type VectorStoreFileUpdateParamsAttributeUnion

type VectorStoreFileUpdateParamsAttributeUnion struct {
	OfString param.Opt[string]  `json:",omitzero,inline"`
	OfFloat  param.Opt[float64] `json:",omitzero,inline"`
	OfBool   param.Opt[bool]    `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (VectorStoreFileUpdateParamsAttributeUnion) MarshalJSON

func (*VectorStoreFileUpdateParamsAttributeUnion) UnmarshalJSON

func (u *VectorStoreFileUpdateParamsAttributeUnion) UnmarshalJSON(data []byte) error

type VectorStoreListParams

type VectorStoreListParams struct {
	// A cursor for use in pagination. `after` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
	// fetch the next page of the list.
	After param.Opt[string] `query:"after,omitzero" json:"-"`
	// A cursor for use in pagination. `before` is an object ID that defines your place
	// in the list. For instance, if you make a list request and receive 100 objects,
	// starting with obj_foo, your subsequent call can include before=obj_foo in order
	// to fetch the previous page of the list.
	Before param.Opt[string] `query:"before,omitzero" json:"-"`
	// A limit on the number of objects to be returned. Limit can range between 1 and
	// 100, and the default is 20.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
	// order and `desc` for descending order.
	//
	// Any of "asc", "desc".
	Order VectorStoreListParamsOrder `query:"order,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (VectorStoreListParams) URLQuery

func (r VectorStoreListParams) URLQuery() (v url.Values, err error)

URLQuery serializes VectorStoreListParams's query parameters as `url.Values`.

type VectorStoreListParamsOrder

type VectorStoreListParamsOrder string

Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

const (
	VectorStoreListParamsOrderAsc  VectorStoreListParamsOrder = "asc"
	VectorStoreListParamsOrderDesc VectorStoreListParamsOrder = "desc"
)

type VectorStoreNewParams

type VectorStoreNewParams struct {
	// The name of the vector store.
	Name param.Opt[string] `json:"name,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
	// strategy. Only applicable if `file_ids` is non-empty.
	ChunkingStrategy FileChunkingStrategyParamUnion `json:"chunking_strategy,omitzero"`
	// The expiration policy for a vector store.
	ExpiresAfter VectorStoreNewParamsExpiresAfter `json:"expires_after,omitzero"`
	// A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
	// the vector store should use. Useful for tools like `file_search` that can access
	// files.
	FileIDs []string `json:"file_ids,omitzero"`
	// contains filtered or unexported fields
}

func (VectorStoreNewParams) MarshalJSON

func (r VectorStoreNewParams) MarshalJSON() (data []byte, err error)

func (*VectorStoreNewParams) UnmarshalJSON

func (r *VectorStoreNewParams) UnmarshalJSON(data []byte) error

type VectorStoreNewParamsExpiresAfter

type VectorStoreNewParamsExpiresAfter struct {
	// The number of days after the anchor time that the vector store will expire.
	Days int64 `json:"days,required"`
	// Anchor timestamp after which the expiration policy applies. Supported anchors:
	// `last_active_at`.
	//
	// This field can be elided, and will marshal its zero value as "last_active_at".
	Anchor constant.LastActiveAt `json:"anchor,required"`
	// contains filtered or unexported fields
}

The expiration policy for a vector store.

The properties Anchor, Days are required.

func (VectorStoreNewParamsExpiresAfter) MarshalJSON

func (r VectorStoreNewParamsExpiresAfter) MarshalJSON() (data []byte, err error)

func (*VectorStoreNewParamsExpiresAfter) UnmarshalJSON

func (r *VectorStoreNewParamsExpiresAfter) UnmarshalJSON(data []byte) error

type VectorStoreSearchParams

type VectorStoreSearchParams struct {
	// A query string for a search
	Query VectorStoreSearchParamsQueryUnion `json:"query,omitzero,required"`
	// The maximum number of results to return. This number should be between 1 and 50
	// inclusive.
	MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"`
	// Whether to rewrite the natural language query for vector search.
	RewriteQuery param.Opt[bool] `json:"rewrite_query,omitzero"`
	// A filter to apply based on file attributes.
	Filters VectorStoreSearchParamsFiltersUnion `json:"filters,omitzero"`
	// Ranking options for search.
	RankingOptions VectorStoreSearchParamsRankingOptions `json:"ranking_options,omitzero"`
	// contains filtered or unexported fields
}

func (VectorStoreSearchParams) MarshalJSON

func (r VectorStoreSearchParams) MarshalJSON() (data []byte, err error)

func (*VectorStoreSearchParams) UnmarshalJSON

func (r *VectorStoreSearchParams) UnmarshalJSON(data []byte) error

type VectorStoreSearchParamsFiltersUnion

type VectorStoreSearchParamsFiltersUnion struct {
	OfComparisonFilter *shared.ComparisonFilterParam `json:",omitzero,inline"`
	OfCompoundFilter   *shared.CompoundFilterParam   `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (VectorStoreSearchParamsFiltersUnion) GetFilters

Returns a pointer to the underlying variant's property, if present.

func (VectorStoreSearchParamsFiltersUnion) GetKey

Returns a pointer to the underlying variant's property, if present.

func (VectorStoreSearchParamsFiltersUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (VectorStoreSearchParamsFiltersUnion) GetValue

Returns a pointer to the underlying variant's property, if present.

func (VectorStoreSearchParamsFiltersUnion) MarshalJSON

func (u VectorStoreSearchParamsFiltersUnion) MarshalJSON() ([]byte, error)

func (*VectorStoreSearchParamsFiltersUnion) UnmarshalJSON

func (u *VectorStoreSearchParamsFiltersUnion) UnmarshalJSON(data []byte) error

type VectorStoreSearchParamsQueryUnion

type VectorStoreSearchParamsQueryUnion struct {
	OfString      param.Opt[string] `json:",omitzero,inline"`
	OfStringArray []string          `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (VectorStoreSearchParamsQueryUnion) MarshalJSON

func (u VectorStoreSearchParamsQueryUnion) MarshalJSON() ([]byte, error)

func (*VectorStoreSearchParamsQueryUnion) UnmarshalJSON

func (u *VectorStoreSearchParamsQueryUnion) UnmarshalJSON(data []byte) error

type VectorStoreSearchParamsRankingOptions

type VectorStoreSearchParamsRankingOptions struct {
	ScoreThreshold param.Opt[float64] `json:"score_threshold,omitzero"`
	// Any of "auto", "default-2024-11-15".
	Ranker string `json:"ranker,omitzero"`
	// contains filtered or unexported fields
}

Ranking options for search.

func (VectorStoreSearchParamsRankingOptions) MarshalJSON

func (r VectorStoreSearchParamsRankingOptions) MarshalJSON() (data []byte, err error)

func (*VectorStoreSearchParamsRankingOptions) UnmarshalJSON

func (r *VectorStoreSearchParamsRankingOptions) UnmarshalJSON(data []byte) error

type VectorStoreSearchResponse

type VectorStoreSearchResponse struct {
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard. Keys are strings with a maximum
	// length of 64 characters. Values are strings with a maximum length of 512
	// characters, booleans, or numbers.
	Attributes map[string]VectorStoreSearchResponseAttributeUnion `json:"attributes,required"`
	// Content chunks from the file.
	Content []VectorStoreSearchResponseContent `json:"content,required"`
	// The ID of the vector store file.
	FileID string `json:"file_id,required"`
	// The name of the vector store file.
	Filename string `json:"filename,required"`
	// The similarity score for the result.
	Score float64 `json:"score,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Attributes  respjson.Field
		Content     respjson.Field
		FileID      respjson.Field
		Filename    respjson.Field
		Score       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (VectorStoreSearchResponse) RawJSON

func (r VectorStoreSearchResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*VectorStoreSearchResponse) UnmarshalJSON

func (r *VectorStoreSearchResponse) UnmarshalJSON(data []byte) error

type VectorStoreSearchResponseAttributeUnion

type VectorStoreSearchResponseAttributeUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [float64] instead of an object.
	OfFloat float64 `json:",inline"`
	// This field will be present if the value is a [bool] instead of an object.
	OfBool bool `json:",inline"`
	JSON   struct {
		OfString respjson.Field
		OfFloat  respjson.Field
		OfBool   respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

VectorStoreSearchResponseAttributeUnion contains all possible properties and values from [string], [float64], [bool].

Use the methods beginning with 'As' to cast the union to one of its variants.

If the underlying value is not a json object, one of the following properties will be valid: OfString OfFloat OfBool]

func (VectorStoreSearchResponseAttributeUnion) AsBool

func (VectorStoreSearchResponseAttributeUnion) AsFloat

func (VectorStoreSearchResponseAttributeUnion) AsString

func (VectorStoreSearchResponseAttributeUnion) RawJSON

Returns the unmodified JSON received from the API

func (*VectorStoreSearchResponseAttributeUnion) UnmarshalJSON

func (r *VectorStoreSearchResponseAttributeUnion) UnmarshalJSON(data []byte) error

type VectorStoreSearchResponseContent

type VectorStoreSearchResponseContent struct {
	// The text content returned from search.
	Text string `json:"text,required"`
	// The type of content.
	//
	// Any of "text".
	Type string `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (VectorStoreSearchResponseContent) RawJSON

Returns the unmodified JSON received from the API

func (*VectorStoreSearchResponseContent) UnmarshalJSON

func (r *VectorStoreSearchResponseContent) UnmarshalJSON(data []byte) error

type VectorStoreService

type VectorStoreService struct {
	Options     []option.RequestOption
	Files       VectorStoreFileService
	FileBatches VectorStoreFileBatchService
}

VectorStoreService contains methods and other services that help with interacting with the openai API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewVectorStoreService method instead.

func NewVectorStoreService

func NewVectorStoreService(opts ...option.RequestOption) (r VectorStoreService)

NewVectorStoreService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*VectorStoreService) Delete

func (r *VectorStoreService) Delete(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStoreDeleted, err error)

Delete a vector store.

func (*VectorStoreService) Get

func (r *VectorStoreService) Get(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStore, err error)

Retrieves a vector store.

func (*VectorStoreService) List

Returns a list of vector stores.

func (*VectorStoreService) ListAutoPaging

Returns a list of vector stores.

func (*VectorStoreService) New

Create a vector store.

func (*VectorStoreService) Search

Search a vector store for relevant chunks based on a query and file attributes filter.

func (*VectorStoreService) SearchAutoPaging

Search a vector store for relevant chunks based on a query and file attributes filter.

func (*VectorStoreService) Update

func (r *VectorStoreService) Update(ctx context.Context, vectorStoreID string, body VectorStoreUpdateParams, opts ...option.RequestOption) (res *VectorStore, err error)

Modifies a vector store.

type VectorStoreStatus

type VectorStoreStatus string

The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.

const (
	VectorStoreStatusExpired    VectorStoreStatus = "expired"
	VectorStoreStatusInProgress VectorStoreStatus = "in_progress"
	VectorStoreStatusCompleted  VectorStoreStatus = "completed"
)

type VectorStoreUpdateParams

type VectorStoreUpdateParams struct {
	// The name of the vector store.
	Name param.Opt[string] `json:"name,omitzero"`
	// The expiration policy for a vector store.
	ExpiresAfter VectorStoreUpdateParamsExpiresAfter `json:"expires_after,omitzero"`
	// Set of 16 key-value pairs that can be attached to an object. This can be useful
	// for storing additional information about the object in a structured format, and
	// querying for objects via API or the dashboard.
	//
	// Keys are strings with a maximum length of 64 characters. Values are strings with
	// a maximum length of 512 characters.
	Metadata shared.Metadata `json:"metadata,omitzero"`
	// contains filtered or unexported fields
}

func (VectorStoreUpdateParams) MarshalJSON

func (r VectorStoreUpdateParams) MarshalJSON() (data []byte, err error)

func (*VectorStoreUpdateParams) UnmarshalJSON

func (r *VectorStoreUpdateParams) UnmarshalJSON(data []byte) error

type VectorStoreUpdateParamsExpiresAfter

type VectorStoreUpdateParamsExpiresAfter struct {
	// The number of days after the anchor time that the vector store will expire.
	Days int64 `json:"days,required"`
	// Anchor timestamp after which the expiration policy applies. Supported anchors:
	// `last_active_at`.
	//
	// This field can be elided, and will marshal its zero value as "last_active_at".
	Anchor constant.LastActiveAt `json:"anchor,required"`
	// contains filtered or unexported fields
}

The expiration policy for a vector store.

The properties Anchor, Days are required.

func (VectorStoreUpdateParamsExpiresAfter) MarshalJSON

func (r VectorStoreUpdateParamsExpiresAfter) MarshalJSON() (data []byte, err error)

func (*VectorStoreUpdateParamsExpiresAfter) UnmarshalJSON

func (r *VectorStoreUpdateParamsExpiresAfter) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
Package azure provides configuration options so you can connect and use Azure OpenAI using the [openai.Client].
Package azure provides configuration options so you can connect and use Azure OpenAI using the [openai.Client].
examples module
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package.
packages