llmproxyclient

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 18 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 Asset added in v1.0.0

type Asset struct {
	AssetID   string    `json:"asset_id"`
	MIMEType  string    `json:"mime_type"`
	SizeBytes int64     `json:"size_bytes"`
	SHA256    string    `json:"sha256"`
	State     string    `json:"state"`
	CreatedAt time.Time `json:"created_at"`
	ExpiresAt time.Time `json:"expires_at"`
}

Asset is a hash-bound tenant asset returned by llm-proxy.

type AssetUploadInput added in v1.0.0

type AssetUploadInput struct {
	MIMEType string
	Data     []byte
}

AssetUploadInput is the exact media content supplied to UploadAsset.

type AudioAssetAttachmentInput added in v1.0.0

type AudioAssetAttachmentInput struct {
	AssetID  string
	MIMEType string
	SHA256   string
}

AudioAssetAttachmentInput is an existing tenant audio asset supplied to NewAudioAssetAttachment.

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.

func (Client) UploadAsset added in v1.0.0

func (client Client) UploadAsset(contextValue context.Context, input AssetUploadInput) (Asset, error)

UploadAsset stores exact media bytes for later hash-bound attachment references.

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) AssetUploadURL added in v1.0.0

func (config Config) AssetUploadURL() string

AssetUploadURL builds the authenticated tenant asset upload URL for this config.

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 HTTPFailure added in v0.4.0

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

HTTPFailure is a completed non-2xx llm-proxy response. It exposes only the safe status and recognized stable proxy error code; the raw response body is deliberately unavailable.

func (*HTTPFailure) Error added in v0.4.0

func (failure *HTTPFailure) Error() string

Error reports the sanitized completed-response failure.

func (*HTTPFailure) ProxyErrorCode added in v0.4.0

func (failure *HTTPFailure) ProxyErrorCode() string

ProxyErrorCode returns the recognized stable proxy error code, or an empty string when the response has no recognized structured error code.

func (*HTTPFailure) StatusCode added in v0.4.0

func (failure *HTTPFailure) StatusCode() int

StatusCode returns the proxy HTTP response status.

func (*HTTPFailure) Unwrap added in v0.4.0

func (failure *HTTPFailure) Unwrap() error

Unwrap preserves errors.Is(error, ErrClientHTTPFailure).

type ImageAssetAttachmentInput added in v1.0.0

type ImageAssetAttachmentInput struct {
	AssetID  string
	MIMEType string
	SHA256   string
}

ImageAssetAttachmentInput is an existing tenant image asset supplied to NewImageAssetAttachment.

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 NewAudioAssetAttachment added in v1.0.0

func NewAudioAssetAttachment(input AudioAssetAttachmentInput) (MessageAttachment, error)

NewAudioAssetAttachment validates a hash-bound tenant audio asset reference.

func NewAudioAttachment added in v0.2.55

func NewAudioAttachment(input AudioAttachmentInput) (MessageAttachment, error)

NewAudioAttachment validates and hash-binds exact audio bytes.

func NewImageAssetAttachment added in v1.0.0

func NewImageAssetAttachment(input ImageAssetAttachmentInput) (MessageAttachment, error)

NewImageAssetAttachment validates a hash-bound tenant image asset reference.

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