llmproxyclient

package
v0.2.56 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 16 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")
	// ErrInvalidModelProfile reports an unreadable or invalid model-profile document.
	ErrInvalidModelProfile = errors.New("llm_proxy_client_invalid_model_profile")
	// ErrClientHTTPFailure reports an unsuccessful llm-proxy HTTP response.
	ErrClientHTTPFailure = errors.New("llm_proxy_client_http_failure")
)

Functions

This section is empty.

Types

type AudioAttachmentInput added in v0.2.55

type AudioAttachmentInput struct {
	MIMEType string
	Data     []byte
}

AudioAttachmentInput is unvalidated audio input supplied to NewAudioAttachment.

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, error)

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

type ConfigInput

type ConfigInput struct {
	BaseURL            string
	Secret             string
	Provider           string
	ModelProfilePath   string
	ModelProfileReader ModelProfileReader
}

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 ImageAttachmentInput added in v0.2.55

type ImageAttachmentInput struct {
	MIMEType string
	Data     []byte
}

ImageAttachmentInput is unvalidated image input supplied to NewImageAttachment.

type MessageAttachment added in v0.2.55

type MessageAttachment interface {
	// contains filtered or unexported methods
}

MessageAttachment is one validated provider-neutral media attachment.

func NewAudioAttachment added in v0.2.55

func NewAudioAttachment(input AudioAttachmentInput) (MessageAttachment, error)

NewAudioAttachment validates and hash-binds exact audio bytes.

func NewImageAttachment added in v0.2.55

func NewImageAttachment(input ImageAttachmentInput) (MessageAttachment, error)

NewImageAttachment validates and hash-binds exact image bytes.

type MessageInput added in v0.2.16

type MessageInput struct {
	Role        string
	Content     string
	Attachments []MessageAttachment
	// 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 is serialized as the native JSON boolean web_search field.
	WebSearch       bool
	MaxTokens       *int
	ReasoningEffort *string
	// RequestTimeoutSeconds optionally selects the proxy-owned wall-clock work budget.
	RequestTimeoutSeconds *int
}

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

type ModelProfileReader added in v0.2.34

type ModelProfileReader func(path string) ([]byte, error)

ModelProfileReader reads the current JSON model-profile document from a configured path.

Jump to

Keyboard shortcuts

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