Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateCost ¶ added in v0.2.0
EstimateCost returns a conservative per-call USD estimate. Unknown models use the documented fallback price so observability remains useful without exposing provider credentials or requiring a remote price lookup.
func ProviderDomain ¶ added in v0.2.0
ProviderDomain returns the egress domain (hostname) for a given provider. Returns empty string for unknown providers.
func ProviderDomains ¶ added in v0.2.0
ProviderDomains returns a map of all provider → domain mappings.
func SetTestEndpoints ¶
func SetTestEndpoints(openAI, anthropic, xai string) func()
SetTestEndpoints overrides provider endpoints for testing. Returns a restore function.
func SupportedProviders ¶
func SupportedProviders() []string
SupportedProviders returns the list of supported provider names.
Types ¶
type LLMResult ¶
type LLMResult struct {
Text string `json:"text"`
Tokens int64 `json:"tokens"`
Model string `json:"model,omitempty"`
InputTokens int64 `json:"input_tokens,omitempty"`
OutputTokens int64 `json:"output_tokens,omitempty"`
}
LLMResult holds the parsed response from an LLM provider call.
type ProviderAdapter ¶
type ProviderAdapter interface {
// BuildRequest creates an HTTP request for the LLM provider.
// credentialValue is the API key (NEVER logged or included in errors).
BuildRequest(ctx context.Context, model, prompt string, credentialValue string, maxTokens ...int) (*http.Request, error)
// ParseResponse extracts text and token count from the provider response body.
ParseResponse(statusCode int, body []byte) (*LLMResult, error)
// Endpoint returns the provider's API endpoint URL (for logging/audit).
Endpoint() string
// AuthHeader returns the header name used for the API key (e.g. "Authorization", "x-api-key").
AuthHeader() string
// Name returns the provider name (e.g. "openai", "anthropic", "xiai").
Name() string
}
ProviderAdapter maps an LLM provider to its API endpoint, auth header, request body format, and response parser. Used by the harness to route agent.llm() calls as credentialed HTTP egress (Option B unified egress).
func GetAdapter ¶
func GetAdapter(provider string) ProviderAdapter
GetAdapter returns the adapter for the given provider name. Supported: "openrouter", "openai", "anthropic", "xai"/"xiai", "nous". Returns nil for unknown providers.