client

package
v0.260127.1000-preview Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewAnthropicClient func(provider *typ.Provider) (*AnthropicClient, error) = defaultNewAnthropicClient

NewAnthropicClient creates a new Anthropic client wrapper

View Source
var NewOpenAIClient func(provider *typ.Provider) (*OpenAIClient, error) = defaultNewOpenAIClient

NewOpenAIClient creates a new OpenAI client wrapper

Functions

func CloseClient

func CloseClient(client protocol.Client) error

CloseClient closes a client if it implements Close()

func CreateHTTPClientForProvider

func CreateHTTPClientForProvider(providerType oauth.ProviderType, proxyURL string, isOAuth bool) *http.Client

CreateHTTPClientForProvider creates an HTTP client configured for the given provider It handles proxy and OAuth hooks if applicable

providerType: the OAuth provider type (e.g., oauth.ProviderClaudeCode) proxyURL: optional proxy URL (can be empty) isOAuth: whether this is an OAuth provider

Returns a configured http.Client

func CreateHTTPClientWithProxy

func CreateHTTPClientWithProxy(proxyURL string) *http.Client

CreateHTTPClientWithProxy creates an HTTP client with proxy support

Types

type AnthropicClient

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

AnthropicClient wraps the Anthropic SDK client

func (*AnthropicClient) APIStyle

func (c *AnthropicClient) APIStyle() protocol.APIStyle

ProviderType returns the provider type

func (*AnthropicClient) BetaMessagesNew

BetaMessagesNew creates a new beta message request

func (*AnthropicClient) BetaMessagesNewStreaming

BetaMessagesNewStreaming creates a new beta streaming message request

func (*AnthropicClient) Client

func (c *AnthropicClient) Client() *anthropic.Client

Client returns the underlying Anthropic SDK client

func (*AnthropicClient) Close

func (c *AnthropicClient) Close() error

Close closes any resources held by the client

func (*AnthropicClient) GetProvider

func (c *AnthropicClient) GetProvider() *typ.Provider

GetProvider returns the provider for this client

func (*AnthropicClient) HttpClient

func (c *AnthropicClient) HttpClient() *http.Client

HttpClient returns the underlying HTTP client for passthrough/proxy operations

func (*AnthropicClient) MessagesCountTokens

MessagesCountTokens counts tokens for a message request

func (*AnthropicClient) MessagesNew

MessagesNew creates a new message request

func (*AnthropicClient) MessagesNewStreaming

MessagesNewStreaming creates a new streaming message request

func (*AnthropicClient) SetRecordSink

func (c *AnthropicClient) SetRecordSink(sink *obs.Sink)

SetRecordSink sets the record sink for the client

type ClientPool

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

ClientPool manages unified client instances for different providers

func NewClientPool

func NewClientPool() *ClientPool

NewClientPool creates a new client pool

func (*ClientPool) Clear

func (p *ClientPool) Clear()

Clear removes all clients from the pool

func (*ClientPool) GetAnthropicClient

func (p *ClientPool) GetAnthropicClient(provider *typ.Provider, model string) *AnthropicClient

GetAnthropicClient returns an Anthropic client wrapper for the specified provider

func (*ClientPool) GetGoogleClient

func (p *ClientPool) GetGoogleClient(provider *typ.Provider, model string) *GoogleClient

GetGoogleClient returns a Google client wrapper for the specified provider

func (*ClientPool) GetOpenAIClient

func (p *ClientPool) GetOpenAIClient(provider *typ.Provider, model string) *OpenAIClient

GetOpenAIClient returns an OpenAI client wrapper for the specified provider

func (*ClientPool) GetProviderKeys

func (p *ClientPool) GetProviderKeys() []string

GetProviderKeys returns all provider keys currently in the pool

func (*ClientPool) GetRecordSink

func (p *ClientPool) GetRecordSink() *obs.Sink

GetRecordSink returns the record sink

func (*ClientPool) RemoveProvider

func (p *ClientPool) RemoveProvider(provider *typ.Provider, model string)

RemoveProvider removes a specific provider's client from the pool

func (*ClientPool) SetRecordSink

func (p *ClientPool) SetRecordSink(sink *obs.Sink)

SetRecordSink sets the record sink for the client pool

func (*ClientPool) Size

func (p *ClientPool) Size() int

Size returns the total number of clients currently in both pools

func (*ClientPool) Stats

func (p *ClientPool) Stats() map[string]interface{}

Stats provides statistics about the client pool

type GoogleClient

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

GoogleClient wraps the Google genai SDK client

func NewGoogleClient

func NewGoogleClient(provider *typ.Provider) (*GoogleClient, error)

NewGoogleClient creates a new Google client wrapper

func (*GoogleClient) APIStyle

func (c *GoogleClient) APIStyle() protocol.APIStyle

ProviderType returns the provider type

func (*GoogleClient) Client

func (c *GoogleClient) Client() *genai.Client

Client returns the underlying Google genai SDK client

func (*GoogleClient) Close

func (c *GoogleClient) Close() error

Close closes any resources held by the client

func (*GoogleClient) GenerateContent

func (c *GoogleClient) GenerateContent(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)

GenerateContent generates content using the Google API

func (*GoogleClient) GenerateContentStream

func (c *GoogleClient) GenerateContentStream(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) iter.Seq2[*genai.GenerateContentResponse, error]

GenerateContentStream generates content using streaming

func (*GoogleClient) GetProvider

func (c *GoogleClient) GetProvider() *typ.Provider

GetProvider returns the provider for this client

func (*GoogleClient) SetRecordSink

func (c *GoogleClient) SetRecordSink(sink *obs.Sink)

SetRecordSink sets the record sink for the client

type HookFunc

type HookFunc func(req *http.Request) error

HookFunc is a function that can modify the request before it's sent

func GetOAuthHook added in v0.260124.900

func GetOAuthHook(providerType oauth.ProviderType) HookFunc

GetOAuthHook returns the hook function for the given provider type

type OpenAIClient

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

OpenAIClient wraps the OpenAI SDK client

func (*OpenAIClient) APIStyle

func (c *OpenAIClient) APIStyle() protocol.APIStyle

ProviderType returns the provider type

func (*OpenAIClient) ChatCompletionsNew

ChatCompletionsNew creates a new chat completion request

func (*OpenAIClient) ChatCompletionsNewStreaming

ChatCompletionsNewStreaming creates a new streaming chat completion request

func (*OpenAIClient) Client

func (c *OpenAIClient) Client() *openai.Client

Client returns the underlying OpenAI SDK client

func (*OpenAIClient) Close

func (c *OpenAIClient) Close() error

Close closes any resources held by the client

func (*OpenAIClient) GetProvider

func (c *OpenAIClient) GetProvider() *typ.Provider

GetProvider returns the provider for this client

func (*OpenAIClient) HttpClient

func (c *OpenAIClient) HttpClient() *http.Client

HttpClient returns the underlying HTTP client for passthrough/proxy operations

func (*OpenAIClient) ResponsesNew

ResponsesNew creates a new Responses API request

func (*OpenAIClient) ResponsesNewStreaming

ResponsesNewStreaming creates a new streaming Responses API request

func (*OpenAIClient) SetRecordSink

func (c *OpenAIClient) SetRecordSink(sink *obs.Sink)

SetRecordSink sets the record sink for the client

type RecordRoundTripper

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

RecordRoundTripper is an http.RoundTripper that records requests and responses

func NewRecordRoundTripper

func NewRecordRoundTripper(transport http.RoundTripper, recordSink *obs.Sink, provider, model string) *RecordRoundTripper

NewRecordRoundTripper creates a new record round tripper

func (*RecordRoundTripper) RoundTrip

func (r *RecordRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction and records request/response

Jump to

Keyboard shortcuts

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