openai

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TracingHTTPClient

func TracingHTTPClient(opikClient *opik.Client, opts ...opik.SpanOption) *http.Client

TracingHTTPClient creates an http.Client that traces OpenAI calls.

func Wrap

func Wrap(client *http.Client, opikClient *opik.Client, opts ...opik.SpanOption) *http.Client

Wrap wraps an existing http.Client to add OpenAI tracing.

Types

type Option

type Option func(*Provider)

Option configures the provider.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the base URL (for Azure OpenAI or proxies).

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithMaxTokens

func WithMaxTokens(max int) Option

WithMaxTokens sets the default max tokens.

func WithModel

func WithModel(model string) Option

WithModel sets the default model.

func WithTemperature

func WithTemperature(temp float64) Option

WithTemperature sets the default temperature.

type Provider

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

Provider implements llm.Provider for OpenAI.

func NewProvider

func NewProvider(opts ...Option) *Provider

NewProvider creates a new OpenAI provider.

func TracingProvider

func TracingProvider(opikClient *opik.Client, providerOpts ...Option) *Provider

TracingProvider creates an OpenAI provider with automatic tracing.

func (*Provider) Complete

Complete sends a chat completion request.

func (*Provider) DefaultModel

func (p *Provider) DefaultModel() string

DefaultModel returns the default model.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type TracingTransport

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

TracingTransport wraps an http.RoundTripper to automatically trace OpenAI API calls.

func NewTracingTransport

func NewTracingTransport(inner http.RoundTripper, opikClient *opik.Client, opts ...opik.SpanOption) *TracingTransport

NewTracingTransport creates a new tracing transport.

func (*TracingTransport) RoundTrip

func (t *TracingTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper with tracing.

Jump to

Keyboard shortcuts

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