openai

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package openai implements the OpenAI LLM provider.

Index

Constants

View Source
const ProviderID llmproxy.ProviderID = "OpenAI"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	APIKey string `env:"OPENAI_API_KEY"`

	// InternalTools governs whether and how native provider-side tools fire when
	// the corresponding marker tool is included in a ChatRequest.
	InternalTools InternalTools
}

Config holds OpenAI-specific provider configuration. APIKey is env-parsed; InternalTools is programmatic (defaults or operator overrides).

type InternalTools

type InternalTools struct {
	// WebSearch enables OpenAI's native web_search tool when non-nil and a
	// llmproxy.WebSearch marker is present in the request. nil means
	// "native search disabled even if the marker is passed."
	WebSearch *WebSearchConfig
}

InternalTools groups OpenAI-side native tool configurations.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements Provider for OpenAI

func NewProvider

func NewProvider(cfg Config) *Provider

NewProvider creates a new OpenAI Provider

func (*Provider) AvailableModels

func (p *Provider) AvailableModels() []llmproxy.ModelInfo

AvailableModels returns the static list of OpenAI models exposed by this provider.

func (*Provider) Chat

Chat sends a prompt to OpenAI and returns the response

func (*Provider) DeleteFile

func (p *Provider) DeleteFile(ctx context.Context, fileID llmproxy.FileID) (bool, error)

DeleteFile removes a file from OpenAI

func (*Provider) Embed

Embed generates embeddings for the given inputs using an OpenAI embedding model.

func (*Provider) EmbeddingDimension

func (p *Provider) EmbeddingDimension(model llmproxy.ModelID) (int, error)

EmbeddingDimension returns the output dimension for the given embedding model.

func (*Provider) Health

func (p *Provider) Health(ctx context.Context) error

Health pings OpenAI to ensure connectivity

func (*Provider) ProviderID

func (p *Provider) ProviderID() llmproxy.ProviderID

ProviderID returns the unique identifier of the LLM provider.

func (*Provider) UploadFile

UploadFile uploads a file to OpenAI

type SearchContextSize

type SearchContextSize string

SearchContextSize controls how much context OpenAI's native web search returns.

const (
	SearchContextSizeLow    SearchContextSize = "low"
	SearchContextSizeMedium SearchContextSize = "medium"
	SearchContextSizeHigh   SearchContextSize = "high"
)

type WebSearchConfig

type WebSearchConfig struct {
	// ContextSize controls how much search context is returned. Empty defaults to low.
	ContextSize SearchContextSize
}

WebSearchConfig configures OpenAI's native web_search tool.

Jump to

Keyboard shortcuts

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