Documentation
¶
Index ¶
- Constants
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type AudioModel
- type AudioResponseFormat
- type AudioService
- type AudioSpeechNewParams
- type AudioSpeechNewParamsResponseFormat
- type AudioSpeechNewParamsVoice
- type AudioSpeechService
- type AudioTranscriptionNewParams
- type AudioTranscriptionNewParamsChunkingStrategyUnion
- type AudioTranscriptionNewParamsChunkingStrategyVadConfig
- type AudioTranscriptionService
- type AudioTranslationNewParams
- type AudioTranslationNewParamsResponseFormat
- type AudioTranslationService
- type AutoFileChunkingStrategyParam
- type Batch
- type BatchError
- type BatchErrors
- type BatchListParams
- type BatchNewParams
- type BatchNewParamsCompletionWindow
- type BatchNewParamsEndpoint
- type BatchRequestCounts
- type BatchService
- func (r *BatchService) Cancel(ctx context.Context, batchID string, opts ...option.RequestOption) (res *Batch, err error)
- func (r *BatchService) Get(ctx context.Context, batchID string, opts ...option.RequestOption) (res *Batch, err error)
- func (r *BatchService) List(ctx context.Context, query BatchListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Batch], err error)
- func (r *BatchService) ListAutoPaging(ctx context.Context, query BatchListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[Batch]
- func (r *BatchService) New(ctx context.Context, body BatchNewParams, opts ...option.RequestOption) (res *Batch, err error)
- type BatchStatus
- type BetaService
- type ChatCompletion
- type ChatCompletionAccumulator
- func (acc *ChatCompletionAccumulator) AddChunk(chunk ChatCompletionChunk) bool
- func (acc *ChatCompletionAccumulator) JustFinishedContent() (content string, ok bool)
- func (acc *ChatCompletionAccumulator) JustFinishedRefusal() (refusal string, ok bool)
- func (acc *ChatCompletionAccumulator) JustFinishedToolCall() (toolcall FinishedChatCompletionToolCall, ok bool)
- type ChatCompletionAssistantMessageParam
- type ChatCompletionAssistantMessageParamAudio
- type ChatCompletionAssistantMessageParamContentUnion
- type ChatCompletionAssistantMessageParamFunctionCalldeprecated
- type ChatCompletionAssistantMessagePartUnion
- func (u ChatCompletionAssistantMessagePartUnion) GetRefusal() *string
- func (u ChatCompletionAssistantMessagePartUnion) GetText() *string
- func (u ChatCompletionAssistantMessagePartUnion) GetType() *string
- func (u ChatCompletionAssistantMessagePartUnion) MarshalJSON() ([]byte, error)
- func (u *ChatCompletionAssistantMessagePartUnion) UnmarshalJSON(data []byte) error
- type ChatCompletionAudio
- type ChatCompletionAudioParam
- type ChatCompletionAudioParamFormat
- type ChatCompletionAudioParamVoice
- type ChatCompletionChoice
- type ChatCompletionChoiceLogprobs
- type ChatCompletionChunk
- type ChatCompletionChunkChoice
- type ChatCompletionChunkChoiceDelta
- type ChatCompletionChunkChoiceDeltaFunctionCalldeprecated
- type ChatCompletionChunkChoiceDeltaToolCallFunction
- type ChatCompletionChunkChoiceLogprobs
- type ChatCompletionChunkServiceTier
- type ChatCompletionContentPartFileParam
- type ChatCompletionContentPartImageImageURLParam
- type ChatCompletionContentPartImageParam
- type ChatCompletionContentPartInputAudioParam
- type ChatCompletionContentPartRefusalParam
- type ChatCompletionContentPartTextParam
- type ChatCompletionContentPartUnionParam
- func FileContentPart(file ChatCompletionFileContentPartParam) ChatCompletionContentPartUnionParam
- func ImageContentPart(imageURL ChatCompletionContentPartImageImageURLParam) ChatCompletionContentPartUnionParam
- func InputAudioContentPart(inputAudio ChatCompletionInputAudioDataParam) ChatCompletionContentPartUnionParam
- func TextContentPart(text string) ChatCompletionContentPartUnionParam
- func (u ChatCompletionContentPartUnionParam) GetFile() *ChatCompletionFileContentPartParam
- func (u ChatCompletionContentPartUnionParam) GetImageURL() *ChatCompletionContentPartImageImageURLParam
- func (u ChatCompletionContentPartUnionParam) GetInputAudio() *ChatCompletionInputAudioDataParam
- func (u ChatCompletionContentPartUnionParam) GetText() *string
- func (u ChatCompletionContentPartUnionParam) GetType() *string
- func (u ChatCompletionContentPartUnionParam) MarshalJSON() ([]byte, error)
- func (u *ChatCompletionContentPartUnionParam) UnmarshalJSON(data []byte) error
- type ChatCompletionDeleted
- type ChatCompletionDeveloperMessageParam
- type ChatCompletionDeveloperMessageParamContentUnion
- type ChatCompletionFileContentPartParam
- type ChatCompletionFunctionCallOptionParam
- type ChatCompletionFunctionMessageParamdeprecated
- type ChatCompletionInputAudioDataParam
- type ChatCompletionListParams
- type ChatCompletionListParamsOrder
- type ChatCompletionMessage
- type ChatCompletionMessageAnnotation
- type ChatCompletionMessageAnnotationURLCitation
- type ChatCompletionMessageFunctionCalldeprecated
- type ChatCompletionMessageListParams
- type ChatCompletionMessageListParamsOrder
- type ChatCompletionMessageParamUnion
- func AssistantMessage[T string | []ChatCompletionAssistantMessagePartUnion](content T) ChatCompletionMessageParamUnion
- func ChatCompletionMessageParamOfFunction(content string, name string) ChatCompletionMessageParamUnion
- func DeveloperMessage[T string | []ChatCompletionContentPartTextParam](content T) ChatCompletionMessageParamUnion
- func SystemMessage[T string | []ChatCompletionContentPartTextParam](content T) ChatCompletionMessageParamUnion
- func ToolMessage[T string | []ChatCompletionContentPartTextParam](content T, toolCallID string) ChatCompletionMessageParamUnion
- func UserMessage[T string | []ChatCompletionContentPartUnionParam](content T) ChatCompletionMessageParamUnion
- func (u ChatCompletionMessageParamUnion) GetAudio() *ChatCompletionAssistantMessageParamAudio
- func (u ChatCompletionMessageParamUnion) GetContent() (res chatCompletionMessageParamUnionContent)
- func (u ChatCompletionMessageParamUnion) GetFunctionCall() *ChatCompletionAssistantMessageParamFunctionCall
- func (u ChatCompletionMessageParamUnion) GetName() *string
- func (u ChatCompletionMessageParamUnion) GetRefusal() *string
- func (u ChatCompletionMessageParamUnion) GetRole() *string
- func (u ChatCompletionMessageParamUnion) GetToolCallID() *string
- func (u ChatCompletionMessageParamUnion) GetToolCalls() []ChatCompletionMessageToolCallParam
- func (u ChatCompletionMessageParamUnion) MarshalJSON() ([]byte, error)
- func (u *ChatCompletionMessageParamUnion) UnmarshalJSON(data []byte) error
- type ChatCompletionMessageService
- func (r *ChatCompletionMessageService) List(ctx context.Context, completionID string, ...) (res *pagination.CursorPage[ChatCompletionStoreMessage], err error)
- func (r *ChatCompletionMessageService) ListAutoPaging(ctx context.Context, completionID string, ...) *pagination.CursorPageAutoPager[ChatCompletionStoreMessage]
- type ChatCompletionMessageToolCall
- type ChatCompletionMessageToolCallFunction
- type ChatCompletionMessageToolCallFunctionParam
- type ChatCompletionMessageToolCallParam
- type ChatCompletionNamedToolChoiceFunctionParam
- type ChatCompletionNamedToolChoiceParam
- type ChatCompletionNewParams
- type ChatCompletionNewParamsFunctiondeprecated
- type ChatCompletionNewParamsFunctionCallFunctionCallMode
- type ChatCompletionNewParamsFunctionCallUnion
- type ChatCompletionNewParamsResponseFormatUnion
- func (u ChatCompletionNewParamsResponseFormatUnion) GetJSONSchema() *shared.ResponseFormatJSONSchemaJSONSchemaParam
- func (u ChatCompletionNewParamsResponseFormatUnion) GetType() *string
- func (u ChatCompletionNewParamsResponseFormatUnion) MarshalJSON() ([]byte, error)
- func (u *ChatCompletionNewParamsResponseFormatUnion) UnmarshalJSON(data []byte) error
- type ChatCompletionNewParamsServiceTier
- type ChatCompletionNewParamsStopUnion
- type ChatCompletionNewParamsWebSearchOptions
- type ChatCompletionPredictionContentContentUnionParam
- type ChatCompletionPredictionContentParam
- type ChatCompletionService
- func (r *ChatCompletionService) Delete(ctx context.Context, completionID string, opts ...option.RequestOption) (res *ChatCompletionDeleted, err error)
- func (r *ChatCompletionService) Get(ctx context.Context, completionID string, opts ...option.RequestOption) (res *ChatCompletion, err error)
- func (r *ChatCompletionService) List(ctx context.Context, query ChatCompletionListParams, ...) (res *pagination.CursorPage[ChatCompletion], err error)
- func (r *ChatCompletionService) ListAutoPaging(ctx context.Context, query ChatCompletionListParams, ...) *pagination.CursorPageAutoPager[ChatCompletion]
- func (r *ChatCompletionService) New(ctx context.Context, body ChatCompletionNewParams, ...) (res *ChatCompletion, err error)
- func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompletionNewParams, ...) (stream *ssestream.Stream[ChatCompletionChunk])
- func (r *ChatCompletionService) Update(ctx context.Context, completionID string, body ChatCompletionUpdateParams, ...) (res *ChatCompletion, err error)
- type ChatCompletionServiceTier
- type ChatCompletionStoreMessage
- type ChatCompletionStreamOptionsParam
- type ChatCompletionSystemMessageParam
- type ChatCompletionSystemMessageParamContentUnion
- type ChatCompletionTokenLogprob
- type ChatCompletionTokenLogprobTopLogprob
- type ChatCompletionToolCallDelta
- type ChatCompletionToolChoiceOptionAuto
- type ChatCompletionToolChoiceOptionUnionParam
- type ChatCompletionToolMessageParam
- type ChatCompletionToolMessageParamContentUnion
- type ChatCompletionToolParam
- type ChatCompletionUpdateParams
- type ChatCompletionUserMessageParam
- type ChatCompletionUserMessageParamContentUnion
- type ChatCompletionWebSearchApproximateUserLocation
- type ChatCompletionWebSearchUserLocation
- type ChatModel
- type ChatService
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, ...) error
- func (r *Client) Get(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Post(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Put(ctx context.Context, path string, params any, res any, ...) error
- type ComparisonFilter
- type ComparisonFilterParam
- type ComparisonFilterType
- type ComparisonFilterValueUnion
- type ComparisonFilterValueUnionParam
- type Completion
- type CompletionChoice
- type CompletionChoiceFinishReason
- type CompletionChoiceLogprobs
- type CompletionNewParams
- type CompletionNewParamsModel
- type CompletionNewParamsPromptUnion
- type CompletionNewParamsStopUnion
- type CompletionService
- type CompletionUsage
- type CompletionUsageCompletionTokensDetails
- type CompletionUsagePromptTokensDetails
- type CompoundFilter
- type CompoundFilterParam
- type CompoundFilterType
- type CreateEmbeddingResponse
- type CreateEmbeddingResponseUsage
- type DpoHyperparameters
- type DpoHyperparametersBatchSizeUnion
- type DpoHyperparametersBatchSizeUnionResp
- type DpoHyperparametersBetaUnion
- type DpoHyperparametersBetaUnionResp
- type DpoHyperparametersLearningRateMultiplierUnion
- type DpoHyperparametersLearningRateMultiplierUnionResp
- func (u DpoHyperparametersLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto)
- func (u DpoHyperparametersLearningRateMultiplierUnionResp) AsFloat() (v float64)
- func (u DpoHyperparametersLearningRateMultiplierUnionResp) RawJSON() string
- func (r *DpoHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error
- type DpoHyperparametersNEpochsUnion
- type DpoHyperparametersNEpochsUnionResp
- type DpoHyperparametersResp
- type DpoMethod
- type DpoMethodParam
- type Embedding
- type EmbeddingModel
- type EmbeddingNewParams
- type EmbeddingNewParamsEncodingFormat
- type EmbeddingNewParamsInputUnion
- type EmbeddingService
- type Error
- type FileChunkingStrategyParamUnion
- type FileChunkingStrategyUnion
- func (u FileChunkingStrategyUnion) AsAny() anyFileChunkingStrategy
- func (u FileChunkingStrategyUnion) AsOther() (v OtherFileChunkingStrategyObject)
- func (u FileChunkingStrategyUnion) AsStatic() (v StaticFileChunkingStrategyObject)
- func (u FileChunkingStrategyUnion) RawJSON() string
- func (r *FileChunkingStrategyUnion) UnmarshalJSON(data []byte) error
- type FileDeleted
- type FileListParams
- type FileListParamsOrder
- type FileNewParams
- type FileObject
- type FileObjectPurpose
- type FileObjectStatus
- type FilePurpose
- type FileService
- func (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *http.Response, err error)
- func (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileDeleted, err error)
- func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileObject, err error)
- func (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FileObject], err error)
- func (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FileObject]
- func (r *FileService) New(ctx context.Context, body FileNewParams, opts ...option.RequestOption) (res *FileObject, err error)
- type FineTuningAlphaGraderRunParams
- type FineTuningAlphaGraderRunParamsGraderUnion
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetCalculateOutput() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetEvaluationMetric() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetGraders() map[string]MultiGraderGraderUnionParam
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetImageTag() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetInput() (res fineTuningAlphaGraderRunParamsGraderUnionInput)
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetModel() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetName() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetOperation() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetRange() []float64
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetReference() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetSamplingParams() *any
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetSource() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) GetType() *string
- func (u FineTuningAlphaGraderRunParamsGraderUnion) MarshalJSON() ([]byte, error)
- func (u *FineTuningAlphaGraderRunParamsGraderUnion) UnmarshalJSON(data []byte) error
- type FineTuningAlphaGraderRunParamsReferenceAnswerUnion
- type FineTuningAlphaGraderRunResponse
- type FineTuningAlphaGraderRunResponseMetadata
- type FineTuningAlphaGraderRunResponseMetadataErrors
- type FineTuningAlphaGraderService
- func (r *FineTuningAlphaGraderService) Run(ctx context.Context, body FineTuningAlphaGraderRunParams, ...) (res *FineTuningAlphaGraderRunResponse, err error)
- func (r *FineTuningAlphaGraderService) Validate(ctx context.Context, body FineTuningAlphaGraderValidateParams, ...) (res *FineTuningAlphaGraderValidateResponse, err error)
- type FineTuningAlphaGraderValidateParams
- type FineTuningAlphaGraderValidateParamsGraderUnion
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetCalculateOutput() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetEvaluationMetric() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetGraders() map[string]MultiGraderGraderUnionParam
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetImageTag() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetInput() (res fineTuningAlphaGraderValidateParamsGraderUnionInput)
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetModel() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetName() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetOperation() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetRange() []float64
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetReference() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetSamplingParams() *any
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetSource() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetType() *string
- func (u FineTuningAlphaGraderValidateParamsGraderUnion) MarshalJSON() ([]byte, error)
- func (u *FineTuningAlphaGraderValidateParamsGraderUnion) UnmarshalJSON(data []byte) error
- type FineTuningAlphaGraderValidateResponse
- type FineTuningAlphaGraderValidateResponseGraderUnion
- func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsMultiGrader() (v MultiGrader)
- func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsPythonGrader() (v PythonGrader)
- func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsScoreModelGrader() (v ScoreModelGrader)
- func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsStringCheckGrader() (v StringCheckGrader)
- func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsTextSimilarityGrader() (v TextSimilarityGrader)
- func (u FineTuningAlphaGraderValidateResponseGraderUnion) RawJSON() string
- func (r *FineTuningAlphaGraderValidateResponseGraderUnion) UnmarshalJSON(data []byte) error
- type FineTuningAlphaGraderValidateResponseGraderUnionInput
- type FineTuningAlphaService
- type FineTuningCheckpointPermissionDeleteParams
- type FineTuningCheckpointPermissionDeleteResponse
- type FineTuningCheckpointPermissionGetParams
- type FineTuningCheckpointPermissionGetParamsOrder
- type FineTuningCheckpointPermissionGetResponse
- type FineTuningCheckpointPermissionGetResponseData
- type FineTuningCheckpointPermissionNewParams
- type FineTuningCheckpointPermissionNewResponse
- type FineTuningCheckpointPermissionService
- func (r *FineTuningCheckpointPermissionService) Delete(ctx context.Context, permissionID string, ...) (res *FineTuningCheckpointPermissionDeleteResponse, err error)
- func (r *FineTuningCheckpointPermissionService) Get(ctx context.Context, fineTunedModelCheckpoint string, ...) (res *FineTuningCheckpointPermissionGetResponse, err error)
- func (r *FineTuningCheckpointPermissionService) New(ctx context.Context, fineTunedModelCheckpoint string, ...) (res *pagination.Page[FineTuningCheckpointPermissionNewResponse], err error)
- func (r *FineTuningCheckpointPermissionService) NewAutoPaging(ctx context.Context, fineTunedModelCheckpoint string, ...) *pagination.PageAutoPager[FineTuningCheckpointPermissionNewResponse]
- type FineTuningCheckpointService
- type FineTuningJob
- type FineTuningJobCheckpoint
- type FineTuningJobCheckpointListParams
- type FineTuningJobCheckpointMetrics
- type FineTuningJobCheckpointService
- func (r *FineTuningJobCheckpointService) List(ctx context.Context, fineTuningJobID string, ...) (res *pagination.CursorPage[FineTuningJobCheckpoint], err error)
- func (r *FineTuningJobCheckpointService) ListAutoPaging(ctx context.Context, fineTuningJobID string, ...) *pagination.CursorPageAutoPager[FineTuningJobCheckpoint]
- type FineTuningJobError
- type FineTuningJobEvent
- type FineTuningJobEventLevel
- type FineTuningJobEventType
- type FineTuningJobHyperparameters
- type FineTuningJobHyperparametersBatchSizeUnion
- func (u FineTuningJobHyperparametersBatchSizeUnion) AsInt() (v int64)
- func (u FineTuningJobHyperparametersBatchSizeUnion) AsManual() (v constant.Auto)
- func (u FineTuningJobHyperparametersBatchSizeUnion) RawJSON() string
- func (r *FineTuningJobHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error
- type FineTuningJobHyperparametersLearningRateMultiplierUnion
- func (u FineTuningJobHyperparametersLearningRateMultiplierUnion) AsAuto() (v constant.Auto)
- func (u FineTuningJobHyperparametersLearningRateMultiplierUnion) AsFloat() (v float64)
- func (u FineTuningJobHyperparametersLearningRateMultiplierUnion) RawJSON() string
- func (r *FineTuningJobHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error
- type FineTuningJobHyperparametersNEpochsUnion
- type FineTuningJobListEventsParams
- type FineTuningJobListParams
- type FineTuningJobMethod
- type FineTuningJobNewParams
- type FineTuningJobNewParamsHyperparametersdeprecated
- type FineTuningJobNewParamsHyperparametersBatchSizeUnion
- type FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion
- type FineTuningJobNewParamsHyperparametersNEpochsUnion
- type FineTuningJobNewParamsIntegration
- type FineTuningJobNewParamsIntegrationWandb
- type FineTuningJobNewParamsMethod
- type FineTuningJobNewParamsModel
- type FineTuningJobService
- func (r *FineTuningJobService) Cancel(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)
- func (r *FineTuningJobService) Get(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)
- func (r *FineTuningJobService) List(ctx context.Context, query FineTuningJobListParams, ...) (res *pagination.CursorPage[FineTuningJob], err error)
- func (r *FineTuningJobService) ListAutoPaging(ctx context.Context, query FineTuningJobListParams, ...) *pagination.CursorPageAutoPager[FineTuningJob]
- func (r *FineTuningJobService) ListEvents(ctx context.Context, fineTuningJobID string, ...) (res *pagination.CursorPage[FineTuningJobEvent], err error)
- func (r *FineTuningJobService) ListEventsAutoPaging(ctx context.Context, fineTuningJobID string, ...) *pagination.CursorPageAutoPager[FineTuningJobEvent]
- func (r *FineTuningJobService) New(ctx context.Context, body FineTuningJobNewParams, opts ...option.RequestOption) (res *FineTuningJob, err error)
- func (r *FineTuningJobService) Pause(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)
- func (r *FineTuningJobService) Resume(ctx context.Context, fineTuningJobID string, opts ...option.RequestOption) (res *FineTuningJob, err error)
- type FineTuningJobStatus
- type FineTuningJobWandbIntegration
- type FineTuningJobWandbIntegrationObject
- type FineTuningMethodService
- type FineTuningService
- type FinishedChatCompletionToolCall
- type FunctionDefinitionParam
- type FunctionParameters
- type GraderGraderModelService
- type GraderService
- type Image
- type ImageEditParams
- type ImageEditParamsBackground
- type ImageEditParamsImageUnion
- type ImageEditParamsQuality
- type ImageEditParamsResponseFormat
- type ImageEditParamsSize
- type ImageGenerateParams
- type ImageGenerateParamsBackground
- type ImageGenerateParamsModeration
- type ImageGenerateParamsOutputFormat
- type ImageGenerateParamsQuality
- type ImageGenerateParamsResponseFormat
- type ImageGenerateParamsSize
- type ImageGenerateParamsStyle
- type ImageModel
- type ImageNewVariationParams
- type ImageNewVariationParamsResponseFormat
- type ImageNewVariationParamsSize
- type ImageService
- func (r *ImageService) Edit(ctx context.Context, body ImageEditParams, opts ...option.RequestOption) (res *ImagesResponse, err error)
- func (r *ImageService) Generate(ctx context.Context, body ImageGenerateParams, opts ...option.RequestOption) (res *ImagesResponse, err error)
- func (r *ImageService) NewVariation(ctx context.Context, body ImageNewVariationParams, ...) (res *ImagesResponse, err error)
- type ImagesResponse
- type ImagesResponseUsage
- type ImagesResponseUsageInputTokensDetails
- type LabelModelGrader
- type LabelModelGraderInput
- type LabelModelGraderInputContentOutputText
- type LabelModelGraderInputContentOutputTextParam
- type LabelModelGraderInputContentUnion
- func (u LabelModelGraderInputContentUnion) AsInputText() (v responses.ResponseInputText)
- func (u LabelModelGraderInputContentUnion) AsOutputText() (v LabelModelGraderInputContentOutputText)
- func (u LabelModelGraderInputContentUnion) AsString() (v string)
- func (u LabelModelGraderInputContentUnion) RawJSON() string
- func (r *LabelModelGraderInputContentUnion) UnmarshalJSON(data []byte) error
- type LabelModelGraderInputContentUnionParam
- type LabelModelGraderInputParam
- type LabelModelGraderParam
- type Metadata
- type Model
- type ModelDeleted
- type ModelService
- func (r *ModelService) Delete(ctx context.Context, model string, opts ...option.RequestOption) (res *ModelDeleted, err error)
- func (r *ModelService) Get(ctx context.Context, model string, opts ...option.RequestOption) (res *Model, err error)
- func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.Page[Model], err error)
- func (r *ModelService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.PageAutoPager[Model]
- type Moderation
- type ModerationCategories
- type ModerationCategoryAppliedInputTypes
- type ModerationCategoryScores
- type ModerationImageURLInputImageURLParam
- type ModerationImageURLInputParam
- type ModerationModel
- type ModerationMultiModalInputUnionParam
- func (u ModerationMultiModalInputUnionParam) GetImageURL() *ModerationImageURLInputImageURLParam
- func (u ModerationMultiModalInputUnionParam) GetText() *string
- func (u ModerationMultiModalInputUnionParam) GetType() *string
- func (u ModerationMultiModalInputUnionParam) MarshalJSON() ([]byte, error)
- func (u *ModerationMultiModalInputUnionParam) UnmarshalJSON(data []byte) error
- type ModerationNewParams
- type ModerationNewParamsInputUnion
- type ModerationNewResponse
- type ModerationService
- type ModerationTextInputParam
- type MultiGrader
- type MultiGraderGraderUnion
- func (u MultiGraderGraderUnion) AsLabelModelGrader() (v LabelModelGrader)
- func (u MultiGraderGraderUnion) AsPythonGrader() (v PythonGrader)
- func (u MultiGraderGraderUnion) AsScoreModelGrader() (v ScoreModelGrader)
- func (u MultiGraderGraderUnion) AsStringCheckGrader() (v StringCheckGrader)
- func (u MultiGraderGraderUnion) AsTextSimilarityGrader() (v TextSimilarityGrader)
- func (u MultiGraderGraderUnion) RawJSON() string
- func (r *MultiGraderGraderUnion) UnmarshalJSON(data []byte) error
- type MultiGraderGraderUnionInput
- type MultiGraderGraderUnionParam
- func (u MultiGraderGraderUnionParam) GetEvaluationMetric() *string
- func (u MultiGraderGraderUnionParam) GetImageTag() *string
- func (u MultiGraderGraderUnionParam) GetInput() (res multiGraderGraderUnionParamInput)
- func (u MultiGraderGraderUnionParam) GetLabels() []string
- func (u MultiGraderGraderUnionParam) GetModel() *string
- func (u MultiGraderGraderUnionParam) GetName() *string
- func (u MultiGraderGraderUnionParam) GetOperation() *string
- func (u MultiGraderGraderUnionParam) GetPassingLabels() []string
- func (u MultiGraderGraderUnionParam) GetRange() []float64
- func (u MultiGraderGraderUnionParam) GetReference() *string
- func (u MultiGraderGraderUnionParam) GetSamplingParams() *any
- func (u MultiGraderGraderUnionParam) GetSource() *string
- func (u MultiGraderGraderUnionParam) GetType() *string
- func (u MultiGraderGraderUnionParam) MarshalJSON() ([]byte, error)
- func (u *MultiGraderGraderUnionParam) UnmarshalJSON(data []byte) error
- type MultiGraderParam
- type OtherFileChunkingStrategyObject
- type PythonGrader
- type PythonGraderParam
- type Reasoning
- type ReasoningEffort
- type ReasoningGenerateSummary
- type ReasoningParam
- type ReasoningSummary
- type ReinforcementComputeMultiplierUnion
- type ReinforcementComputeMultiplierUnionResp
- type ReinforcementEvalSamplesUnion
- type ReinforcementEvalSamplesUnionResp
- type ReinforcementHyperparameters
- type ReinforcementHyperparametersBatchSizeUnion
- type ReinforcementHyperparametersBatchSizeUnionResp
- func (u ReinforcementHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto)
- func (u ReinforcementHyperparametersBatchSizeUnionResp) AsInt() (v int64)
- func (u ReinforcementHyperparametersBatchSizeUnionResp) RawJSON() string
- func (r *ReinforcementHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error
- type ReinforcementHyperparametersEvalIntervalUnion
- type ReinforcementHyperparametersEvalIntervalUnionResp
- func (u ReinforcementHyperparametersEvalIntervalUnionResp) AsAuto() (v constant.Auto)
- func (u ReinforcementHyperparametersEvalIntervalUnionResp) AsInt() (v int64)
- func (u ReinforcementHyperparametersEvalIntervalUnionResp) RawJSON() string
- func (r *ReinforcementHyperparametersEvalIntervalUnionResp) UnmarshalJSON(data []byte) error
- type ReinforcementHyperparametersNEpochsUnion
- type ReinforcementHyperparametersNEpochsUnionResp
- func (u ReinforcementHyperparametersNEpochsUnionResp) AsAuto() (v constant.Auto)
- func (u ReinforcementHyperparametersNEpochsUnionResp) AsInt() (v int64)
- func (u ReinforcementHyperparametersNEpochsUnionResp) RawJSON() string
- func (r *ReinforcementHyperparametersNEpochsUnionResp) UnmarshalJSON(data []byte) error
- type ReinforcementHyperparametersReasoningEffort
- type ReinforcementHyperparametersResp
- type ReinforcementLearningRateMultiplierUnion
- type ReinforcementLearningRateMultiplierUnionResp
- func (u ReinforcementLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto)
- func (u ReinforcementLearningRateMultiplierUnionResp) AsFloat() (v float64)
- func (u ReinforcementLearningRateMultiplierUnionResp) RawJSON() string
- func (r *ReinforcementLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error
- type ReinforcementMethod
- type ReinforcementMethodGraderUnion
- func (u ReinforcementMethodGraderUnion) AsMultiGrader() (v MultiGrader)
- func (u ReinforcementMethodGraderUnion) AsPythonGrader() (v PythonGrader)
- func (u ReinforcementMethodGraderUnion) AsScoreModelGrader() (v ScoreModelGrader)
- func (u ReinforcementMethodGraderUnion) AsStringCheckGrader() (v StringCheckGrader)
- func (u ReinforcementMethodGraderUnion) AsTextSimilarityGrader() (v TextSimilarityGrader)
- func (u ReinforcementMethodGraderUnion) RawJSON() string
- func (r *ReinforcementMethodGraderUnion) UnmarshalJSON(data []byte) error
- type ReinforcementMethodGraderUnionInput
- type ReinforcementMethodGraderUnionParam
- func (u ReinforcementMethodGraderUnionParam) GetCalculateOutput() *string
- func (u ReinforcementMethodGraderUnionParam) GetEvaluationMetric() *string
- func (u ReinforcementMethodGraderUnionParam) GetGraders() map[string]MultiGraderGraderUnionParam
- func (u ReinforcementMethodGraderUnionParam) GetImageTag() *string
- func (u ReinforcementMethodGraderUnionParam) GetInput() (res reinforcementMethodGraderUnionParamInput)
- func (u ReinforcementMethodGraderUnionParam) GetModel() *string
- func (u ReinforcementMethodGraderUnionParam) GetName() *string
- func (u ReinforcementMethodGraderUnionParam) GetOperation() *string
- func (u ReinforcementMethodGraderUnionParam) GetRange() []float64
- func (u ReinforcementMethodGraderUnionParam) GetReference() *string
- func (u ReinforcementMethodGraderUnionParam) GetSamplingParams() *any
- func (u ReinforcementMethodGraderUnionParam) GetSource() *string
- func (u ReinforcementMethodGraderUnionParam) GetType() *string
- func (u ReinforcementMethodGraderUnionParam) MarshalJSON() ([]byte, error)
- func (u *ReinforcementMethodGraderUnionParam) UnmarshalJSON(data []byte) error
- type ReinforcementMethodParam
- type ResponseFormatJSONObject
- type ResponseFormatJSONObjectParam
- type ResponseFormatJSONSchemaJSONSchemaParam
- type ResponseFormatJSONSchemaParam
- type ResponseFormatText
- type ResponseFormatTextParam
- type ResponsesModel
- type ScoreModelGrader
- type ScoreModelGraderInput
- type ScoreModelGraderInputContentOutputText
- type ScoreModelGraderInputContentOutputTextParam
- type ScoreModelGraderInputContentUnion
- func (u ScoreModelGraderInputContentUnion) AsInputText() (v responses.ResponseInputText)
- func (u ScoreModelGraderInputContentUnion) AsOutputText() (v ScoreModelGraderInputContentOutputText)
- func (u ScoreModelGraderInputContentUnion) AsString() (v string)
- func (u ScoreModelGraderInputContentUnion) RawJSON() string
- func (r *ScoreModelGraderInputContentUnion) UnmarshalJSON(data []byte) error
- type ScoreModelGraderInputContentUnionParam
- type ScoreModelGraderInputParam
- type ScoreModelGraderParam
- type SpeechModel
- type StaticFileChunkingStrategy
- type StaticFileChunkingStrategyObject
- type StaticFileChunkingStrategyObjectParam
- type StaticFileChunkingStrategyParam
- type StringCheckGrader
- type StringCheckGraderOperation
- type StringCheckGraderParam
- type SupervisedHyperparameters
- type SupervisedHyperparametersBatchSizeUnion
- type SupervisedHyperparametersBatchSizeUnionResp
- func (u SupervisedHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto)
- func (u SupervisedHyperparametersBatchSizeUnionResp) AsInt() (v int64)
- func (u SupervisedHyperparametersBatchSizeUnionResp) RawJSON() string
- func (r *SupervisedHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error
- type SupervisedHyperparametersLearningRateMultiplierUnion
- type SupervisedHyperparametersLearningRateMultiplierUnionResp
- func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto)
- func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) AsFloat() (v float64)
- func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) RawJSON() string
- func (r *SupervisedHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error
- type SupervisedHyperparametersNEpochsUnion
- type SupervisedHyperparametersNEpochsUnionResp
- type SupervisedHyperparametersResp
- type SupervisedMethod
- type SupervisedMethodParam
- type TextSimilarityGrader
- type TextSimilarityGraderEvaluationMetric
- type TextSimilarityGraderParam
- type Transcription
- type TranscriptionInclude
- type TranscriptionLogprob
- type TranscriptionStreamEventUnion
- func (u TranscriptionStreamEventUnion) AsAny() anyTranscriptionStreamEvent
- func (u TranscriptionStreamEventUnion) AsTranscriptTextDelta() (v TranscriptionTextDeltaEvent)
- func (u TranscriptionStreamEventUnion) AsTranscriptTextDone() (v TranscriptionTextDoneEvent)
- func (u TranscriptionStreamEventUnion) RawJSON() string
- func (r *TranscriptionStreamEventUnion) UnmarshalJSON(data []byte) error
- type TranscriptionStreamEventUnionLogprobs
- type TranscriptionTextDeltaEvent
- type TranscriptionTextDeltaEventLogprob
- type TranscriptionTextDoneEvent
- type TranscriptionTextDoneEventLogprob
- type Translation
- type Upload
- type UploadCompleteParams
- type UploadNewParams
- type UploadPart
- type UploadPartNewParams
- type UploadPartService
- type UploadService
- func (r *UploadService) Cancel(ctx context.Context, uploadID string, opts ...option.RequestOption) (res *Upload, err error)
- func (r *UploadService) Complete(ctx context.Context, uploadID string, body UploadCompleteParams, ...) (res *Upload, err error)
- func (r *UploadService) New(ctx context.Context, body UploadNewParams, opts ...option.RequestOption) (res *Upload, err error)
- type UploadStatus
- type VectorStore
- type VectorStoreDeleted
- type VectorStoreExpiresAfter
- type VectorStoreFile
- type VectorStoreFileAttributeUnion
- func (u VectorStoreFileAttributeUnion) AsBool() (v bool)
- func (u VectorStoreFileAttributeUnion) AsFloat() (v float64)
- func (u VectorStoreFileAttributeUnion) AsString() (v string)
- func (u VectorStoreFileAttributeUnion) RawJSON() string
- func (r *VectorStoreFileAttributeUnion) UnmarshalJSON(data []byte) error
- type VectorStoreFileBatch
- type VectorStoreFileBatchCancelParams
- type VectorStoreFileBatchFileCounts
- type VectorStoreFileBatchGetParams
- type VectorStoreFileBatchListFilesParams
- type VectorStoreFileBatchListFilesParamsFilter
- type VectorStoreFileBatchListFilesParamsOrder
- type VectorStoreFileBatchNewParams
- type VectorStoreFileBatchNewParamsAttributeUnion
- type VectorStoreFileBatchService
- func (r *VectorStoreFileBatchService) Cancel(ctx context.Context, batchID string, body VectorStoreFileBatchCancelParams, ...) (res *VectorStoreFileBatch, err error)
- func (r *VectorStoreFileBatchService) Get(ctx context.Context, batchID string, query VectorStoreFileBatchGetParams, ...) (res *VectorStoreFileBatch, err error)
- func (r *VectorStoreFileBatchService) ListFiles(ctx context.Context, batchID string, ...) (res *pagination.CursorPage[VectorStoreFile], err error)
- func (r *VectorStoreFileBatchService) ListFilesAutoPaging(ctx context.Context, batchID string, ...) *pagination.CursorPageAutoPager[VectorStoreFile]
- func (r *VectorStoreFileBatchService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileBatchNewParams, ...) (res *VectorStoreFileBatch, err error)
- func (r *VectorStoreFileBatchService) NewAndPoll(ctx context.Context, vectorStoreId string, body VectorStoreFileBatchNewParams, ...) (res *VectorStoreFileBatch, err error)
- func (r *VectorStoreFileBatchService) PollStatus(ctx context.Context, vectorStoreID string, batchID string, pollIntervalMs int, ...) (*VectorStoreFileBatch, error)
- func (r *VectorStoreFileBatchService) UploadAndPoll(ctx context.Context, vectorStoreID string, files []FileNewParams, ...) (*VectorStoreFileBatch, error)
- type VectorStoreFileBatchStatus
- type VectorStoreFileContentParams
- type VectorStoreFileContentResponse
- type VectorStoreFileCounts
- type VectorStoreFileDeleteParams
- type VectorStoreFileDeleted
- type VectorStoreFileGetParams
- type VectorStoreFileLastError
- type VectorStoreFileListParams
- type VectorStoreFileListParamsFilter
- type VectorStoreFileListParamsOrder
- type VectorStoreFileNewParams
- type VectorStoreFileNewParamsAttributeUnion
- type VectorStoreFileService
- func (r *VectorStoreFileService) Content(ctx context.Context, fileID string, query VectorStoreFileContentParams, ...) (res *pagination.Page[VectorStoreFileContentResponse], err error)
- func (r *VectorStoreFileService) ContentAutoPaging(ctx context.Context, fileID string, query VectorStoreFileContentParams, ...) *pagination.PageAutoPager[VectorStoreFileContentResponse]
- func (r *VectorStoreFileService) Delete(ctx context.Context, fileID string, body VectorStoreFileDeleteParams, ...) (res *VectorStoreFileDeleted, err error)
- func (r *VectorStoreFileService) Get(ctx context.Context, fileID string, query VectorStoreFileGetParams, ...) (res *VectorStoreFile, err error)
- func (r *VectorStoreFileService) List(ctx context.Context, vectorStoreID string, query VectorStoreFileListParams, ...) (res *pagination.CursorPage[VectorStoreFile], err error)
- func (r *VectorStoreFileService) ListAutoPaging(ctx context.Context, vectorStoreID string, query VectorStoreFileListParams, ...) *pagination.CursorPageAutoPager[VectorStoreFile]
- func (r *VectorStoreFileService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileNewParams, ...) (res *VectorStoreFile, err error)
- func (r *VectorStoreFileService) NewAndPoll(ctx context.Context, vectorStoreId string, body VectorStoreFileNewParams, ...) (res *VectorStoreFile, err error)
- func (r *VectorStoreFileService) PollStatus(ctx context.Context, vectorStoreID string, fileID string, pollIntervalMs int, ...) (*VectorStoreFile, error)
- func (r *VectorStoreFileService) Update(ctx context.Context, fileID string, params VectorStoreFileUpdateParams, ...) (res *VectorStoreFile, err error)
- func (r *VectorStoreFileService) Upload(ctx context.Context, vectorStoreID string, body FileNewParams, ...) (*VectorStoreFile, error)
- func (r *VectorStoreFileService) UploadAndPoll(ctx context.Context, vectorStoreID string, body FileNewParams, ...) (*VectorStoreFile, error)
- type VectorStoreFileStatus
- type VectorStoreFileUpdateParams
- type VectorStoreFileUpdateParamsAttributeUnion
- type VectorStoreListParams
- type VectorStoreListParamsOrder
- type VectorStoreNewParams
- type VectorStoreNewParamsExpiresAfter
- type VectorStoreSearchParams
- type VectorStoreSearchParamsFiltersUnion
- func (u VectorStoreSearchParamsFiltersUnion) GetFilters() []shared.ComparisonFilterParam
- func (u VectorStoreSearchParamsFiltersUnion) GetKey() *string
- func (u VectorStoreSearchParamsFiltersUnion) GetType() *string
- func (u VectorStoreSearchParamsFiltersUnion) GetValue() *shared.ComparisonFilterValueUnionParam
- func (u VectorStoreSearchParamsFiltersUnion) MarshalJSON() ([]byte, error)
- func (u *VectorStoreSearchParamsFiltersUnion) UnmarshalJSON(data []byte) error
- type VectorStoreSearchParamsQueryUnion
- type VectorStoreSearchParamsRankingOptions
- type VectorStoreSearchResponse
- type VectorStoreSearchResponseAttributeUnion
- func (u VectorStoreSearchResponseAttributeUnion) AsBool() (v bool)
- func (u VectorStoreSearchResponseAttributeUnion) AsFloat() (v float64)
- func (u VectorStoreSearchResponseAttributeUnion) AsString() (v string)
- func (u VectorStoreSearchResponseAttributeUnion) RawJSON() string
- func (r *VectorStoreSearchResponseAttributeUnion) UnmarshalJSON(data []byte) error
- type VectorStoreSearchResponseContent
- type VectorStoreService
- func (r *VectorStoreService) Delete(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStoreDeleted, err error)
- func (r *VectorStoreService) Get(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStore, err error)
- func (r *VectorStoreService) List(ctx context.Context, query VectorStoreListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStore], err error)
- func (r *VectorStoreService) ListAutoPaging(ctx context.Context, query VectorStoreListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[VectorStore]
- func (r *VectorStoreService) New(ctx context.Context, body VectorStoreNewParams, opts ...option.RequestOption) (res *VectorStore, err error)
- func (r *VectorStoreService) Search(ctx context.Context, vectorStoreID string, body VectorStoreSearchParams, ...) (res *pagination.Page[VectorStoreSearchResponse], err error)
- func (r *VectorStoreService) SearchAutoPaging(ctx context.Context, vectorStoreID string, body VectorStoreSearchParams, ...) *pagination.PageAutoPager[VectorStoreSearchResponse]
- func (r *VectorStoreService) Update(ctx context.Context, vectorStoreID string, body VectorStoreUpdateParams, ...) (res *VectorStore, err error)
- type VectorStoreStatus
- type VectorStoreUpdateParams
- type VectorStoreUpdateParamsExpiresAfter
Constants ¶
const ChatModelChatgpt4oLatest = shared.ChatModelChatgpt4oLatest
Equals "chatgpt-4o-latest"
const ChatModelCodexMiniLatest = shared.ChatModelCodexMiniLatest
Equals "codex-mini-latest"
const ChatModelGPT3_5Turbo = shared.ChatModelGPT3_5Turbo
Equals "gpt-3.5-turbo"
const ChatModelGPT3_5Turbo0125 = shared.ChatModelGPT3_5Turbo0125
Equals "gpt-3.5-turbo-0125"
const ChatModelGPT3_5Turbo0301 = shared.ChatModelGPT3_5Turbo0301
Equals "gpt-3.5-turbo-0301"
const ChatModelGPT3_5Turbo0613 = shared.ChatModelGPT3_5Turbo0613
Equals "gpt-3.5-turbo-0613"
const ChatModelGPT3_5Turbo1106 = shared.ChatModelGPT3_5Turbo1106
Equals "gpt-3.5-turbo-1106"
const ChatModelGPT3_5Turbo16k = shared.ChatModelGPT3_5Turbo16k
Equals "gpt-3.5-turbo-16k"
const ChatModelGPT3_5Turbo16k0613 = shared.ChatModelGPT3_5Turbo16k0613
Equals "gpt-3.5-turbo-16k-0613"
const ChatModelGPT4 = shared.ChatModelGPT4
Equals "gpt-4"
const ChatModelGPT4Turbo = shared.ChatModelGPT4Turbo
Equals "gpt-4-turbo"
const ChatModelGPT4Turbo2024_04_09 = shared.ChatModelGPT4Turbo2024_04_09
Equals "gpt-4-turbo-2024-04-09"
const ChatModelGPT4TurboPreview = shared.ChatModelGPT4TurboPreview
Equals "gpt-4-turbo-preview"
const ChatModelGPT4VisionPreview = shared.ChatModelGPT4VisionPreview
Equals "gpt-4-vision-preview"
const ChatModelGPT4_0125Preview = shared.ChatModelGPT4_0125Preview
Equals "gpt-4-0125-preview"
const ChatModelGPT4_0314 = shared.ChatModelGPT4_0314
Equals "gpt-4-0314"
const ChatModelGPT4_0613 = shared.ChatModelGPT4_0613
Equals "gpt-4-0613"
const ChatModelGPT4_1 = shared.ChatModelGPT4_1
Equals "gpt-4.1"
const ChatModelGPT4_1106Preview = shared.ChatModelGPT4_1106Preview
Equals "gpt-4-1106-preview"
const ChatModelGPT4_1Mini = shared.ChatModelGPT4_1Mini
Equals "gpt-4.1-mini"
const ChatModelGPT4_1Mini2025_04_14 = shared.ChatModelGPT4_1Mini2025_04_14
Equals "gpt-4.1-mini-2025-04-14"
const ChatModelGPT4_1Nano = shared.ChatModelGPT4_1Nano
Equals "gpt-4.1-nano"
const ChatModelGPT4_1Nano2025_04_14 = shared.ChatModelGPT4_1Nano2025_04_14
Equals "gpt-4.1-nano-2025-04-14"
const ChatModelGPT4_1_2025_04_14 = shared.ChatModelGPT4_1_2025_04_14
Equals "gpt-4.1-2025-04-14"
const ChatModelGPT4_32k = shared.ChatModelGPT4_32k
Equals "gpt-4-32k"
const ChatModelGPT4_32k0314 = shared.ChatModelGPT4_32k0314
Equals "gpt-4-32k-0314"
const ChatModelGPT4_32k0613 = shared.ChatModelGPT4_32k0613
Equals "gpt-4-32k-0613"
const ChatModelGPT4o = shared.ChatModelGPT4o
Equals "gpt-4o"
const ChatModelGPT4o2024_05_13 = shared.ChatModelGPT4o2024_05_13
Equals "gpt-4o-2024-05-13"
const ChatModelGPT4o2024_08_06 = shared.ChatModelGPT4o2024_08_06
Equals "gpt-4o-2024-08-06"
const ChatModelGPT4o2024_11_20 = shared.ChatModelGPT4o2024_11_20
Equals "gpt-4o-2024-11-20"
const ChatModelGPT4oAudioPreview = shared.ChatModelGPT4oAudioPreview
Equals "gpt-4o-audio-preview"
const ChatModelGPT4oAudioPreview2024_10_01 = shared.ChatModelGPT4oAudioPreview2024_10_01
Equals "gpt-4o-audio-preview-2024-10-01"
const ChatModelGPT4oAudioPreview2024_12_17 = shared.ChatModelGPT4oAudioPreview2024_12_17
Equals "gpt-4o-audio-preview-2024-12-17"
const ChatModelGPT4oMini = shared.ChatModelGPT4oMini
Equals "gpt-4o-mini"
const ChatModelGPT4oMini2024_07_18 = shared.ChatModelGPT4oMini2024_07_18
Equals "gpt-4o-mini-2024-07-18"
const ChatModelGPT4oMiniAudioPreview = shared.ChatModelGPT4oMiniAudioPreview
Equals "gpt-4o-mini-audio-preview"
const ChatModelGPT4oMiniAudioPreview2024_12_17 = shared.ChatModelGPT4oMiniAudioPreview2024_12_17
Equals "gpt-4o-mini-audio-preview-2024-12-17"
const ChatModelGPT4oMiniSearchPreview = shared.ChatModelGPT4oMiniSearchPreview
Equals "gpt-4o-mini-search-preview"
const ChatModelGPT4oMiniSearchPreview2025_03_11 = shared.ChatModelGPT4oMiniSearchPreview2025_03_11
Equals "gpt-4o-mini-search-preview-2025-03-11"
const ChatModelGPT4oSearchPreview = shared.ChatModelGPT4oSearchPreview
Equals "gpt-4o-search-preview"
const ChatModelGPT4oSearchPreview2025_03_11 = shared.ChatModelGPT4oSearchPreview2025_03_11
Equals "gpt-4o-search-preview-2025-03-11"
const ChatModelO1 = shared.ChatModelO1
Equals "o1"
const ChatModelO1Mini = shared.ChatModelO1Mini
Equals "o1-mini"
const ChatModelO1Mini2024_09_12 = shared.ChatModelO1Mini2024_09_12
Equals "o1-mini-2024-09-12"
const ChatModelO1Preview = shared.ChatModelO1Preview
Equals "o1-preview"
const ChatModelO1Preview2024_09_12 = shared.ChatModelO1Preview2024_09_12
Equals "o1-preview-2024-09-12"
const ChatModelO1_2024_12_17 = shared.ChatModelO1_2024_12_17
Equals "o1-2024-12-17"
const ChatModelO3 = shared.ChatModelO3
Equals "o3"
const ChatModelO3Mini = shared.ChatModelO3Mini
Equals "o3-mini"
const ChatModelO3Mini2025_01_31 = shared.ChatModelO3Mini2025_01_31
Equals "o3-mini-2025-01-31"
const ChatModelO3_2025_04_16 = shared.ChatModelO3_2025_04_16
Equals "o3-2025-04-16"
const ChatModelO4Mini = shared.ChatModelO4Mini
Equals "o4-mini"
const ChatModelO4Mini2025_04_16 = shared.ChatModelO4Mini2025_04_16
Equals "o4-mini-2025-04-16"
const ComparisonFilterTypeEq = shared.ComparisonFilterTypeEq
Equals "eq"
const ComparisonFilterTypeGt = shared.ComparisonFilterTypeGt
Equals "gt"
const ComparisonFilterTypeGte = shared.ComparisonFilterTypeGte
Equals "gte"
const ComparisonFilterTypeLt = shared.ComparisonFilterTypeLt
Equals "lt"
const ComparisonFilterTypeLte = shared.ComparisonFilterTypeLte
Equals "lte"
const ComparisonFilterTypeNe = shared.ComparisonFilterTypeNe
Equals "ne"
const CompoundFilterTypeAnd = shared.CompoundFilterTypeAnd
Equals "and"
const CompoundFilterTypeOr = shared.CompoundFilterTypeOr
Equals "or"
const ReasoningEffortHigh = shared.ReasoningEffortHigh
Equals "high"
const ReasoningEffortLow = shared.ReasoningEffortLow
Equals "low"
const ReasoningEffortMedium = shared.ReasoningEffortMedium
Equals "medium"
const ReasoningGenerateSummaryAuto = shared.ReasoningGenerateSummaryAuto
Equals "auto"
const ReasoningGenerateSummaryConcise = shared.ReasoningGenerateSummaryConcise
Equals "concise"
const ReasoningGenerateSummaryDetailed = shared.ReasoningGenerateSummaryDetailed
Equals "detailed"
const ReasoningSummaryAuto = shared.ReasoningSummaryAuto
Equals "auto"
const ReasoningSummaryConcise = shared.ReasoningSummaryConcise
Equals "concise"
const ReasoningSummaryDetailed = shared.ReasoningSummaryDetailed
Equals "detailed"
const ResponsesModelComputerUsePreview = shared.ResponsesModelComputerUsePreview
Equals "computer-use-preview"
const ResponsesModelComputerUsePreview2025_03_11 = shared.ResponsesModelComputerUsePreview2025_03_11
Equals "computer-use-preview-2025-03-11"
const ResponsesModelO1Pro = shared.ResponsesModelO1Pro
Equals "o1-pro"
const ResponsesModelO1Pro2025_03_19 = shared.ResponsesModelO1Pro2025_03_19
Equals "o1-pro-2025-03-19"
Variables ¶
This section is empty.
Functions ¶
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 Opt ¶
func Opt[T comparable](v T) param.Opt[T]
Types ¶
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. Does not work with `gpt-4o-mini-tts`.
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"`
// 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 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 ¶
func (r *AudioSpeechService) New(ctx context.Context, body AudioSpeechNewParams, opts ...option.RequestOption) (res *http.Response, err error)
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 (u AudioTranscriptionNewParamsChunkingStrategyUnion) MarshalJSON() ([]byte, error)
func (*AudioTranscriptionNewParamsChunkingStrategyUnion) UnmarshalJSON ¶
func (u *AudioTranscriptionNewParamsChunkingStrategyUnion) UnmarshalJSON(data []byte) error
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 ¶
func (r *AudioTranscriptionNewParamsChunkingStrategyVadConfig) UnmarshalJSON(data []byte) error
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 ¶
func (r *AudioTranscriptionService) New(ctx context.Context, body AudioTranscriptionNewParams, opts ...option.RequestOption) (res *Transcription, err error)
Transcribes audio into the input language.
func (*AudioTranscriptionService) NewStreaming ¶
func (r *AudioTranscriptionService) NewStreaming(ctx context.Context, body AudioTranscriptionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[TranscriptionStreamEventUnion])
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 ¶
func (r *AudioTranslationService) New(ctx context.Context, body AudioTranslationNewParams, opts ...option.RequestOption) (res *Translation, err error)
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) UnmarshalJSON ¶
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 ¶
func (r *BatchService) ListAutoPaging(ctx context.Context, query BatchListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[Batch]
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 BetaService ¶
type BetaService struct {
Options []option.RequestOption
}
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 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 guarentee.
// - If set to 'default', the request will be processed using the default service
// tier with a lower uptime SLA and no latency guarentee.
// - 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".
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 ChatCompletionAssistantMessageParamContentUnion ¶
type ChatCompletionAssistantMessageParamContentUnion struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfArrayOfContentParts []ChatCompletionAssistantMessagePartUnion `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 (u ChatCompletionAssistantMessageParamContentUnion) MarshalJSON() ([]byte, error)
func (*ChatCompletionAssistantMessageParamContentUnion) UnmarshalJSON ¶
func (u *ChatCompletionAssistantMessageParamContentUnion) UnmarshalJSON(data []byte) error
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 ¶
func (r *ChatCompletionAssistantMessageParamFunctionCall) UnmarshalJSON(data []byte) error
type ChatCompletionAssistantMessagePartUnion ¶
type ChatCompletionAssistantMessagePartUnion 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 (ChatCompletionAssistantMessagePartUnion) GetRefusal ¶
func (u ChatCompletionAssistantMessagePartUnion) GetRefusal() *string
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionAssistantMessagePartUnion) GetText ¶
func (u ChatCompletionAssistantMessagePartUnion) GetText() *string
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionAssistantMessagePartUnion) GetType ¶
func (u ChatCompletionAssistantMessagePartUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionAssistantMessagePartUnion) MarshalJSON ¶
func (u ChatCompletionAssistantMessagePartUnion) MarshalJSON() ([]byte, error)
func (*ChatCompletionAssistantMessagePartUnion) UnmarshalJSON ¶
func (u *ChatCompletionAssistantMessagePartUnion) UnmarshalJSON(data []byte) error
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 ¶
func (r ChatCompletionChoiceLogprobs) RawJSON() string
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 guarentee.
// - If set to 'default', the request will be processed using the default service
// tier with a lower uptime SLA and no latency guarentee.
// - 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".
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 []ChatCompletionToolCallDelta `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 ¶
func (r ChatCompletionChunkChoiceDelta) RawJSON() string
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 ¶
func (r ChatCompletionChunkChoiceDeltaFunctionCall) RawJSON() string
Returns the unmodified JSON received from the API
func (*ChatCompletionChunkChoiceDeltaFunctionCall) UnmarshalJSON ¶
func (r *ChatCompletionChunkChoiceDeltaFunctionCall) 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 ¶
func (r ChatCompletionChunkChoiceDeltaToolCallFunction) RawJSON() string
Returns the unmodified JSON received from the API
func (*ChatCompletionChunkChoiceDeltaToolCallFunction) UnmarshalJSON ¶
func (r *ChatCompletionChunkChoiceDeltaToolCallFunction) UnmarshalJSON(data []byte) error
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 ¶
func (r ChatCompletionChunkChoiceLogprobs) RawJSON() string
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 guarentee.
- If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
- 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" )
type ChatCompletionContentPartFileParam ¶
type ChatCompletionContentPartFileParam struct {
File ChatCompletionFileContentPartParam `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 ChatCompletionContentPartInputAudioParam ¶
type ChatCompletionContentPartInputAudioParam struct {
InputAudio ChatCompletionInputAudioDataParam `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 FileContentPart ¶
func FileContentPart(file ChatCompletionFileContentPartParam) ChatCompletionContentPartUnionParam
func ImageContentPart ¶
func ImageContentPart(imageURL ChatCompletionContentPartImageImageURLParam) ChatCompletionContentPartUnionParam
func InputAudioContentPart ¶
func InputAudioContentPart(inputAudio ChatCompletionInputAudioDataParam) ChatCompletionContentPartUnionParam
func TextContentPart ¶
func TextContentPart(text string) ChatCompletionContentPartUnionParam
func (ChatCompletionContentPartUnionParam) GetFile ¶
func (u ChatCompletionContentPartUnionParam) GetFile() *ChatCompletionFileContentPartParam
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionContentPartUnionParam) GetImageURL ¶
func (u ChatCompletionContentPartUnionParam) GetImageURL() *ChatCompletionContentPartImageImageURLParam
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionContentPartUnionParam) GetInputAudio ¶
func (u ChatCompletionContentPartUnionParam) GetInputAudio() *ChatCompletionInputAudioDataParam
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionContentPartUnionParam) GetText ¶
func (u ChatCompletionContentPartUnionParam) GetText() *string
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionContentPartUnionParam) GetType ¶
func (u ChatCompletionContentPartUnionParam) GetType() *string
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 (u ChatCompletionDeveloperMessageParamContentUnion) MarshalJSON() ([]byte, error)
func (*ChatCompletionDeveloperMessageParamContentUnion) UnmarshalJSON ¶
func (u *ChatCompletionDeveloperMessageParamContentUnion) UnmarshalJSON(data []byte) error
type ChatCompletionFileContentPartParam ¶
type ChatCompletionFileContentPartParam 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 (ChatCompletionFileContentPartParam) MarshalJSON ¶
func (r ChatCompletionFileContentPartParam) MarshalJSON() (data []byte, err error)
func (*ChatCompletionFileContentPartParam) UnmarshalJSON ¶
func (r *ChatCompletionFileContentPartParam) UnmarshalJSON(data []byte) error
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 ChatCompletionInputAudioDataParam ¶
type ChatCompletionInputAudioDataParam 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 (ChatCompletionInputAudioDataParam) MarshalJSON ¶
func (r ChatCompletionInputAudioDataParam) MarshalJSON() (data []byte, err error)
func (*ChatCompletionInputAudioDataParam) UnmarshalJSON ¶
func (r *ChatCompletionInputAudioDataParam) 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 (r ChatCompletionMessage) ToParam() ChatCompletionMessageParamUnion
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 ¶
func (r ChatCompletionMessageAnnotation) RawJSON() string
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 ¶
func (r ChatCompletionMessageAnnotationURLCitation) RawJSON() string
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 ¶
func (r ChatCompletionMessageFunctionCall) RawJSON() string
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 AssistantMessage ¶
func AssistantMessage[T string | []ChatCompletionAssistantMessagePartUnion](content T) ChatCompletionMessageParamUnion
func ChatCompletionMessageParamOfFunction ¶
func ChatCompletionMessageParamOfFunction(content string, name string) ChatCompletionMessageParamUnion
func DeveloperMessage ¶
func DeveloperMessage[T string | []ChatCompletionContentPartTextParam](content T) ChatCompletionMessageParamUnion
func SystemMessage ¶
func SystemMessage[T string | []ChatCompletionContentPartTextParam](content T) ChatCompletionMessageParamUnion
func ToolMessage ¶
func ToolMessage[T string | []ChatCompletionContentPartTextParam](content T, toolCallID string) ChatCompletionMessageParamUnion
func UserMessage ¶
func UserMessage[T string | []ChatCompletionContentPartUnionParam](content T) ChatCompletionMessageParamUnion
func (ChatCompletionMessageParamUnion) GetAudio ¶
func (u ChatCompletionMessageParamUnion) GetAudio() *ChatCompletionAssistantMessageParamAudio
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 ¶
func (u ChatCompletionMessageParamUnion) GetFunctionCall() *ChatCompletionAssistantMessageParamFunctionCall
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionMessageParamUnion) GetName ¶
func (u ChatCompletionMessageParamUnion) GetName() *string
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 ¶
func (u ChatCompletionMessageParamUnion) GetRole() *string
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 ¶
func (u ChatCompletionMessageParamUnion) GetToolCalls() []ChatCompletionMessageToolCallParam
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 ¶
func (r *ChatCompletionMessageService) List(ctx context.Context, completionID string, query ChatCompletionMessageListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ChatCompletionStoreMessage], err error)
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 ¶
func (r *ChatCompletionMessageService) ListAutoPaging(ctx context.Context, completionID string, query ChatCompletionMessageListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[ChatCompletionStoreMessage]
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 ¶
func (r ChatCompletionMessageToolCall) RawJSON() string
Returns the unmodified JSON received from the API
func (ChatCompletionMessageToolCall) ToParam ¶
func (r ChatCompletionMessageToolCall) ToParam() ChatCompletionMessageToolCallParam
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 ¶
func (r ChatCompletionMessageToolCallFunction) RawJSON() string
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 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"`
// 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 guarentee.
// - If set to 'default', the request will be processed using the default service
// tier with a lower uptime SLA and no latency guarentee.
// - 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".
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 (u ChatCompletionNewParamsFunctionCallUnion) MarshalJSON() ([]byte, error)
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 ¶
func (u ChatCompletionNewParamsResponseFormatUnion) GetJSONSchema() *shared.ResponseFormatJSONSchemaJSONSchemaParam
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionNewParamsResponseFormatUnion) GetType ¶
func (u ChatCompletionNewParamsResponseFormatUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (ChatCompletionNewParamsResponseFormatUnion) MarshalJSON ¶
func (u ChatCompletionNewParamsResponseFormatUnion) MarshalJSON() ([]byte, error)
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 guarentee.
- If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
- 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" )
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 ChatCompletionWebSearchUserLocation `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 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 (u ChatCompletionPredictionContentContentUnionParam) MarshalJSON() ([]byte, error)
func (*ChatCompletionPredictionContentContentUnionParam) UnmarshalJSON ¶
func (u *ChatCompletionPredictionContentContentUnionParam) UnmarshalJSON(data []byte) error
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 ¶
func (r *ChatCompletionService) List(ctx context.Context, query ChatCompletionListParams, opts ...option.RequestOption) (res *pagination.CursorPage[ChatCompletion], err error)
List stored Chat Completions. Only Chat Completions that have been stored with the `store` parameter set to `true` will be returned.
func (*ChatCompletionService) ListAutoPaging ¶
func (r *ChatCompletionService) ListAutoPaging(ctx context.Context, query ChatCompletionListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[ChatCompletion]
List stored Chat Completions. Only Chat Completions that have been stored with the `store` parameter set to `true` will be returned.
func (*ChatCompletionService) New ¶
func (r *ChatCompletionService) New(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (res *ChatCompletion, err error)
**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 ¶
func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[ChatCompletionChunk])
**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 guarentee.
- If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
- 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" )
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 (u ChatCompletionSystemMessageParamContentUnion) MarshalJSON() ([]byte, error)
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 ¶
func (r ChatCompletionTokenLogprobTopLogprob) RawJSON() string
Returns the unmodified JSON received from the API
func (*ChatCompletionTokenLogprobTopLogprob) UnmarshalJSON ¶
func (r *ChatCompletionTokenLogprobTopLogprob) UnmarshalJSON(data []byte) error
type ChatCompletionToolCallDelta ¶
type ChatCompletionToolCallDelta 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 (ChatCompletionToolCallDelta) RawJSON ¶
func (r ChatCompletionToolCallDelta) RawJSON() string
Returns the unmodified JSON received from the API
func (*ChatCompletionToolCallDelta) UnmarshalJSON ¶
func (r *ChatCompletionToolCallDelta) 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 ToolChoiceNamedFunction ¶
func ToolChoiceNamedFunction(function ChatCompletionNamedToolChoiceFunctionParam) ChatCompletionToolChoiceOptionUnionParam
func (ChatCompletionToolChoiceOptionUnionParam) MarshalJSON ¶
func (u ChatCompletionToolChoiceOptionUnionParam) MarshalJSON() ([]byte, error)
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 (u ChatCompletionToolMessageParamContentUnion) MarshalJSON() ([]byte, error)
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 (u ChatCompletionUserMessageParamContentUnion) MarshalJSON() ([]byte, error)
func (*ChatCompletionUserMessageParamContentUnion) UnmarshalJSON ¶
func (u *ChatCompletionUserMessageParamContentUnion) UnmarshalJSON(data []byte) error
type ChatCompletionWebSearchApproximateUserLocation ¶
type ChatCompletionWebSearchApproximateUserLocation 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 (ChatCompletionWebSearchApproximateUserLocation) MarshalJSON ¶
func (r ChatCompletionWebSearchApproximateUserLocation) MarshalJSON() (data []byte, err error)
func (*ChatCompletionWebSearchApproximateUserLocation) UnmarshalJSON ¶
func (r *ChatCompletionWebSearchApproximateUserLocation) UnmarshalJSON(data []byte) error
type ChatCompletionWebSearchUserLocation ¶
type ChatCompletionWebSearchUserLocation struct {
// Approximate location parameters for the search.
Approximate ChatCompletionWebSearchApproximateUserLocation `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 (ChatCompletionWebSearchUserLocation) MarshalJSON ¶
func (r ChatCompletionWebSearchUserLocation) MarshalJSON() (data []byte, err error)
func (*ChatCompletionWebSearchUserLocation) UnmarshalJSON ¶
func (r *ChatCompletionWebSearchUserLocation) UnmarshalJSON(data []byte) error
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
}
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.
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 ¶
func (r *CompletionService) New(ctx context.Context, body CompletionNewParams, opts ...option.RequestOption) (res *Completion, err error)
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 ¶
func (r CompletionUsageCompletionTokensDetails) RawJSON() string
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 ¶
func (r CompletionUsagePromptTokensDetails) RawJSON() string
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 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 ¶
func (r CreateEmbeddingResponseUsage) RawJSON() string
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 (u DpoHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto)
func (DpoHyperparametersBatchSizeUnionResp) AsInt ¶
func (u DpoHyperparametersBatchSizeUnionResp) AsInt() (v int64)
func (DpoHyperparametersBatchSizeUnionResp) RawJSON ¶
func (u DpoHyperparametersBatchSizeUnionResp) RawJSON() string
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 (u DpoHyperparametersBetaUnionResp) AsAuto() (v constant.Auto)
func (DpoHyperparametersBetaUnionResp) AsFloat ¶
func (u DpoHyperparametersBetaUnionResp) AsFloat() (v float64)
func (DpoHyperparametersBetaUnionResp) RawJSON ¶
func (u DpoHyperparametersBetaUnionResp) RawJSON() string
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 (u DpoHyperparametersLearningRateMultiplierUnion) MarshalJSON() ([]byte, error)
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 (u DpoHyperparametersLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto)
func (DpoHyperparametersLearningRateMultiplierUnionResp) AsFloat ¶
func (u DpoHyperparametersLearningRateMultiplierUnionResp) AsFloat() (v float64)
func (DpoHyperparametersLearningRateMultiplierUnionResp) RawJSON ¶
func (u DpoHyperparametersLearningRateMultiplierUnionResp) RawJSON() string
Returns the unmodified JSON received from the API
func (*DpoHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON ¶
func (r *DpoHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error
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 (u DpoHyperparametersNEpochsUnionResp) AsAuto() (v constant.Auto)
func (DpoHyperparametersNEpochsUnionResp) AsInt ¶
func (u DpoHyperparametersNEpochsUnionResp) AsInt() (v int64)
func (DpoHyperparametersNEpochsUnionResp) RawJSON ¶
func (u DpoHyperparametersNEpochsUnionResp) RawJSON() string
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 ¶
func (r DpoHyperparametersResp) ToParam() DpoHyperparameters
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) 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 ¶
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) UnmarshalJSON ¶
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 ¶
func (r *EmbeddingService) New(ctx context.Context, body EmbeddingNewParams, opts ...option.RequestOption) (res *CreateEmbeddingResponse, err error)
Creates an embedding vector representing the input text.
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 FileChunkingStrategyParamOfStatic ¶
func FileChunkingStrategyParamOfStatic(static StaticFileChunkingStrategyParam) FileChunkingStrategyParamUnion
func (FileChunkingStrategyParamUnion) GetStatic ¶
func (u FileChunkingStrategyParamUnion) GetStatic() *StaticFileChunkingStrategyParam
Returns a pointer to the underlying variant's property, if present.
func (FileChunkingStrategyParamUnion) GetType ¶
func (u FileChunkingStrategyParamUnion) GetType() *string
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 (u FileChunkingStrategyUnion) AsOther() (v OtherFileChunkingStrategyObject)
func (FileChunkingStrategyUnion) AsStatic ¶
func (u FileChunkingStrategyUnion) AsStatic() (v StaticFileChunkingStrategyObject)
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 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 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 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 ¶
func (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FileObject], err error)
Returns a list of files.
func (*FileService) ListAutoPaging ¶
func (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FileObject]
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.
ModelSample string `json:"model_sample,required"`
// The reference answer for the evaluation.
ReferenceAnswer FineTuningAlphaGraderRunParamsReferenceAnswerUnion `json:"reference_answer,omitzero,required"`
// 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 ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetGraders() map[string]MultiGraderGraderUnionParam
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderRunParamsGraderUnion) GetImageTag ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetImageTag() *string
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 ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetModel() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderRunParamsGraderUnion) GetName ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetName() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderRunParamsGraderUnion) GetOperation ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetOperation() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderRunParamsGraderUnion) GetRange ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetRange() []float64
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderRunParamsGraderUnion) GetReference ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetReference() *string
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 ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetSource() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderRunParamsGraderUnion) GetType ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderRunParamsGraderUnion) MarshalJSON ¶
func (u FineTuningAlphaGraderRunParamsGraderUnion) MarshalJSON() ([]byte, error)
func (*FineTuningAlphaGraderRunParamsGraderUnion) UnmarshalJSON ¶
func (u *FineTuningAlphaGraderRunParamsGraderUnion) UnmarshalJSON(data []byte) error
type FineTuningAlphaGraderRunParamsReferenceAnswerUnion ¶
type FineTuningAlphaGraderRunParamsReferenceAnswerUnion struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfAnyArray []any `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 (FineTuningAlphaGraderRunParamsReferenceAnswerUnion) MarshalJSON ¶
func (u FineTuningAlphaGraderRunParamsReferenceAnswerUnion) MarshalJSON() ([]byte, error)
func (*FineTuningAlphaGraderRunParamsReferenceAnswerUnion) UnmarshalJSON ¶
func (u *FineTuningAlphaGraderRunParamsReferenceAnswerUnion) 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 ¶
func (r FineTuningAlphaGraderRunResponse) RawJSON() string
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 ¶
func (r FineTuningAlphaGraderRunResponseMetadata) RawJSON() string
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 ¶
func (r FineTuningAlphaGraderRunResponseMetadataErrors) RawJSON() string
Returns the unmodified JSON received from the API
func (*FineTuningAlphaGraderRunResponseMetadataErrors) UnmarshalJSON ¶
func (r *FineTuningAlphaGraderRunResponseMetadataErrors) UnmarshalJSON(data []byte) error
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 ¶
func (r *FineTuningAlphaGraderService) Run(ctx context.Context, body FineTuningAlphaGraderRunParams, opts ...option.RequestOption) (res *FineTuningAlphaGraderRunResponse, err error)
Run a grader.
func (*FineTuningAlphaGraderService) Validate ¶
func (r *FineTuningAlphaGraderService) Validate(ctx context.Context, body FineTuningAlphaGraderValidateParams, opts ...option.RequestOption) (res *FineTuningAlphaGraderValidateResponse, err error)
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 ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetCalculateOutput() *string
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 ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetGraders() map[string]MultiGraderGraderUnionParam
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderValidateParamsGraderUnion) GetImageTag ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetImageTag() *string
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 ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetModel() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderValidateParamsGraderUnion) GetName ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetName() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderValidateParamsGraderUnion) GetOperation ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetOperation() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderValidateParamsGraderUnion) GetRange ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetRange() []float64
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderValidateParamsGraderUnion) GetReference ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetReference() *string
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 ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetSource() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderValidateParamsGraderUnion) GetType ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (FineTuningAlphaGraderValidateParamsGraderUnion) MarshalJSON ¶
func (u FineTuningAlphaGraderValidateParamsGraderUnion) MarshalJSON() ([]byte, error)
func (*FineTuningAlphaGraderValidateParamsGraderUnion) UnmarshalJSON ¶
func (u *FineTuningAlphaGraderValidateParamsGraderUnion) UnmarshalJSON(data []byte) error
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 ¶
func (r FineTuningAlphaGraderValidateResponse) RawJSON() string
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 map[string]MultiGraderGraderUnion `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 (u FineTuningAlphaGraderValidateResponseGraderUnion) AsMultiGrader() (v MultiGrader)
func (FineTuningAlphaGraderValidateResponseGraderUnion) AsPythonGrader ¶
func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsPythonGrader() (v PythonGrader)
func (FineTuningAlphaGraderValidateResponseGraderUnion) AsScoreModelGrader ¶
func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsScoreModelGrader() (v ScoreModelGrader)
func (FineTuningAlphaGraderValidateResponseGraderUnion) AsStringCheckGrader ¶
func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsStringCheckGrader() (v StringCheckGrader)
func (FineTuningAlphaGraderValidateResponseGraderUnion) AsTextSimilarityGrader ¶
func (u FineTuningAlphaGraderValidateResponseGraderUnion) AsTextSimilarityGrader() (v TextSimilarityGrader)
func (FineTuningAlphaGraderValidateResponseGraderUnion) RawJSON ¶
func (u FineTuningAlphaGraderValidateResponseGraderUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*FineTuningAlphaGraderValidateResponseGraderUnion) UnmarshalJSON ¶
func (r *FineTuningAlphaGraderValidateResponseGraderUnion) UnmarshalJSON(data []byte) error
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 ¶
func (r *FineTuningAlphaGraderValidateResponseGraderUnionInput) UnmarshalJSON(data []byte) error
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 FineTuningCheckpointPermissionDeleteParams ¶
type FineTuningCheckpointPermissionDeleteParams struct {
FineTunedModelCheckpoint string `path:"fine_tuned_model_checkpoint,required" json:"-"`
// contains filtered or unexported fields
}
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 ¶
func (r FineTuningCheckpointPermissionDeleteResponse) RawJSON() string
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 ¶
func (r FineTuningCheckpointPermissionGetParams) URLQuery() (v url.Values, err error)
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 ¶
func (r FineTuningCheckpointPermissionGetResponse) RawJSON() string
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 ¶
func (r FineTuningCheckpointPermissionGetResponseData) RawJSON() string
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 ¶
func (r FineTuningCheckpointPermissionNewResponse) RawJSON() string
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, permissionID string, body FineTuningCheckpointPermissionDeleteParams, 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 ¶
func (r *FineTuningCheckpointPermissionService) Get(ctx context.Context, fineTunedModelCheckpoint string, query FineTuningCheckpointPermissionGetParams, opts ...option.RequestOption) (res *FineTuningCheckpointPermissionGetResponse, err error)
**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 ¶
func (r *FineTuningCheckpointPermissionService) New(ctx context.Context, fineTunedModelCheckpoint string, body FineTuningCheckpointPermissionNewParams, opts ...option.RequestOption) (res *pagination.Page[FineTuningCheckpointPermissionNewResponse], err error)
**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 ¶
func (r *FineTuningCheckpointPermissionService) NewAutoPaging(ctx context.Context, fineTunedModelCheckpoint string, body FineTuningCheckpointPermissionNewParams, opts ...option.RequestOption) *pagination.PageAutoPager[FineTuningCheckpointPermissionNewResponse]
**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 ¶
func (r FineTuningJobCheckpointMetrics) RawJSON() string
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 ¶
func (r *FineTuningJobCheckpointService) List(ctx context.Context, fineTuningJobID string, query FineTuningJobCheckpointListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FineTuningJobCheckpoint], err error)
List checkpoints for a fine-tuning job.
func (*FineTuningJobCheckpointService) ListAutoPaging ¶
func (r *FineTuningJobCheckpointService) ListAutoPaging(ctx context.Context, fineTuningJobID string, query FineTuningJobCheckpointListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FineTuningJobCheckpoint]
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 ¶
func (r FineTuningJobHyperparameters) RawJSON() string
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.
OfManual 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 {
OfManual 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: OfManual OfInt]
func (FineTuningJobHyperparametersBatchSizeUnion) AsInt ¶
func (u FineTuningJobHyperparametersBatchSizeUnion) AsInt() (v int64)
func (FineTuningJobHyperparametersBatchSizeUnion) AsManual ¶
func (u FineTuningJobHyperparametersBatchSizeUnion) AsManual() (v constant.Auto)
func (FineTuningJobHyperparametersBatchSizeUnion) RawJSON ¶
func (u FineTuningJobHyperparametersBatchSizeUnion) RawJSON() string
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 (u FineTuningJobHyperparametersLearningRateMultiplierUnion) AsAuto() (v constant.Auto)
func (FineTuningJobHyperparametersLearningRateMultiplierUnion) AsFloat ¶
func (u FineTuningJobHyperparametersLearningRateMultiplierUnion) AsFloat() (v float64)
func (FineTuningJobHyperparametersLearningRateMultiplierUnion) RawJSON ¶
func (u FineTuningJobHyperparametersLearningRateMultiplierUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*FineTuningJobHyperparametersLearningRateMultiplierUnion) UnmarshalJSON ¶
func (r *FineTuningJobHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error
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 (u FineTuningJobHyperparametersNEpochsUnion) AsAuto() (v constant.Auto)
func (FineTuningJobHyperparametersNEpochsUnion) AsInt ¶
func (u FineTuningJobHyperparametersNEpochsUnion) AsInt() (v int64)
func (FineTuningJobHyperparametersNEpochsUnion) RawJSON ¶
func (u FineTuningJobHyperparametersNEpochsUnion) RawJSON() string
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/fine-tuning)
// 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/fine-tuning)
// 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 (u FineTuningJobNewParamsHyperparametersBatchSizeUnion) MarshalJSON() ([]byte, error)
func (*FineTuningJobNewParamsHyperparametersBatchSizeUnion) UnmarshalJSON ¶
func (u *FineTuningJobNewParamsHyperparametersBatchSizeUnion) UnmarshalJSON(data []byte) error
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 (u FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion) MarshalJSON() ([]byte, error)
func (*FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion) UnmarshalJSON ¶
func (u *FineTuningJobNewParamsHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error
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 (u FineTuningJobNewParamsHyperparametersNEpochsUnion) MarshalJSON() ([]byte, error)
func (*FineTuningJobNewParamsHyperparametersNEpochsUnion) UnmarshalJSON ¶
func (u *FineTuningJobNewParamsHyperparametersNEpochsUnion) UnmarshalJSON(data []byte) error
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/fine-tuning)
func (*FineTuningJobService) List ¶
func (r *FineTuningJobService) List(ctx context.Context, query FineTuningJobListParams, opts ...option.RequestOption) (res *pagination.CursorPage[FineTuningJob], err error)
List your organization's fine-tuning jobs
func (*FineTuningJobService) ListAutoPaging ¶
func (r *FineTuningJobService) ListAutoPaging(ctx context.Context, query FineTuningJobListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FineTuningJob]
List your organization's fine-tuning jobs
func (*FineTuningJobService) ListEvents ¶
func (r *FineTuningJobService) ListEvents(ctx context.Context, fineTuningJobID string, query FineTuningJobListEventsParams, opts ...option.RequestOption) (res *pagination.CursorPage[FineTuningJobEvent], err error)
Get status updates for a fine-tuning job.
func (*FineTuningJobService) ListEventsAutoPaging ¶
func (r *FineTuningJobService) ListEventsAutoPaging(ctx context.Context, fineTuningJobID string, query FineTuningJobListEventsParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[FineTuningJobEvent]
Get status updates for a fine-tuning job.
func (*FineTuningJobService) New ¶
func (r *FineTuningJobService) New(ctx context.Context, body FineTuningJobNewParams, opts ...option.RequestOption) (res *FineTuningJob, err error)
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/fine-tuning)
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 ¶
func (r FineTuningJobWandbIntegration) RawJSON() string
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 ¶
func (r FineTuningJobWandbIntegrationObject) RawJSON() string
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 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 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) UnmarshalJSON ¶
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
// 25MB. 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"`
// 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 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 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 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 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 ¶
func (r ImagesResponseUsageInputTokensDetails) RawJSON() string
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 ¶
func (r LabelModelGrader) ToParam() LabelModelGraderParam
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 ¶
func (r LabelModelGraderInputContentOutputText) RawJSON() string
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 (u LabelModelGraderInputContentUnion) AsInputText() (v responses.ResponseInputText)
func (LabelModelGraderInputContentUnion) AsOutputText ¶
func (u LabelModelGraderInputContentUnion) AsOutputText() (v LabelModelGraderInputContentOutputText)
func (LabelModelGraderInputContentUnion) AsString ¶
func (u LabelModelGraderInputContentUnion) AsString() (v string)
func (LabelModelGraderInputContentUnion) RawJSON ¶
func (u LabelModelGraderInputContentUnion) RawJSON() string
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 ¶
func (u LabelModelGraderInputContentUnionParam) GetText() *string
Returns a pointer to the underlying variant's property, if present.
func (LabelModelGraderInputContentUnionParam) GetType ¶
func (u LabelModelGraderInputContentUnionParam) GetType() *string
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 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) UnmarshalJSON ¶
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 ¶
func (r ModerationCategoryAppliedInputTypes) RawJSON() string
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 ModerationMultiModalInputParamOfImageURL ¶
func ModerationMultiModalInputParamOfImageURL(imageURL ModerationImageURLInputImageURLParam) ModerationMultiModalInputUnionParam
func ModerationMultiModalInputParamOfText ¶
func ModerationMultiModalInputParamOfText(text string) ModerationMultiModalInputUnionParam
func (ModerationMultiModalInputUnionParam) GetImageURL ¶
func (u ModerationMultiModalInputUnionParam) GetImageURL() *ModerationImageURLInputImageURLParam
Returns a pointer to the underlying variant's property, if present.
func (ModerationMultiModalInputUnionParam) GetText ¶
func (u ModerationMultiModalInputUnionParam) GetText() *string
Returns a pointer to the underlying variant's property, if present.
func (ModerationMultiModalInputUnionParam) GetType ¶
func (u ModerationMultiModalInputUnionParam) GetType() *string
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 ¶
func (r *ModerationService) New(ctx context.Context, body ModerationNewParams, opts ...option.RequestOption) (res *ModerationNewResponse, err error)
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"`
Graders map[string]MultiGraderGraderUnion `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 MultiGraderGraderUnion ¶
type MultiGraderGraderUnion struct {
// This field is a union of [string], [string], [[]ScoreModelGraderInput],
// [[]LabelModelGraderInput]
Input MultiGraderGraderUnionInput `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:"-"`
}
MultiGraderGraderUnion 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 (MultiGraderGraderUnion) AsLabelModelGrader ¶
func (u MultiGraderGraderUnion) AsLabelModelGrader() (v LabelModelGrader)
func (MultiGraderGraderUnion) AsPythonGrader ¶
func (u MultiGraderGraderUnion) AsPythonGrader() (v PythonGrader)
func (MultiGraderGraderUnion) AsScoreModelGrader ¶
func (u MultiGraderGraderUnion) AsScoreModelGrader() (v ScoreModelGrader)
func (MultiGraderGraderUnion) AsStringCheckGrader ¶
func (u MultiGraderGraderUnion) AsStringCheckGrader() (v StringCheckGrader)
func (MultiGraderGraderUnion) AsTextSimilarityGrader ¶
func (u MultiGraderGraderUnion) AsTextSimilarityGrader() (v TextSimilarityGrader)
func (MultiGraderGraderUnion) RawJSON ¶
func (u MultiGraderGraderUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*MultiGraderGraderUnion) UnmarshalJSON ¶
func (r *MultiGraderGraderUnion) UnmarshalJSON(data []byte) error
type MultiGraderGraderUnionInput ¶
type MultiGraderGraderUnionInput 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:"-"`
}
MultiGraderGraderUnionInput is an implicit subunion of MultiGraderGraderUnion. MultiGraderGraderUnionInput provides convenient access to the sub-properties of the union.
For type safety it is recommended to directly use a variant of the MultiGraderGraderUnion.
If the underlying value is not a json object, one of the following properties will be valid: OfString OfScoreModelGraderInputArray OfLabelModelGraderInputArray]
func (*MultiGraderGraderUnionInput) UnmarshalJSON ¶
func (r *MultiGraderGraderUnionInput) UnmarshalJSON(data []byte) error
type MultiGraderGraderUnionParam ¶
type MultiGraderGraderUnionParam 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 (MultiGraderGraderUnionParam) GetEvaluationMetric ¶
func (u MultiGraderGraderUnionParam) GetEvaluationMetric() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetImageTag ¶
func (u MultiGraderGraderUnionParam) GetImageTag() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetInput ¶
func (u MultiGraderGraderUnionParam) GetInput() (res multiGraderGraderUnionParamInput)
Returns a subunion which exports methods to access subproperties
Or use AsAny() to get the underlying value
func (MultiGraderGraderUnionParam) GetLabels ¶
func (u MultiGraderGraderUnionParam) GetLabels() []string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetModel ¶
func (u MultiGraderGraderUnionParam) GetModel() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetName ¶
func (u MultiGraderGraderUnionParam) GetName() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetOperation ¶
func (u MultiGraderGraderUnionParam) GetOperation() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetPassingLabels ¶
func (u MultiGraderGraderUnionParam) GetPassingLabels() []string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetRange ¶
func (u MultiGraderGraderUnionParam) GetRange() []float64
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetReference ¶
func (u MultiGraderGraderUnionParam) GetReference() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetSamplingParams ¶
func (u MultiGraderGraderUnionParam) GetSamplingParams() *any
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetSource ¶
func (u MultiGraderGraderUnionParam) GetSource() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) GetType ¶
func (u MultiGraderGraderUnionParam) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (MultiGraderGraderUnionParam) MarshalJSON ¶
func (u MultiGraderGraderUnionParam) MarshalJSON() ([]byte, error)
func (*MultiGraderGraderUnionParam) UnmarshalJSON ¶
func (u *MultiGraderGraderUnionParam) 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"`
Graders map[string]MultiGraderGraderUnionParam `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 ¶
func (r OtherFileChunkingStrategyObject) RawJSON() string
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 ¶
**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 ReinforcementComputeMultiplierUnion ¶
type ReinforcementComputeMultiplierUnion 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 (ReinforcementComputeMultiplierUnion) MarshalJSON ¶
func (u ReinforcementComputeMultiplierUnion) MarshalJSON() ([]byte, error)
func (*ReinforcementComputeMultiplierUnion) UnmarshalJSON ¶
func (u *ReinforcementComputeMultiplierUnion) UnmarshalJSON(data []byte) error
type ReinforcementComputeMultiplierUnionResp ¶
type ReinforcementComputeMultiplierUnionResp 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:"-"`
}
ReinforcementComputeMultiplierUnionResp 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 (ReinforcementComputeMultiplierUnionResp) AsAuto ¶
func (u ReinforcementComputeMultiplierUnionResp) AsAuto() (v constant.Auto)
func (ReinforcementComputeMultiplierUnionResp) AsFloat ¶
func (u ReinforcementComputeMultiplierUnionResp) AsFloat() (v float64)
func (ReinforcementComputeMultiplierUnionResp) RawJSON ¶
func (u ReinforcementComputeMultiplierUnionResp) RawJSON() string
Returns the unmodified JSON received from the API
func (*ReinforcementComputeMultiplierUnionResp) UnmarshalJSON ¶
func (r *ReinforcementComputeMultiplierUnionResp) UnmarshalJSON(data []byte) error
type ReinforcementEvalSamplesUnion ¶
type ReinforcementEvalSamplesUnion 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 (ReinforcementEvalSamplesUnion) MarshalJSON ¶
func (u ReinforcementEvalSamplesUnion) MarshalJSON() ([]byte, error)
func (*ReinforcementEvalSamplesUnion) UnmarshalJSON ¶
func (u *ReinforcementEvalSamplesUnion) UnmarshalJSON(data []byte) error
type ReinforcementEvalSamplesUnionResp ¶
type ReinforcementEvalSamplesUnionResp 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:"-"`
}
ReinforcementEvalSamplesUnionResp 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 (ReinforcementEvalSamplesUnionResp) AsAuto ¶
func (u ReinforcementEvalSamplesUnionResp) AsAuto() (v constant.Auto)
func (ReinforcementEvalSamplesUnionResp) AsInt ¶
func (u ReinforcementEvalSamplesUnionResp) AsInt() (v int64)
func (ReinforcementEvalSamplesUnionResp) RawJSON ¶
func (u ReinforcementEvalSamplesUnionResp) RawJSON() string
Returns the unmodified JSON received from the API
func (*ReinforcementEvalSamplesUnionResp) UnmarshalJSON ¶
func (r *ReinforcementEvalSamplesUnionResp) 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 ReinforcementComputeMultiplierUnion `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 ReinforcementEvalSamplesUnion `json:"eval_samples,omitzero"`
// Scaling factor for the learning rate. A smaller learning rate may be useful to
// avoid overfitting.
LearningRateMultiplier ReinforcementLearningRateMultiplierUnion `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 (u ReinforcementHyperparametersBatchSizeUnion) MarshalJSON() ([]byte, error)
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 (u ReinforcementHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto)
func (ReinforcementHyperparametersBatchSizeUnionResp) AsInt ¶
func (u ReinforcementHyperparametersBatchSizeUnionResp) AsInt() (v int64)
func (ReinforcementHyperparametersBatchSizeUnionResp) RawJSON ¶
func (u ReinforcementHyperparametersBatchSizeUnionResp) RawJSON() string
Returns the unmodified JSON received from the API
func (*ReinforcementHyperparametersBatchSizeUnionResp) UnmarshalJSON ¶
func (r *ReinforcementHyperparametersBatchSizeUnionResp) UnmarshalJSON(data []byte) error
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 (u ReinforcementHyperparametersEvalIntervalUnion) MarshalJSON() ([]byte, error)
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 (u ReinforcementHyperparametersEvalIntervalUnionResp) AsAuto() (v constant.Auto)
func (ReinforcementHyperparametersEvalIntervalUnionResp) AsInt ¶
func (u ReinforcementHyperparametersEvalIntervalUnionResp) AsInt() (v int64)
func (ReinforcementHyperparametersEvalIntervalUnionResp) RawJSON ¶
func (u ReinforcementHyperparametersEvalIntervalUnionResp) RawJSON() string
Returns the unmodified JSON received from the API
func (*ReinforcementHyperparametersEvalIntervalUnionResp) UnmarshalJSON ¶
func (r *ReinforcementHyperparametersEvalIntervalUnionResp) UnmarshalJSON(data []byte) error
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 (u ReinforcementHyperparametersNEpochsUnion) MarshalJSON() ([]byte, error)
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 (u ReinforcementHyperparametersNEpochsUnionResp) AsAuto() (v constant.Auto)
func (ReinforcementHyperparametersNEpochsUnionResp) AsInt ¶
func (u ReinforcementHyperparametersNEpochsUnionResp) AsInt() (v int64)
func (ReinforcementHyperparametersNEpochsUnionResp) RawJSON ¶
func (u ReinforcementHyperparametersNEpochsUnionResp) RawJSON() string
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 ReinforcementComputeMultiplierUnionResp `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 ReinforcementEvalSamplesUnionResp `json:"eval_samples"`
// Scaling factor for the learning rate. A smaller learning rate may be useful to
// avoid overfitting.
LearningRateMultiplier ReinforcementLearningRateMultiplierUnionResp `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 ¶
func (r ReinforcementHyperparametersResp) RawJSON() string
Returns the unmodified JSON received from the API
func (ReinforcementHyperparametersResp) ToParam ¶
func (r ReinforcementHyperparametersResp) ToParam() ReinforcementHyperparameters
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 ReinforcementLearningRateMultiplierUnion ¶
type ReinforcementLearningRateMultiplierUnion 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 (ReinforcementLearningRateMultiplierUnion) MarshalJSON ¶
func (u ReinforcementLearningRateMultiplierUnion) MarshalJSON() ([]byte, error)
func (*ReinforcementLearningRateMultiplierUnion) UnmarshalJSON ¶
func (u *ReinforcementLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error
type ReinforcementLearningRateMultiplierUnionResp ¶
type ReinforcementLearningRateMultiplierUnionResp 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:"-"`
}
ReinforcementLearningRateMultiplierUnionResp 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 (ReinforcementLearningRateMultiplierUnionResp) AsAuto ¶
func (u ReinforcementLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto)
func (ReinforcementLearningRateMultiplierUnionResp) AsFloat ¶
func (u ReinforcementLearningRateMultiplierUnionResp) AsFloat() (v float64)
func (ReinforcementLearningRateMultiplierUnionResp) RawJSON ¶
func (u ReinforcementLearningRateMultiplierUnionResp) RawJSON() string
Returns the unmodified JSON received from the API
func (*ReinforcementLearningRateMultiplierUnionResp) UnmarshalJSON ¶
func (r *ReinforcementLearningRateMultiplierUnionResp) 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 ¶
func (r ReinforcementMethod) ToParam() ReinforcementMethodParam
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 map[string]MultiGraderGraderUnion `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 ¶
func (u ReinforcementMethodGraderUnion) RawJSON() string
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 ¶
func (u ReinforcementMethodGraderUnionParam) GetGraders() map[string]MultiGraderGraderUnionParam
Returns a pointer to the underlying variant's property, if present.
func (ReinforcementMethodGraderUnionParam) GetImageTag ¶
func (u ReinforcementMethodGraderUnionParam) GetImageTag() *string
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 ¶
func (u ReinforcementMethodGraderUnionParam) GetModel() *string
Returns a pointer to the underlying variant's property, if present.
func (ReinforcementMethodGraderUnionParam) GetName ¶
func (u ReinforcementMethodGraderUnionParam) GetName() *string
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 ¶
func (u ReinforcementMethodGraderUnionParam) GetRange() []float64
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 ¶
func (u ReinforcementMethodGraderUnionParam) GetSource() *string
Returns a pointer to the underlying variant's property, if present.
func (ReinforcementMethodGraderUnionParam) GetType ¶
func (u ReinforcementMethodGraderUnionParam) GetType() *string
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 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 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 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 ¶
func (r ScoreModelGrader) ToParam() ScoreModelGraderParam
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 ¶
func (r ScoreModelGraderInputContentOutputText) RawJSON() string
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 (u ScoreModelGraderInputContentUnion) AsInputText() (v responses.ResponseInputText)
func (ScoreModelGraderInputContentUnion) AsOutputText ¶
func (u ScoreModelGraderInputContentUnion) AsOutputText() (v ScoreModelGraderInputContentOutputText)
func (ScoreModelGraderInputContentUnion) AsString ¶
func (u ScoreModelGraderInputContentUnion) AsString() (v string)
func (ScoreModelGraderInputContentUnion) RawJSON ¶
func (u ScoreModelGraderInputContentUnion) RawJSON() string
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 ¶
func (u ScoreModelGraderInputContentUnionParam) GetText() *string
Returns a pointer to the underlying variant's property, if present.
func (ScoreModelGraderInputContentUnionParam) GetType ¶
func (u ScoreModelGraderInputContentUnionParam) GetType() *string
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 ¶
func (r StaticFileChunkingStrategy) ToParam() StaticFileChunkingStrategyParam
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 ¶
func (r StaticFileChunkingStrategyObject) RawJSON() string
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 ¶
func (r StringCheckGrader) ToParam() StringCheckGraderParam
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 (u SupervisedHyperparametersBatchSizeUnionResp) AsAuto() (v constant.Auto)
func (SupervisedHyperparametersBatchSizeUnionResp) AsInt ¶
func (u SupervisedHyperparametersBatchSizeUnionResp) AsInt() (v int64)
func (SupervisedHyperparametersBatchSizeUnionResp) RawJSON ¶
func (u SupervisedHyperparametersBatchSizeUnionResp) RawJSON() string
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 (u SupervisedHyperparametersLearningRateMultiplierUnion) MarshalJSON() ([]byte, error)
func (*SupervisedHyperparametersLearningRateMultiplierUnion) UnmarshalJSON ¶
func (u *SupervisedHyperparametersLearningRateMultiplierUnion) UnmarshalJSON(data []byte) error
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 (u SupervisedHyperparametersLearningRateMultiplierUnionResp) AsAuto() (v constant.Auto)
func (SupervisedHyperparametersLearningRateMultiplierUnionResp) AsFloat ¶
func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) AsFloat() (v float64)
func (SupervisedHyperparametersLearningRateMultiplierUnionResp) RawJSON ¶
func (u SupervisedHyperparametersLearningRateMultiplierUnionResp) RawJSON() string
Returns the unmodified JSON received from the API
func (*SupervisedHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON ¶
func (r *SupervisedHyperparametersLearningRateMultiplierUnionResp) UnmarshalJSON(data []byte) error
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 (u SupervisedHyperparametersNEpochsUnionResp) AsAuto() (v constant.Auto)
func (SupervisedHyperparametersNEpochsUnionResp) AsInt ¶
func (u SupervisedHyperparametersNEpochsUnionResp) AsInt() (v int64)
func (SupervisedHyperparametersNEpochsUnionResp) RawJSON ¶
func (u SupervisedHyperparametersNEpochsUnionResp) RawJSON() string
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 ¶
func (r SupervisedHyperparametersResp) RawJSON() string
Returns the unmodified JSON received from the API
func (SupervisedHyperparametersResp) ToParam ¶
func (r SupervisedHyperparametersResp) ToParam() SupervisedHyperparameters
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 ¶
func (r SupervisedMethod) ToParam() SupervisedMethodParam
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 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 ¶
func (r TextSimilarityGrader) ToParam() TextSimilarityGraderParam
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 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"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Text respjson.Field
Logprobs 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"`
JSON struct {
Delta respjson.Field
Type respjson.Field
Logprobs respjson.Field
Text 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 ¶
func (u TranscriptionStreamEventUnion) RawJSON() string
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 []any `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 ¶
func (r TranscriptionTextDeltaEventLogprob) RawJSON() string
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"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Text respjson.Field
Type respjson.Field
Logprobs 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 []any `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 ¶
func (r TranscriptionTextDoneEventLogprob) RawJSON() string
Returns the unmodified JSON received from the API
func (*TranscriptionTextDoneEventLogprob) UnmarshalJSON ¶
func (r *TranscriptionTextDoneEventLogprob) 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) UnmarshalJSON ¶
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 ¶
func (u VectorStoreFileAttributeUnion) RawJSON() string
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 VectorStoreFileBatchCancelParams ¶
type VectorStoreFileBatchCancelParams struct {
VectorStoreID string `path:"vector_store_id,required" json:"-"`
// contains filtered or unexported fields
}
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 ¶
func (r VectorStoreFileBatchFileCounts) RawJSON() string
Returns the unmodified JSON received from the API
func (*VectorStoreFileBatchFileCounts) UnmarshalJSON ¶
func (r *VectorStoreFileBatchFileCounts) UnmarshalJSON(data []byte) error
type VectorStoreFileBatchGetParams ¶
type VectorStoreFileBatchGetParams struct {
VectorStoreID string `path:"vector_store_id,required" json:"-"`
// contains filtered or unexported fields
}
type VectorStoreFileBatchListFilesParams ¶
type VectorStoreFileBatchListFilesParams struct {
VectorStoreID string `path:"vector_store_id,required" json:"-"`
// 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 (u VectorStoreFileBatchNewParamsAttributeUnion) MarshalJSON() ([]byte, error)
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, batchID string, body VectorStoreFileBatchCancelParams, 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, batchID string, query VectorStoreFileBatchGetParams, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error)
Retrieves a vector store file batch.
func (*VectorStoreFileBatchService) ListFiles ¶
func (r *VectorStoreFileBatchService) ListFiles(ctx context.Context, batchID string, params VectorStoreFileBatchListFilesParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStoreFile], err error)
Returns a list of vector store files in a batch.
func (*VectorStoreFileBatchService) ListFilesAutoPaging ¶
func (r *VectorStoreFileBatchService) ListFilesAutoPaging(ctx context.Context, batchID string, params VectorStoreFileBatchListFilesParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[VectorStoreFile]
Returns a list of vector store files in a batch.
func (*VectorStoreFileBatchService) New ¶
func (r *VectorStoreFileBatchService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileBatchNewParams, opts ...option.RequestOption) (res *VectorStoreFileBatch, err error)
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 VectorStoreFileContentParams ¶
type VectorStoreFileContentParams struct {
VectorStoreID string `path:"vector_store_id,required" json:"-"`
// contains filtered or unexported fields
}
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 ¶
func (r VectorStoreFileContentResponse) RawJSON() string
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 VectorStoreFileDeleteParams ¶
type VectorStoreFileDeleteParams struct {
VectorStoreID string `path:"vector_store_id,required" json:"-"`
// contains filtered or unexported fields
}
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 VectorStoreFileGetParams ¶
type VectorStoreFileGetParams struct {
VectorStoreID string `path:"vector_store_id,required" json:"-"`
// contains filtered or unexported fields
}
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, fileID string, query VectorStoreFileContentParams, opts ...option.RequestOption) (res *pagination.Page[VectorStoreFileContentResponse], err error)
Retrieve the parsed contents of a vector store file.
func (*VectorStoreFileService) ContentAutoPaging ¶
func (r *VectorStoreFileService) ContentAutoPaging(ctx context.Context, fileID string, query VectorStoreFileContentParams, opts ...option.RequestOption) *pagination.PageAutoPager[VectorStoreFileContentResponse]
Retrieve the parsed contents of a vector store file.
func (*VectorStoreFileService) Delete ¶
func (r *VectorStoreFileService) Delete(ctx context.Context, fileID string, body VectorStoreFileDeleteParams, 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, fileID string, query VectorStoreFileGetParams, opts ...option.RequestOption) (res *VectorStoreFile, err error)
Retrieves a vector store file.
func (*VectorStoreFileService) List ¶
func (r *VectorStoreFileService) List(ctx context.Context, vectorStoreID string, query VectorStoreFileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStoreFile], err error)
Returns a list of vector store files.
func (*VectorStoreFileService) ListAutoPaging ¶
func (r *VectorStoreFileService) ListAutoPaging(ctx context.Context, vectorStoreID string, query VectorStoreFileListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[VectorStoreFile]
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, fileID string, params 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"`
VectorStoreID string `path:"vector_store_id,required" json:"-"`
// 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 (u VectorStoreFileUpdateParamsAttributeUnion) MarshalJSON() ([]byte, error)
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 ¶
func (u VectorStoreSearchParamsFiltersUnion) GetFilters() []shared.ComparisonFilterParam
Returns a pointer to the underlying variant's property, if present.
func (VectorStoreSearchParamsFiltersUnion) GetKey ¶
func (u VectorStoreSearchParamsFiltersUnion) GetKey() *string
Returns a pointer to the underlying variant's property, if present.
func (VectorStoreSearchParamsFiltersUnion) GetType ¶
func (u VectorStoreSearchParamsFiltersUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (VectorStoreSearchParamsFiltersUnion) GetValue ¶
func (u VectorStoreSearchParamsFiltersUnion) GetValue() *shared.ComparisonFilterValueUnionParam
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 (u VectorStoreSearchResponseAttributeUnion) AsBool() (v bool)
func (VectorStoreSearchResponseAttributeUnion) AsFloat ¶
func (u VectorStoreSearchResponseAttributeUnion) AsFloat() (v float64)
func (VectorStoreSearchResponseAttributeUnion) AsString ¶
func (u VectorStoreSearchResponseAttributeUnion) AsString() (v string)
func (VectorStoreSearchResponseAttributeUnion) RawJSON ¶
func (u VectorStoreSearchResponseAttributeUnion) RawJSON() string
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 ¶
func (r VectorStoreSearchResponseContent) RawJSON() string
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 ¶
func (r *VectorStoreService) List(ctx context.Context, query VectorStoreListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStore], err error)
Returns a list of vector stores.
func (*VectorStoreService) ListAutoPaging ¶
func (r *VectorStoreService) ListAutoPaging(ctx context.Context, query VectorStoreListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[VectorStore]
Returns a list of vector stores.
func (*VectorStoreService) New ¶
func (r *VectorStoreService) New(ctx context.Context, body VectorStoreNewParams, opts ...option.RequestOption) (res *VectorStore, err error)
Create a vector store.
func (*VectorStoreService) Search ¶
func (r *VectorStoreService) Search(ctx context.Context, vectorStoreID string, body VectorStoreSearchParams, opts ...option.RequestOption) (res *pagination.Page[VectorStoreSearchResponse], err error)
Search a vector store for relevant chunks based on a query and file attributes filter.
func (*VectorStoreService) SearchAutoPaging ¶
func (r *VectorStoreService) SearchAutoPaging(ctx context.Context, vectorStoreID string, body VectorStoreSearchParams, opts ...option.RequestOption) *pagination.PageAutoPager[VectorStoreSearchResponse]
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
Source Files
¶
- aliases.go
- audio.go
- audiospeech.go
- audiotranscription.go
- audiotranslation.go
- batch.go
- beta.go
- chat.go
- chatcompletion.go
- chatcompletionmessage.go
- client.go
- completion.go
- embedding.go
- field.go
- file.go
- finetuning.go
- finetuningalpha.go
- finetuningalphagrader.go
- finetuningcheckpoint.go
- finetuningcheckpointpermission.go
- finetuningjob.go
- finetuningjobcheckpoint.go
- finetuningmethod.go
- grader.go
- gradergradermodel.go
- image.go
- model.go
- moderation.go
- polling.go
- streamaccumulator.go
- upload.go
- uploadpart.go
- vectorstore.go
- vectorstorefile.go
- vectorstorefilebatch.go
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
|
|