llmproxyclient

package
v0.2.32 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package llmproxyclient provides an HTTP client for llm-proxy v2 JSON POST requests.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidClientConfig reports invalid llm-proxy client configuration.
	ErrInvalidClientConfig = errors.New("llm_proxy_client_invalid_config")
	// ErrInvalidClientRequest reports invalid llm-proxy request input.
	ErrInvalidClientRequest = errors.New("llm_proxy_client_invalid_request")
	// ErrClientHTTPFailure reports an unsuccessful llm-proxy HTTP response.
	ErrClientHTTPFailure = errors.New("llm_proxy_client_http_failure")
)

Functions

This section is empty.

Types

type Client

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

Client calls llm-proxy using a configured HTTP transport.

func NewClient

func NewClient(config Config, httpClient HTTPDoer) (Client, error)

NewClient creates a client from validated config and an injected HTTP transport.

func (Client) PostMessages added in v0.2.16

func (client Client) PostMessages(contextValue context.Context, request MessagesRequest) (string, error)

PostMessages sends a v2 JSON POST messages request and returns the response text.

type Config

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

Config is validated llm-proxy client configuration.

func NewConfig

func NewConfig(input ConfigInput) (Config, error)

NewConfig validates external client configuration.

func (Config) MessagesPostURL added in v0.2.16

func (config Config) MessagesPostURL() string

MessagesPostURL builds the authenticated v2 JSON POST URL for this config.

func (Config) Timeout

func (config Config) Timeout() time.Duration

Timeout returns the validated client timeout.

type ConfigInput

type ConfigInput struct {
	BaseURL  string
	Secret   string
	Provider string
	Timeout  time.Duration
}

ConfigInput is the unvalidated external configuration for an llm-proxy client.

type HTTPDoer

type HTTPDoer interface {
	Do(request *http.Request) (*http.Response, error)
}

HTTPDoer performs one HTTP request.

type MessageInput added in v0.2.16

type MessageInput struct {
	Role    string
	Content string
	// Order is optional; when any message sets it, every message in the request must set a unique non-negative value.
	Order *int
}

MessageInput is an unvalidated chat message for a v2 JSON POST request.

type MessagesRequest added in v0.2.16

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

MessagesRequest is a validated v2 messages-only JSON POST request.

func NewMessagesRequest added in v0.2.16

func NewMessagesRequest(input MessagesRequestInput) (MessagesRequest, error)

NewMessagesRequest validates v2 messages-only request input.

type MessagesRequestInput added in v0.2.16

type MessagesRequestInput struct {
	Messages  []MessageInput
	Model     string
	WebSearch bool
	MaxTokens *int
}

MessagesRequestInput is the unvalidated external input for a v2 messages-only JSON POST request.

Jump to

Keyboard shortcuts

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