lm15

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 17 Imported by: 0

README

lm15-go

Go implementation of the lm15 canonical model, ported from the lm15 contract (spec/types.md, spec/vocabularies.md, spec/invariants.md, docs/serde-rules.md, docs/mapping-rules.md).

Status

This port implements the frozen chat core per spec/SCOPE.md: canonical types and serde, error normalization, request building, response parsing, and stream replay (SSE parsing, per-provider event mapping, MAP-3 coalescing) for the four adapters (openai, openai_chat, anthropic, gemini).

Against the contract harness (all five directions) it passes 304 checks, 0 failures (request 110, response 102, stream 8, error 16, serde 68; 4 skips are cases not applicable to the shim protocol).

On top of the core sits the client layer: OpenAILM, OpenAIChatLM, AnthropicLM, GeminiLM with context-first Complete/Stream methods over a shared net/http client (stdlib only). Streams are normalized per MAP-3: exactly one StreamEndEvent ends the stream, carrying merged finish_reason and usage.

Not implemented: non-chat endpoints (embeddings, files, batch, image/audio generation) and live sessions (PROVISIONAL in spec/SCOPE.md).

Quickstart

package main

import (
	"context"
	"fmt"
	"os"

	lm15 "github.com/lm15-dev/lm15-go"
)

func main() {
	lm, _ := lm15.NewOpenAILM(os.Getenv("OPENAI_API_KEY"))
	maxTokens := int64(50)
	resp, err := lm.Complete(context.Background(), lm15.Request{
		Model:    "gpt-4.1-mini",
		System:   "You are terse.",
		Messages: []lm15.Message{lm15.UserMessage("Say hello in three words.")},
		Config:   &lm15.Config{MaxTokens: &maxTokens},
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(resp.Text())       // Hello there!
	fmt.Println(resp.FinishReason) // stop
	fmt.Println(*resp.Usage.TotalTokens)
}

The mental model is one straight line, same as the reference implementation: parts → Message → Request → LM → Response, with Stream as the event-wise twin.

Any OpenAI-compatible server is one compat preset away (the preset bundles the server's wire quirks and its default base URL):

lm, _ := lm15.NewOpenAIChatLM("ollama", lm15.WithCompat(lm15.CompatOllama))
// base URL -> http://localhost:11434/v1; swap CompatGroq, CompatOpenRouter, ...
resp, _ := lm.Complete(ctx, lm15.Request{
	Model:    "qwen3.5:0.8b",
	Messages: []lm15.Message{lm15.UserMessage("Say hello in five words or fewer.")},
	Config:   &lm15.Config{MaxTokens: &maxTokens, Extensions: map[string]any{"reasoning_effort": "none"}},
})
Streaming

Stream returns an iter.Seq2[StreamEvent, error]. Text arrives as StreamDeltaEvent{Delta: TextDelta{...}}; exactly one StreamEndEvent ends the stream with finish_reason and usage (MAP-3):

for ev, err := range lm.Stream(ctx, req) {
	if err != nil {
		panic(err)
	}
	if d, ok := ev.(lm15.StreamDeltaEvent); ok {
		if td, ok := d.Delta.(lm15.TextDelta); ok {
			fmt.Print(td.Text)
		}
	}
}

To consume a stream into a full Response (identical in shape to one from Complete): resp, err := lm.CollectResponse(ctx, req).

Tools: the full round-trip
desc := "Get the current weather for a city."
weather := lm15.FunctionTool{
	Name:        "get_weather",
	Description: &desc,
	Parameters: map[string]any{
		"type":       "object",
		"properties": map[string]any{"city": map[string]any{"type": "string"}},
		"required":   []any{"city"},
	},
}
req := lm15.Request{
	Model:    "gpt-4.1-mini",
	Messages: []lm15.Message{lm15.UserMessage("What is the weather in Montreal? Use the tool.")},
	Tools:    []lm15.Tool{weather},
}
first, _ := lm.Complete(ctx, req)
call := first.ToolCalls()[0] // typed ToolCallPart: ID, Name, Input
req.Messages = append(req.Messages,
	first.Message, // replay the assistant turn
	lm15.ToolResults(lm15.ToolResult(call.ID, "Sunny, 22C")),
)
final, _ := lm.Complete(ctx, req)
fmt.Println(final.Text()) // "The weather in Montreal is currently sunny ... 22°C."

All of the above ran live (June 2026): the quickstart and tools round-trip against OpenAI (gpt-4.1-mini), the compat example against local Ollama (qwen3.5:0.8b) and Groq (llama-3.1-8b-instant), and streaming against all three — see client_live_test.go for the exact assertions.

Live smoke tests

go test runs the live smokes when targets are available and skips them otherwise (CI-safe): -short skips all, each provider test skips without its key (OPENAI_API_KEY, GROQ_API_KEY), and the Ollama tests skip unless localhost:11434 answers.

Build

go mod download
go build -o bin/lm15-vet ./cmd/lm15-vet
go test ./...
go vet ./...

Conformance

cd ../lm15-contract
../lm15-python2/.venv/bin/python harness/check.py --shim go --direction all

The harness drives bin/lm15-vet (see harness/shims.json) inside a no-network sandbox; build the binary first.

Dependency budget

Zero third-party dependencies — standard library only, by policy.

Documentation

Index

Constants

View Source
const (
	CompatOpenAI     = "openai"
	CompatOllama     = "ollama"
	CompatGroq       = "groq"
	CompatOpenRouter = "openrouter"
	CompatVLLM       = "vllm"
	CompatSGLang     = "sglang"
	CompatLMStudio   = "lmstudio"
)

Compat preset names for WithCompat (see ChatCompatPreset).

View Source
const ImplVersion = "2.0.0-dev"

ImplVersion is the lm15-go implementation version reported by the shim.

Variables

View Source
var AudioEncodings = []string{"pcm16", "opus", "mp3", "aac"}
View Source
var BatchStatuses = []string{"submitted", "queued", "running", "completed", "failed", "cancelled"}
View Source
var CacheModes = []string{"auto", "off"}
View Source
var CacheRetentions = []string{"short", "long"}
View Source
var ChatPresetBaseURLs = map[string]string{
	"openai":     "https://api.openai.com/v1",
	"ollama":     "http://localhost:11434/v1",
	"groq":       "https://api.groq.com/openai/v1",
	"openrouter": "https://openrouter.ai/api/v1",
	"vllm":       "http://localhost:8000/v1",
	"sglang":     "http://localhost:30000/v1",
}

ChatPresetBaseURLs gives each preset's default server base URL.

View Source
var DefaultBaseURLs = map[string]string{
	"openai":      "https://api.openai.com/v1",
	"openai_chat": "https://api.openai.com/v1",
	"anthropic":   "https://api.anthropic.com/v1",
	"gemini":      "https://generativelanguage.googleapis.com/v1beta",
}

DefaultBaseURLs per provider.

View Source
var DeltaTypes = []string{
	"text", "thinking", "audio", "image", "tool_call", "citation", "continuation",
}
View Source
var ErrorCodes = []string{
	"auth", "billing", "rate_limit", "invalid_request", "context_length",
	"timeout", "server", "unsupported_model", "unsupported_feature",
	"not_configured", "transport", "provider",
}
View Source
var FinishReasons = []string{"stop", "length", "tool_call", "content_filter", "error"}
View Source
var LiveClientEventTypes = []string{"turn", "audio", "image", "text", "tool_result", "interrupt", "end_audio"}
View Source
var LiveServerEventTypes = []string{"audio", "text", "tool_call", "tool_call_delta", "interrupted", "turn_end", "error"}
View Source
var PartTypes = []string{
	"text", "image", "audio", "video", "document", "binary",
	"tool_call", "tool_result", "thinking", "refusal", "citation",
}
View Source
var ReasoningEfforts = []string{"off", "adaptive", "minimal", "low", "medium", "high", "xhigh"}
View Source
var ReasoningSummaries = []string{"auto", "concise", "detailed"}
View Source
var RoleValues = []string{"user", "assistant", "tool", "developer"}
View Source
var StreamEventTypes = []string{"start", "delta", "end", "error"}
View Source
var ToolChoiceModes = []string{"auto", "required", "none"}

Functions

func BuildRequestMap

func BuildRequestMap(provider string, canonical jmap, stream bool, apiKey, baseURL string) (jmap, error)

BuildRequestMap is the vet-protocol entry: canonical request JSON in, protocol-shaped transport request out.

func DefaultParameters

func DefaultParameters() jmap

DefaultParameters returns the default FunctionTool JSON-Schema payload.

func ErrTypeName

func ErrTypeName(err error) string

ErrTypeName reports the vet-protocol error type name for an error: the recorded native-exception-style name for serde errors, the canonical class name for lm15-typed errors, else "ValueError".

func MarshalPart

func MarshalPart(p Part) ([]byte, error)

MarshalPart serializes any Part to canonical JSON bytes.

func NormalizedErrorMap

func NormalizedErrorMap(err LM15Error) jmap

NormalizedErrorMap renders an LM15Error in the normalize_error vet output shape.

func ParseResponseMap

func ParseResponseMap(provider string, canonical jmap, status int, bodyB64 string) (jmap, error)

ParseResponseMap is the vet-shim entry: canonical Response JSON plus the unmapped canary per harness/PROTOCOL.md.

func PartToMap

func PartToMap(p Part) jmap

PartToMap serializes a Part to its canonical JSON object form.

func ReplayStream

func ReplayStream(provider string, req Request, body []byte) ([]StreamEvent, Response, error)

ReplayStream parses a captured SSE body for the given provider into the POST-coalesce canonical event trace plus the materialized Response.

func ReplayStreamMap

func ReplayStreamMap(provider string, canonical jmap, bodyB64 string) (jmap, error)

ReplayStreamMap is the vet-shim entry for the replay_stream op.

func SerdeRoundtrip

func SerdeRoundtrip(kind string, value jmap) (jmap, error)

SerdeRoundtrip implements the vet protocol's serde_roundtrip op: to_dict(from_dict(value)) for the given kind, no cleaning beyond the canonical serializers themselves.

func SurfaceDump

func SurfaceDump() jmap

SurfaceDump returns the type/enum surface for the vet protocol.

Types

type AnthropicLM

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

AnthropicLM talks to the Anthropic Messages API.

func NewAnthropicLM

func NewAnthropicLM(apiKey string, opts ...Option) (*AnthropicLM, error)

NewAnthropicLM builds an Anthropic Messages API client.

func (*AnthropicLM) CollectResponse

func (c *AnthropicLM) CollectResponse(ctx context.Context, req Request) (Response, error)

CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).

func (*AnthropicLM) Complete

func (c *AnthropicLM) Complete(ctx context.Context, req Request) (Response, error)

Complete sends the canonical Request and returns the canonical Response.

func (*AnthropicLM) Provider

func (c *AnthropicLM) Provider() string

Provider reports the adapter name ("openai", "openai_chat", ...).

func (*AnthropicLM) Stream

func (c *AnthropicLM) Stream(ctx context.Context, req Request) iter.Seq2[StreamEvent, error]

Stream sends the Request in streaming mode and yields canonical stream events. MAP-3 holds: exactly one StreamEndEvent ends the stream, last, carrying merged finish_reason/usage. Iteration stops at the first non-nil error; abandoning the loop closes the connection.

type AudioDelta

type AudioDelta struct {
	Data      *string `json:"data"`
	URL       *string `json:"url"`
	FileID    *string `json:"file_id"`
	PartIndex int64   `json:"part_index"`
	MediaType *string `json:"media_type"`
}

func (AudioDelta) DeltaType

func (d AudioDelta) DeltaType() string

func (AudioDelta) MarshalJSON

func (d AudioDelta) MarshalJSON() ([]byte, error)

type AudioFormat

type AudioFormat struct {
	Encoding   string `json:"encoding"`
	SampleRate int64  `json:"sample_rate"`
	Channels   int64  `json:"channels"`
}

func (AudioFormat) MarshalJSON

func (af AudioFormat) MarshalJSON() ([]byte, error)

func (*AudioFormat) UnmarshalJSON

func (af *AudioFormat) UnmarshalJSON(data []byte) error

type AudioGenerationRequest

type AudioGenerationRequest struct {
	Model      string  `json:"model"`
	Prompt     string  `json:"prompt"`
	Voice      *string `json:"voice"`
	Format     *string `json:"format"`
	Extensions jmap    `json:"extensions"`
}

type AudioGenerationResponse

type AudioGenerationResponse struct {
	Audio        AudioPart `json:"audio"`
	ID           *string   `json:"id"`
	Model        *string   `json:"model"`
	Usage        Usage     `json:"usage"`
	ProviderData jmap      `json:"provider_data"`
}

type AudioPart

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

func (AudioPart) Continuations

func (p AudioPart) Continuations() []ContinuationState

func (AudioPart) MarshalJSON

func (p AudioPart) MarshalJSON() ([]byte, error)

func (AudioPart) PartType

func (p AudioPart) PartType() string

type AuthError

type AuthError struct{ ProviderError }

func (AuthError) ClassName

func (AuthError) ClassName() string

func (AuthError) Code

func (AuthError) Code() string

func (AuthError) Unwrap

func (e AuthError) Unwrap() error

type BatchRequest

type BatchRequest struct {
	Model      string    `json:"model"`
	Requests   []Request `json:"requests"`
	Extensions jmap      `json:"extensions"`
}

type BatchResponse

type BatchResponse struct {
	ID           string `json:"id"`
	Status       string `json:"status"`
	ProviderData jmap   `json:"provider_data"`
}

type BillingError

type BillingError struct{ ProviderError }

func (BillingError) ClassName

func (BillingError) ClassName() string

func (BillingError) Code

func (BillingError) Code() string

func (BillingError) Unwrap

func (e BillingError) Unwrap() error

type BinaryPart

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

func (BinaryPart) Continuations

func (p BinaryPart) Continuations() []ContinuationState

func (BinaryPart) MarshalJSON

func (p BinaryPart) MarshalJSON() ([]byte, error)

func (BinaryPart) PartType

func (p BinaryPart) PartType() string

type BuiltinTool

type BuiltinTool struct {
	Name   string `json:"name"`
	Config jmap   `json:"config"`
}

func (BuiltinTool) MarshalJSON

func (t BuiltinTool) MarshalJSON() ([]byte, error)

func (BuiltinTool) ToolName

func (t BuiltinTool) ToolName() string

func (BuiltinTool) ToolType

func (t BuiltinTool) ToolType() string

type CacheConfig

type CacheConfig struct {
	Mode             string  `json:"mode"`
	Retention        *string `json:"retention"`
	Key              *string `json:"key"`
	PrefixUntilIndex *int64  `json:"prefix_until_index"`
}

type CapabilityError

type CapabilityError struct{ ErrorMeta }

func (CapabilityError) ClassName

func (CapabilityError) ClassName() string

func (CapabilityError) Code

func (CapabilityError) Code() string

func (CapabilityError) Retryable

func (CapabilityError) Retryable() bool

type ChatCompat

type ChatCompat struct {
	InstructionRole string // "system" | "developer"
	MaxTokensField  string // "max_completion_tokens" | "max_tokens"
	StreamUsage     string // "include" | "omit"
	ThinkingFormat  string // "none" | "reasoning_effort" | "openrouter" | ...
	ToolResultName  string // "include" | "omit"
	StrictTools     string // "include" | "omit"
	CacheControl    string // "none" | "openai"
	Routing         jmap
}

ChatCompat is the resolved OpenAI Chat Completions compatibility policy.

func ChatCompatPreset

func ChatCompatPreset(name string) (ChatCompat, error)

ChatCompatPreset resolves a named OpenAI-compatible server preset (ollama, groq, openrouter, vllm, sglang, openai, ...).

type CitationDelta

type CitationDelta struct {
	Text      *string `json:"text"`
	URL       *string `json:"url"`
	Title     *string `json:"title"`
	PartIndex int64   `json:"part_index"`
}

func (CitationDelta) DeltaType

func (d CitationDelta) DeltaType() string

func (CitationDelta) MarshalJSON

func (d CitationDelta) MarshalJSON() ([]byte, error)

type CitationPart

type CitationPart struct {
	URL          *string             `json:"url"`
	Title        *string             `json:"title"`
	Text         *string             `json:"text"`
	Continuation []ContinuationState `json:"continuation"`
}

func (CitationPart) Continuations

func (p CitationPart) Continuations() []ContinuationState

func (CitationPart) MarshalJSON

func (p CitationPart) MarshalJSON() ([]byte, error)

func (CitationPart) PartType

func (p CitationPart) PartType() string

type Config

type Config struct {
	MaxTokens      *int64       `json:"max_tokens"`
	Temperature    *float64     `json:"temperature"`
	TopP           *float64     `json:"top_p"`
	TopK           *int64       `json:"top_k"`
	Stop           []string     `json:"stop"`
	ResponseFormat jmap         `json:"response_format"`
	ToolChoice     *ToolChoice  `json:"tool_choice"`
	Reasoning      *Reasoning   `json:"reasoning"`
	Cache          *CacheConfig `json:"cache"`
	Extensions     jmap         `json:"extensions"`
}

func (Config) MarshalJSON

func (c Config) MarshalJSON() ([]byte, error)

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

type ConfigurationError

type ConfigurationError struct{ ErrorMeta }

func (ConfigurationError) ClassName

func (ConfigurationError) ClassName() string

func (ConfigurationError) Code

func (ConfigurationError) Code() string

func (ConfigurationError) Retryable

func (ConfigurationError) Retryable() bool

type ContextLengthError

type ContextLengthError struct{ InvalidRequestError }

func (ContextLengthError) ClassName

func (ContextLengthError) ClassName() string

func (ContextLengthError) Code

func (ContextLengthError) Code() string

func (ContextLengthError) Unwrap

func (e ContextLengthError) Unwrap() error

type ContinuationDelta

type ContinuationDelta struct {
	Provider  string `json:"provider"`
	Kind      string `json:"kind"`
	Data      jmap   `json:"data"`
	PartIndex *int64 `json:"part_index"`
}

func (ContinuationDelta) DeltaType

func (d ContinuationDelta) DeltaType() string

func (ContinuationDelta) MarshalJSON

func (d ContinuationDelta) MarshalJSON() ([]byte, error)

func (ContinuationDelta) ToState

ToState converts a ContinuationDelta to its ContinuationState.

type ContinuationState

type ContinuationState struct {
	Provider string `json:"provider"`
	Kind     string `json:"kind"`
	Data     jmap   `json:"data"`
}

func (ContinuationState) MarshalJSON

func (c ContinuationState) MarshalJSON() ([]byte, error)

func (*ContinuationState) UnmarshalJSON

func (c *ContinuationState) UnmarshalJSON(data []byte) error

type Delta

type Delta interface {
	DeltaType() string
	// contains filtered or unexported methods
}

Delta is the tagged union of streaming deltas, dispatching on "type".

func DeltaFromMap

func DeltaFromMap(m jmap) (Delta, error)

DeltaFromMap deserializes a Delta, dispatching on "type".

type DocumentPart

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

func (DocumentPart) Continuations

func (p DocumentPart) Continuations() []ContinuationState

func (DocumentPart) MarshalJSON

func (p DocumentPart) MarshalJSON() ([]byte, error)

func (DocumentPart) PartType

func (p DocumentPart) PartType() string

type EmbeddingRequest

type EmbeddingRequest struct {
	Model      string   `json:"model"`
	Inputs     []string `json:"inputs"`
	Extensions jmap     `json:"extensions"`
}

type EmbeddingResponse

type EmbeddingResponse struct {
	Model        string      `json:"model"`
	Vectors      [][]float64 `json:"vectors"`
	Usage        Usage       `json:"usage"`
	ProviderData jmap        `json:"provider_data"`
}

type ErrorDetail

type ErrorDetail struct {
	Code         string  `json:"code"`
	Message      string  `json:"message"`
	ProviderCode *string `json:"provider_code"`
}

func (ErrorDetail) MarshalJSON

func (e ErrorDetail) MarshalJSON() ([]byte, error)

func (*ErrorDetail) UnmarshalJSON

func (e *ErrorDetail) UnmarshalJSON(data []byte) error

type ErrorMeta

type ErrorMeta struct {
	Message      string
	Provider     string
	ProviderCode string
	Status       int
	RequestID    string
	RetryAfter   *float64
}

ErrorMeta is the shared metadata of every canonical lm15 error.

func Meta

func Meta(err LM15Error) ErrorMeta

Meta exposes the metadata of any canonical error (used by the shim and callers via errors.As targets).

func (ErrorMeta) Error

func (m ErrorMeta) Error() string

type FileUploadRequest

type FileUploadRequest struct {
	Filename   string `json:"filename"`
	BytesData  []byte `json:"bytes_data"`
	MediaType  string `json:"media_type"`
	Model      string `json:"model"`
	Extensions jmap   `json:"extensions"`
	Path       string `json:"path"`
}

FileUploadRequest is in-memory only (no canonical JSON serializer).

type FileUploadResponse

type FileUploadResponse struct {
	ID           string `json:"id"`
	ProviderData jmap   `json:"provider_data"`
}

type FunctionTool

type FunctionTool struct {
	Name        string  `json:"name"`
	Description *string `json:"description"`
	Parameters  jmap    `json:"parameters"`
}

func (FunctionTool) MarshalJSON

func (t FunctionTool) MarshalJSON() ([]byte, error)

func (FunctionTool) ToolName

func (t FunctionTool) ToolName() string

func (FunctionTool) ToolType

func (t FunctionTool) ToolType() string

type GeminiLM

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

GeminiLM talks to the Google Gemini generateContent API.

func NewGeminiLM

func NewGeminiLM(apiKey string, opts ...Option) (*GeminiLM, error)

NewGeminiLM builds a Gemini client.

func (*GeminiLM) CollectResponse

func (c *GeminiLM) CollectResponse(ctx context.Context, req Request) (Response, error)

CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).

func (*GeminiLM) Complete

func (c *GeminiLM) Complete(ctx context.Context, req Request) (Response, error)

Complete sends the canonical Request and returns the canonical Response.

func (*GeminiLM) Provider

func (c *GeminiLM) Provider() string

Provider reports the adapter name ("openai", "openai_chat", ...).

func (*GeminiLM) Stream

func (c *GeminiLM) Stream(ctx context.Context, req Request) iter.Seq2[StreamEvent, error]

Stream sends the Request in streaming mode and yields canonical stream events. MAP-3 holds: exactly one StreamEndEvent ends the stream, last, carrying merged finish_reason/usage. Iteration stops at the first non-nil error; abandoning the loop closes the connection.

type ImageDelta

type ImageDelta struct {
	Data      *string `json:"data"`
	URL       *string `json:"url"`
	FileID    *string `json:"file_id"`
	PartIndex int64   `json:"part_index"`
	MediaType *string `json:"media_type"`
}

func (ImageDelta) DeltaType

func (d ImageDelta) DeltaType() string

func (ImageDelta) MarshalJSON

func (d ImageDelta) MarshalJSON() ([]byte, error)

type ImageGenerationRequest

type ImageGenerationRequest struct {
	Model      string  `json:"model"`
	Prompt     string  `json:"prompt"`
	Size       *string `json:"size"`
	Extensions jmap    `json:"extensions"`
}

type ImageGenerationResponse

type ImageGenerationResponse struct {
	Images       []ImagePart `json:"images"`
	ID           *string     `json:"id"`
	Model        *string     `json:"model"`
	Usage        Usage       `json:"usage"`
	ProviderData jmap        `json:"provider_data"`
}

type ImagePart

type ImagePart struct {
	Detail *string `json:"detail"`
	// contains filtered or unexported fields
}

func (ImagePart) Continuations

func (p ImagePart) Continuations() []ContinuationState

func (ImagePart) MarshalJSON

func (p ImagePart) MarshalJSON() ([]byte, error)

func (ImagePart) PartType

func (p ImagePart) PartType() string

type InferenceModelInfo

type InferenceModelInfo struct {
	InputModalities   []string          `json:"input_modalities"`
	OutputModalities  []string          `json:"output_modalities"`
	ContextWindow     *int64            `json:"context_window"`
	MaxOutputTokens   *int64            `json:"max_output_tokens"`
	SupportsReasoning bool              `json:"supports_reasoning"`
	ReasoningEfforts  []string          `json:"reasoning_efforts"`
	Pricing           *InferencePricing `json:"pricing"`
	Extensions        jmap              `json:"extensions"`
}

type InferencePricing

type InferencePricing struct {
	InputPerMillion      *float64 `json:"input_per_million"`
	OutputPerMillion     *float64 `json:"output_per_million"`
	CacheReadPerMillion  *float64 `json:"cache_read_per_million"`
	CacheWritePerMillion *float64 `json:"cache_write_per_million"`
	Currency             string   `json:"currency"`
	Dimensions           jmap     `json:"dimensions"`
}

type InvalidRequestError

type InvalidRequestError struct{ ProviderError }

func (InvalidRequestError) ClassName

func (InvalidRequestError) ClassName() string

func (InvalidRequestError) Code

func (InvalidRequestError) Code() string

func (InvalidRequestError) Unwrap

func (e InvalidRequestError) Unwrap() error

type LM15Error

type LM15Error interface {
	error
	Code() string
	ClassName() string
	Retryable() bool
}

LM15Error is implemented by every canonical lm15 error type.

func ErrorForCode

func ErrorForCode(code, message string) LM15Error

ErrorForCode maps a canonical ErrorCode to a fresh error value of the most specific canonical class; unknown codes map to ProviderError.

func MapHTTPError

func MapHTTPError(status int, message, provider, providerCode, requestID string) LM15Error

MapHTTPError maps an HTTP status + message to a typed canonical error, per the spec's HTTP mapping table (unmatched status -> ProviderError).

func NormalizeError

func NormalizeError(provider string, status int, body string) (LM15Error, error)

NormalizeError maps a provider HTTP error response to the canonical error for the given provider ("openai", "openai_chat", "anthropic", "gemini").

type LiveClientAudioEvent

type LiveClientAudioEvent struct {
	Data      string `json:"data"`
	MediaType string `json:"media_type"`
}

func (LiveClientAudioEvent) LiveClientEventType

func (e LiveClientAudioEvent) LiveClientEventType() string

type LiveClientEndAudioEvent

type LiveClientEndAudioEvent struct{}

func (LiveClientEndAudioEvent) LiveClientEventType

func (e LiveClientEndAudioEvent) LiveClientEventType() string

type LiveClientEvent

type LiveClientEvent interface {
	LiveClientEventType() string
	// contains filtered or unexported methods
}

LiveClientEvent is the tagged union of client→server live events.

func LiveClientEventFromMap

func LiveClientEventFromMap(m jmap) (LiveClientEvent, error)

LiveClientEventFromMap dispatches on "type".

type LiveClientImageEvent

type LiveClientImageEvent struct {
	Data      string `json:"data"`
	MediaType string `json:"media_type"`
}

func (LiveClientImageEvent) LiveClientEventType

func (e LiveClientImageEvent) LiveClientEventType() string

type LiveClientInterruptEvent

type LiveClientInterruptEvent struct{}

func (LiveClientInterruptEvent) LiveClientEventType

func (e LiveClientInterruptEvent) LiveClientEventType() string

type LiveClientTextEvent

type LiveClientTextEvent struct {
	Text string `json:"text"`
}

func (LiveClientTextEvent) LiveClientEventType

func (e LiveClientTextEvent) LiveClientEventType() string

type LiveClientToolResultEvent

type LiveClientToolResultEvent struct {
	ID      string `json:"id"`
	Content []Part `json:"content"`
}

func (LiveClientToolResultEvent) LiveClientEventType

func (e LiveClientToolResultEvent) LiveClientEventType() string

type LiveClientTurnEvent

type LiveClientTurnEvent struct {
	Parts        []Part `json:"parts"`
	TurnComplete bool   `json:"turn_complete"`
}

func (LiveClientTurnEvent) LiveClientEventType

func (e LiveClientTurnEvent) LiveClientEventType() string

type LiveConfig

type LiveConfig struct {
	Model        string       `json:"model"`
	System       any          `json:"system"` // string or []Part
	Tools        []Tool       `json:"tools"`
	Voice        *string      `json:"voice"`
	InputFormat  *AudioFormat `json:"input_format"`
	OutputFormat *AudioFormat `json:"output_format"`
	Extensions   jmap         `json:"extensions"`
}

func (LiveConfig) MarshalJSON

func (lc LiveConfig) MarshalJSON() ([]byte, error)

func (*LiveConfig) UnmarshalJSON

func (lc *LiveConfig) UnmarshalJSON(data []byte) error

type LiveServerAudioEvent

type LiveServerAudioEvent struct {
	Data      string  `json:"data"`
	MediaType *string `json:"media_type"`
}

func (LiveServerAudioEvent) LiveServerEventType

func (e LiveServerAudioEvent) LiveServerEventType() string

type LiveServerErrorEvent

type LiveServerErrorEvent struct {
	Error ErrorDetail `json:"error"`
}

func (LiveServerErrorEvent) LiveServerEventType

func (e LiveServerErrorEvent) LiveServerEventType() string

type LiveServerEvent

type LiveServerEvent interface {
	LiveServerEventType() string
	// contains filtered or unexported methods
}

LiveServerEvent is the tagged union of server→client live events.

func LiveServerEventFromMap

func LiveServerEventFromMap(m jmap) (LiveServerEvent, error)

LiveServerEventFromMap dispatches on "type".

type LiveServerInterruptedEvent

type LiveServerInterruptedEvent struct{}

func (LiveServerInterruptedEvent) LiveServerEventType

func (e LiveServerInterruptedEvent) LiveServerEventType() string

type LiveServerTextEvent

type LiveServerTextEvent struct {
	Text string `json:"text"`
}

func (LiveServerTextEvent) LiveServerEventType

func (e LiveServerTextEvent) LiveServerEventType() string

type LiveServerToolCallDeltaEvent

type LiveServerToolCallDeltaEvent struct {
	InputDelta string  `json:"input_delta"`
	ID         *string `json:"id"`
	Name       *string `json:"name"`
}

func (LiveServerToolCallDeltaEvent) LiveServerEventType

func (e LiveServerToolCallDeltaEvent) LiveServerEventType() string

type LiveServerToolCallEvent

type LiveServerToolCallEvent struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Input jmap   `json:"input"`
}

func (LiveServerToolCallEvent) LiveServerEventType

func (e LiveServerToolCallEvent) LiveServerEventType() string

type LiveServerTurnEndEvent

type LiveServerTurnEndEvent struct {
	Usage Usage `json:"usage"`
}

func (LiveServerTurnEndEvent) LiveServerEventType

func (e LiveServerTurnEndEvent) LiveServerEventType() string

type Message

type Message struct {
	Role         string              `json:"role"`
	Parts        []Part              `json:"parts"`
	Continuation []ContinuationState `json:"continuation"`
}

func AssistantMessage

func AssistantMessage(text string) Message

AssistantMessage creates an assistant message from text.

func AssistantMessageParts

func AssistantMessageParts(parts ...Part) Message

AssistantMessageParts creates an assistant message from explicit parts (e.g. replaying the model's ToolCallParts in a tools round-trip).

func ToolResults

func ToolResults(results ...ToolResultPart) Message

ToolResults creates a tool message carrying one or more tool results.

func UserMessage

func UserMessage(text string) Message

UserMessage creates a user message from text.

func UserMessageParts

func UserMessageParts(parts ...Part) Message

UserMessageParts creates a user message from explicit parts.

func (Message) MarshalJSON

func (msg Message) MarshalJSON() ([]byte, error)

func (*Message) UnmarshalJSON

func (msg *Message) UnmarshalJSON(data []byte) error

type ModelInfo

type ModelInfo struct {
	ID         string              `json:"id"`
	Provider   string              `json:"provider"`
	APIFamily  string              `json:"api_family"`
	Aliases    []string            `json:"aliases"`
	Origin     ModelOrigin         `json:"origin"`
	Inference  *InferenceModelInfo `json:"inference"`
	Training   *TrainingModelInfo  `json:"training"`
	Extensions jmap                `json:"extensions"`
}

func (ModelInfo) MarshalJSON

func (mi ModelInfo) MarshalJSON() ([]byte, error)

func (*ModelInfo) UnmarshalJSON

func (mi *ModelInfo) UnmarshalJSON(data []byte) error

type ModelOrigin

type ModelOrigin struct {
	Type         string  `json:"type"`
	ID           *string `json:"id"`
	BaseModel    *string `json:"base_model"`
	ProviderData jmap    `json:"provider_data"`
}

type NotConfiguredError

type NotConfiguredError struct{ ConfigurationError }

func (NotConfiguredError) ClassName

func (NotConfiguredError) ClassName() string

func (NotConfiguredError) Unwrap

func (e NotConfiguredError) Unwrap() error

Unwrap methods expose the class hierarchy to errors.As/errors.Is: each subclass unwraps to its embedded parent class.

type OpenAIChatLM

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

OpenAIChatLM talks to the OpenAI Chat Completions dialect — OpenAI itself or any compatible server via WithCompat / WithBaseURL.

func NewOpenAIChatLM

func NewOpenAIChatLM(apiKey string, opts ...Option) (*OpenAIChatLM, error)

NewOpenAIChatLM builds a Chat Completions client (OpenAI-compatible servers).

func (*OpenAIChatLM) CollectResponse

func (c *OpenAIChatLM) CollectResponse(ctx context.Context, req Request) (Response, error)

CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).

func (*OpenAIChatLM) Complete

func (c *OpenAIChatLM) Complete(ctx context.Context, req Request) (Response, error)

Complete sends the canonical Request and returns the canonical Response.

func (*OpenAIChatLM) Provider

func (c *OpenAIChatLM) Provider() string

Provider reports the adapter name ("openai", "openai_chat", ...).

func (*OpenAIChatLM) Stream

func (c *OpenAIChatLM) Stream(ctx context.Context, req Request) iter.Seq2[StreamEvent, error]

Stream sends the Request in streaming mode and yields canonical stream events. MAP-3 holds: exactly one StreamEndEvent ends the stream, last, carrying merged finish_reason/usage. Iteration stops at the first non-nil error; abandoning the loop closes the connection.

type OpenAILM

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

OpenAILM talks to the OpenAI Responses API.

func NewOpenAILM

func NewOpenAILM(apiKey string, opts ...Option) (*OpenAILM, error)

NewOpenAILM builds an OpenAI Responses API client.

func (*OpenAILM) CollectResponse

func (c *OpenAILM) CollectResponse(ctx context.Context, req Request) (Response, error)

CollectResponse runs Stream and materializes the events into a Response — the streaming twin of Complete (same shape: message, finish_reason, usage).

func (*OpenAILM) Complete

func (c *OpenAILM) Complete(ctx context.Context, req Request) (Response, error)

Complete sends the canonical Request and returns the canonical Response.

func (*OpenAILM) Provider

func (c *OpenAILM) Provider() string

Provider reports the adapter name ("openai", "openai_chat", ...).

func (*OpenAILM) Stream

func (c *OpenAILM) Stream(ctx context.Context, req Request) iter.Seq2[StreamEvent, error]

Stream sends the Request in streaming mode and yields canonical stream events. MAP-3 holds: exactly one StreamEndEvent ends the stream, last, carrying merged finish_reason/usage. Iteration stops at the first non-nil error; abandoning the loop closes the connection.

type Option

type Option func(*providerClient) error

Option configures an LM constructor.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the provider's default base URL.

func WithCompat

func WithCompat(preset string) Option

WithCompat selects an OpenAI Chat Completions compat preset by name (CompatOllama, CompatGroq, ...). The preset bundles the server's wire quirks and its default base URL; an explicit WithBaseURL still wins. Only meaningful for NewOpenAIChatLM.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient substitutes the shared http.Client.

type Part

type Part interface {
	PartType() string
	Continuations() []ContinuationState
	// contains filtered or unexported methods
}

Part is the canonical tagged union of message content. Concrete structs carry custom JSON marshalling dispatching on the "type" discriminator.

func PartFromMap

func PartFromMap(m jmap) (Part, error)

PartFromMap deserializes a Part from canonical JSON, dispatching on "type".

func UnmarshalPart

func UnmarshalPart(data []byte) (Part, error)

UnmarshalPart deserializes canonical JSON bytes into a Part.

type ProviderError

type ProviderError struct{ ErrorMeta }

func (ProviderError) ClassName

func (ProviderError) ClassName() string

func (ProviderError) Code

func (ProviderError) Code() string

func (ProviderError) Retryable

func (ProviderError) Retryable() bool

type RateLimitError

type RateLimitError struct{ ProviderError }

func (RateLimitError) ClassName

func (RateLimitError) ClassName() string

func (RateLimitError) Code

func (RateLimitError) Code() string

func (RateLimitError) Retryable

func (RateLimitError) Retryable() bool

func (RateLimitError) Unwrap

func (e RateLimitError) Unwrap() error

type Reasoning

type Reasoning struct {
	Effort         string  `json:"effort"`
	ThinkingBudget *int64  `json:"thinking_budget"`
	TotalBudget    *int64  `json:"total_budget"`
	Summary        *string `json:"summary"`
}

func (Reasoning) IsOff

func (r Reasoning) IsOff() bool

type RefusalPart

type RefusalPart struct {
	Text         string              `json:"text"`
	Continuation []ContinuationState `json:"continuation"`
}

func (RefusalPart) Continuations

func (p RefusalPart) Continuations() []ContinuationState

func (RefusalPart) MarshalJSON

func (p RefusalPart) MarshalJSON() ([]byte, error)

func (RefusalPart) PartType

func (p RefusalPart) PartType() string

type Request

type Request struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
	System   any       `json:"system"` // string or []Part
	Tools    []Tool    `json:"tools"`
	Config   *Config   `json:"config"`
}

func (Request) MarshalJSON

func (r Request) MarshalJSON() ([]byte, error)

func (*Request) UnmarshalJSON

func (r *Request) UnmarshalJSON(data []byte) error

type Response

type Response struct {
	ID           *string `json:"id"`
	Model        string  `json:"model"`
	Message      Message `json:"message"`
	FinishReason string  `json:"finish_reason"`
	Usage        Usage   `json:"usage"`
	ProviderData jmap    `json:"provider_data"`
}

func MaterializeResponse

func MaterializeResponse(events []StreamEvent, req Request) Response

MaterializeResponse consumes a canonical event trace and builds the complete Response.

func ParseResponse

func ParseResponse(provider string, req Request, status int, body []byte) (Response, []jmap, error)

ParseResponse maps a provider HTTP response body into the canonical Response. The returned recorder entries are the _lm15_unmapped canary.

func (Response) MarshalJSON

func (r Response) MarshalJSON() ([]byte, error)

func (Response) Text

func (r Response) Text() string

Text returns the concatenated assistant text, or "" when the response carries no text. Citation and thinking parts are metadata around the visible answer and don't block extraction; any other part type does.

func (Response) ToolCalls

func (r Response) ToolCalls() []ToolCallPart

ToolCalls returns the response's tool-call parts, in order.

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(data []byte) error

type SSEEvent

type SSEEvent struct {
	Event *string
	Data  string
}

SSEEvent is one parsed server-sent event.

func ParseSSE

func ParseSSE(body []byte) ([]SSEEvent, error)

ParseSSE parses a complete SSE body into events.

type ServerError

type ServerError struct{ ProviderError }

func (ServerError) ClassName

func (ServerError) ClassName() string

func (ServerError) Code

func (ServerError) Code() string

func (ServerError) Retryable

func (ServerError) Retryable() bool

func (ServerError) Unwrap

func (e ServerError) Unwrap() error

type StreamDeltaEvent

type StreamDeltaEvent struct {
	Delta Delta `json:"delta"`
}

func (StreamDeltaEvent) MarshalJSON

func (e StreamDeltaEvent) MarshalJSON() ([]byte, error)

func (StreamDeltaEvent) StreamEventType

func (e StreamDeltaEvent) StreamEventType() string

type StreamEndEvent

type StreamEndEvent struct {
	FinishReason *string `json:"finish_reason"`
	Usage        *Usage  `json:"usage"`
	ProviderData jmap    `json:"provider_data"`
}

func (StreamEndEvent) MarshalJSON

func (e StreamEndEvent) MarshalJSON() ([]byte, error)

func (StreamEndEvent) StreamEventType

func (e StreamEndEvent) StreamEventType() string

type StreamErrorEvent

type StreamErrorEvent struct {
	Error ErrorDetail `json:"error"`
}

func (StreamErrorEvent) MarshalJSON

func (e StreamErrorEvent) MarshalJSON() ([]byte, error)

func (StreamErrorEvent) StreamEventType

func (e StreamErrorEvent) StreamEventType() string

type StreamEvent

type StreamEvent interface {
	StreamEventType() string
	// contains filtered or unexported methods
}

StreamEvent is the tagged union of stream events, dispatching on "type".

func CoalesceStream

func CoalesceStream(events []StreamEvent) []StreamEvent

CoalesceStream enforces MAP-3 (docs/mapping-rules.md): a stream yields exactly one StreamEndEvent, as the final event. Adapters are stateless and may emit one end event per provider terminal frame (finish_reason chunk, post-finish usage-only chunk, [DONE], message_delta + message_stop). This pass absorbs every end event's fields — a later non-nil field replaces the accumulated value, a nil field never erases one — and appends the single merged end event. If no end event was seen, none is fabricated.

func ParseStreamEvents

func ParseStreamEvents(provider string, req Request, raw SSEEvent) ([]StreamEvent, error)

ParseStreamEvents maps one SSE frame to canonical stream events.

func StreamEventFromMap

func StreamEventFromMap(m jmap) (StreamEvent, error)

StreamEventFromMap deserializes a StreamEvent, dispatching on "type".

type StreamStartEvent

type StreamStartEvent struct {
	ID    *string `json:"id"`
	Model *string `json:"model"`
}

func (StreamStartEvent) MarshalJSON

func (e StreamStartEvent) MarshalJSON() ([]byte, error)

func (StreamStartEvent) StreamEventType

func (e StreamStartEvent) StreamEventType() string

type TextDelta

type TextDelta struct {
	Text      string `json:"text"`
	PartIndex int64  `json:"part_index"`
}

func (TextDelta) DeltaType

func (d TextDelta) DeltaType() string

func (TextDelta) MarshalJSON

func (d TextDelta) MarshalJSON() ([]byte, error)

type TextPart

type TextPart struct {
	Text         string              `json:"text"`
	Continuation []ContinuationState `json:"continuation"`
}

func Text

func Text(content string) TextPart

Text creates a text part.

func (TextPart) Continuations

func (p TextPart) Continuations() []ContinuationState

func (TextPart) MarshalJSON

func (p TextPart) MarshalJSON() ([]byte, error)

func (TextPart) PartType

func (p TextPart) PartType() string

type ThinkingDelta

type ThinkingDelta struct {
	Text      string `json:"text"`
	PartIndex int64  `json:"part_index"`
}

func (ThinkingDelta) DeltaType

func (d ThinkingDelta) DeltaType() string

func (ThinkingDelta) MarshalJSON

func (d ThinkingDelta) MarshalJSON() ([]byte, error)

type ThinkingPart

type ThinkingPart struct {
	Text         string              `json:"text"`
	Redacted     bool                `json:"redacted"`
	Continuation []ContinuationState `json:"continuation"`
}

func (ThinkingPart) Continuations

func (p ThinkingPart) Continuations() []ContinuationState

func (ThinkingPart) MarshalJSON

func (p ThinkingPart) MarshalJSON() ([]byte, error)

func (ThinkingPart) PartType

func (p ThinkingPart) PartType() string

type TimeoutError

type TimeoutError struct{ ProviderError }

func (TimeoutError) ClassName

func (TimeoutError) ClassName() string

func (TimeoutError) Code

func (TimeoutError) Code() string

func (TimeoutError) Retryable

func (TimeoutError) Retryable() bool

func (TimeoutError) Unwrap

func (e TimeoutError) Unwrap() error

type Tool

type Tool interface {
	ToolType() string
	ToolName() string
	// contains filtered or unexported methods
}

Tool is the tagged union of FunctionTool and BuiltinTool.

func ToolFromMap

func ToolFromMap(m jmap) (Tool, error)

ToolFromMap dispatches on "type": "builtin" → BuiltinTool; anything else (including absent) → FunctionTool (INV-034).

type ToolCallDelta

type ToolCallDelta struct {
	Input     string  `json:"input"`
	PartIndex int64   `json:"part_index"`
	ID        *string `json:"id"`
	Name      *string `json:"name"`
}

func (ToolCallDelta) DeltaType

func (d ToolCallDelta) DeltaType() string

func (ToolCallDelta) MarshalJSON

func (d ToolCallDelta) MarshalJSON() ([]byte, error)

type ToolCallInfo

type ToolCallInfo struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Input jmap   `json:"input"`
}

ToolCallInfo is the in-memory callback view of a ToolCallPart.

func ToolCallInfoFromPart

func ToolCallInfoFromPart(p ToolCallPart) ToolCallInfo

FromPart builds a ToolCallInfo from a ToolCallPart.

func (ToolCallInfo) ToPart

func (i ToolCallInfo) ToPart() ToolCallPart

ToPart converts back to a ToolCallPart.

type ToolCallPart

type ToolCallPart struct {
	ID           string              `json:"id"`
	Name         string              `json:"name"`
	Input        jmap                `json:"input"`
	Continuation []ContinuationState `json:"continuation"`
}

func (ToolCallPart) Continuations

func (p ToolCallPart) Continuations() []ContinuationState

func (ToolCallPart) MarshalJSON

func (p ToolCallPart) MarshalJSON() ([]byte, error)

func (ToolCallPart) PartType

func (p ToolCallPart) PartType() string

type ToolChoice

type ToolChoice struct {
	Mode     string   `json:"mode"`
	Allowed  []string `json:"allowed"`
	Parallel *bool    `json:"parallel"`
}

type ToolResultPart

type ToolResultPart struct {
	ID           string              `json:"id"`
	Content      []Part              `json:"content"`
	Name         *string             `json:"name"`
	IsError      bool                `json:"is_error"`
	Continuation []ContinuationState `json:"continuation"`
}

func ToolResult

func ToolResult(callID, content string) ToolResultPart

ToolResult builds a text tool result answering the tool call with this ID.

func (ToolResultPart) Continuations

func (p ToolResultPart) Continuations() []ContinuationState

func (ToolResultPart) MarshalJSON

func (p ToolResultPart) MarshalJSON() ([]byte, error)

func (ToolResultPart) PartType

func (p ToolResultPart) PartType() string

type TrainingModelInfo

type TrainingModelInfo struct {
	SupportsLora         bool             `json:"supports_lora"`
	SupportsFullFinetune bool             `json:"supports_full_finetune"`
	TrainableModalities  []string         `json:"trainable_modalities"`
	Pricing              *TrainingPricing `json:"pricing"`
	Extensions           jmap             `json:"extensions"`
}

type TrainingPricing

type TrainingPricing struct {
	TrainingTokensPerMillion *float64 `json:"training_tokens_per_million"`
	GPUSecond                *float64 `json:"gpu_second"`
	Currency                 string   `json:"currency"`
	Dimensions               jmap     `json:"dimensions"`
}

type TransportError

type TransportError struct{ ErrorMeta }

func (TransportError) ClassName

func (TransportError) ClassName() string

func (TransportError) Code

func (TransportError) Code() string

func (TransportError) Retryable

func (TransportError) Retryable() bool

type TransportRequest

type TransportRequest struct {
	Method  string
	URL     string
	Params  map[string]string
	Headers map[string]string
	Body    jmap
}

TransportRequest is the pure build_request output: the wire request the transport would send. Params are decoded query parameters (PROTOCOL.md: encoding is the transport's responsibility); header names are lowercase.

func BuildRequest

func BuildRequest(provider string, req Request, stream bool, apiKey, baseURL string) (TransportRequest, error)

BuildRequest builds the provider wire request for a canonical Request. baseURL == "" means the provider default.

type UnsupportedFeatureError

type UnsupportedFeatureError struct{ CapabilityError }

func (UnsupportedFeatureError) ClassName

func (UnsupportedFeatureError) ClassName() string

func (UnsupportedFeatureError) Unwrap

func (e UnsupportedFeatureError) Unwrap() error

type UnsupportedModelError

type UnsupportedModelError struct{ InvalidRequestError }

func (UnsupportedModelError) ClassName

func (UnsupportedModelError) ClassName() string

func (UnsupportedModelError) Code

func (UnsupportedModelError) Unwrap

func (e UnsupportedModelError) Unwrap() error

type Usage

type Usage struct {
	InputTokens       *int64 `json:"input_tokens"`
	OutputTokens      *int64 `json:"output_tokens"`
	TotalTokens       *int64 `json:"total_tokens"`
	CacheReadTokens   *int64 `json:"cache_read_tokens"`
	CacheWriteTokens  *int64 `json:"cache_write_tokens"`
	ReasoningTokens   *int64 `json:"reasoning_tokens"`
	InputAudioTokens  *int64 `json:"input_audio_tokens"`
	OutputAudioTokens *int64 `json:"output_audio_tokens"`
}

Usage counters are *int64: nil means "not reported by the provider", distinct from a reported 0.

func (Usage) MarshalJSON

func (u Usage) MarshalJSON() ([]byte, error)

func (*Usage) UnmarshalJSON

func (u *Usage) UnmarshalJSON(data []byte) error

type VideoPart

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

func (VideoPart) Continuations

func (p VideoPart) Continuations() []ContinuationState

func (VideoPart) MarshalJSON

func (p VideoPart) MarshalJSON() ([]byte, error)

func (VideoPart) PartType

func (p VideoPart) PartType() string

Directories

Path Synopsis
cmd
lm15-vet command
lm15-vet — the lm15-go vet shim.
lm15-vet — the lm15-go vet shim.

Jump to

Keyboard shortcuts

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