openai

package
v1.4.577 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 33 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ImageGenerationResponseType = "image_generation_call"

ImageGenerationResponseType is the type used for image generation calls in responses

View Source
const ImageGenerationToolType = "image_generation"
View Source
const MaxAudioFileSize int64 = 25 * 1024 * 1024

MaxAudioFileSize defines the maximum allowed size for audio uploads (25MB).

Variables

AllowedTranscriptionModels lists the models supported for transcription.

View Source
var ImageGenerationSupportedModels = []string{
	"gpt-5.6-luna",
	"o3",
	"gpt-5",
	"gpt-5-nano",
	"gpt-5.2",
}

ImageGenerationSupportedModels lists all models that support image generation

Functions

func FetchModelsDirectly added in v1.4.331

func FetchModelsDirectly(ctx context.Context, baseURL, apiKey, providerName string, httpClient *http.Client) ([]string, error)

FetchModelsDirectly is used to fetch models directly from the API when the standard OpenAI SDK method fails due to a nonstandard format. This is useful for providers that return a direct array of models instead of the OpenAI object format. If httpClient is nil, a new client with default settings will be created.

Types

type Client

type Client struct {
	*plugins.PluginBase
	ApiKey              *plugins.SetupQuestion
	ApiBaseURL          *plugins.SetupQuestion
	ApiClient           *openai.Client
	ImplementsResponses bool // Whether this provider supports the Responses API
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (ret *Client)

func NewClientCompatible

func NewClientCompatible(vendorName string, defaultBaseUrl string, configureCustom func() error) (ret *Client)

func NewClientCompatibleNoSetupQuestions

func NewClientCompatibleNoSetupQuestions(vendorName string, configureCustom func() error) (ret *Client)

func NewClientCompatibleWithResponses

func NewClientCompatibleWithResponses(vendorName string, defaultBaseUrl string, implementsResponses bool, configureCustom func() error) (ret *Client)

func (*Client) BuildResponseParams added in v1.4.437

func (o *Client) BuildResponseParams(
	inputMsgs []*chat.ChatCompletionMessage, opts *domain.ChatOptions,
) responses.ResponseNewParams

BuildResponseParams exposes the shared Responses API request builder so auth-specialized vendors can reuse Fabric's OpenAI-compatible request shape.

func (*Client) ExtractText added in v1.4.437

func (o *Client) ExtractText(resp *responses.Response) string

ExtractText exposes the shared Responses API text extraction logic so other vendors can reuse Fabric's response formatting and citation handling.

func (*Client) ListModels

func (o *Client) ListModels(ctx context.Context) (ret []string, err error)

func (*Client) NeedsRawMode

func (o *Client) NeedsRawMode(modelName string) bool

func (*Client) Send

func (o *Client) Send(ctx context.Context, msgs []*chat.ChatCompletionMessage, opts *domain.ChatOptions) (ret string, err error)

func (*Client) SendStream

func (o *Client) SendStream(
	ctx context.Context, msgs []*chat.ChatCompletionMessage, opts *domain.ChatOptions, channel chan domain.StreamUpdate,
) (err error)

func (*Client) SetEnableXSearch added in v1.4.450

func (o *Client) SetEnableXSearch(enabled bool)

SetEnableXSearch toggles whether an additional xAI "x_search" tool entry is appended when Search is enabled. Non-xAI providers should leave this false.

func (*Client) SetResponseParamsHook added in v1.4.528

func (o *Client) SetResponseParamsHook(hook func(*responses.ResponseNewParams))

SetResponseParamsHook sets a function that changes each Responses API request after Fabric builds it. Perplexity uses it to select presets.

func (*Client) SetResponsesAPIEnabled added in v1.4.257

func (o *Client) SetResponsesAPIEnabled(enabled bool)

SetResponsesAPIEnabled configures whether to use the Responses API

func (*Client) SetSessionHeaderName added in v1.4.504

func (o *Client) SetSessionHeaderName(name string)

SetSessionHeaderName sets the request header used to carry a stable per-conversation session ID (for example, OpenCode's "x-opencode-session"). Pass an empty string to disable.

func (*Client) SetUserAgent added in v1.4.504

func (o *Client) SetUserAgent(userAgent string)

SetUserAgent overrides the User-Agent header sent with chat and responses requests. Pass an empty string to keep the SDK's default.

func (*Client) SetWebSearchToolName added in v1.4.450

func (o *Client) SetWebSearchToolName(name string)

SetWebSearchToolName replaces the "web_search_preview" tool type that the Responses API request has when Search is true. A name that is not empty also selects the web_search tool param (OfWebSearch). An empty name keeps the OpenAI default. xAI uses "web_search".

func (*Client) TranscribeFile added in v1.4.291

func (o *Client) TranscribeFile(ctx context.Context, filePath, model string, split bool) (string, error)

TranscribeFile transcribes the given audio file using the specified model. If the file exceeds the size limit, it can optionally be split into chunks using ffmpeg.

type MessageConversionResult

type MessageConversionResult struct {
	Role            string
	Content         string
	MultiContent    []chat.ChatMessagePart
	HasMultiContent bool
}

MessageConversionResult holds the common conversion result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL