GoodMemGoodMem
ReferenceSdkV2Go

LLMs

package goodmem // import "fury.io/pairsys/goodmem"

LLM management — generation-time model registration.

Methods are called as client.LLMs().<Method>(ctx, ...) on a *goodmem.Client. Service: LLMsService.

Index

type LLMsService

type LLMsService struct{ … }

Access this service as client.LLMs() on a *goodmem.Client. Its methods follow.

func (s *LLMsService) Create

func (s *LLMsService) Create(ctx context.Context, req *models.LLMCreationRequest, apiKey string) (*models.CreateLLMResponse, error)

Creates a new LLM configuration for text generation services. LLMs represent connections to different language model API services (like OpenAI, vLLM, etc.) and include all the necessary configuration to use them for text generation. DUPLICATE DETECTION: Returns HTTP 409 Conflict (ALREADY_EXISTS) if another LLM exists with identical {ownerId, providerType, endpointUrl, apiPath, modelIdentifier, credentialsFingerprint} after URL canonicalization. Uniqueness is enforced per-owner. Credentials are hashed (SHA-256) for uniqueness while remaining encrypted. The apiPath field defaults to '/chat/completions' if omitted. Requires CREATE_LLM_OWN permission (or CREATE_LLM_ANY for admin users).

HTTPPOST /v1/llms

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • req (*models.LLMCreationRequest) — the request payload. The linked type documents every field and its JSON wire name.
  • apiKey (string) — bare provider API key. The convenience layer auto-fills provider / endpoint / dimensionality from the bundled model registry (keyed by the request's model identifier) and converts the key to structured credentials. Pass "" to keep any credentials already set on req.

Returns(*models.CreateLLMResponse, error)

Example

resp, err := client.LLMs().Create(ctx, &models.LLMCreationRequest{
	DisplayName:     "Doc LLM",
	ModelIdentifier: "gpt-4o-mini",
	Labels:          map[string]string{"env": "docs"},
}, "sk-...")
if err != nil {
	log.Fatal(err)
}
llm := resp.LLM
_ = llm

func (s *LLMsService) Get

func (s *LLMsService) Get(ctx context.Context, id string) (*models.LLMResponse, error)

Retrieves the details of a specific LLM configuration by its unique identifier. Requires READ_LLM_OWN permission for LLMs you own (or READ_LLM_ANY for admin users to view any user's LLMs). This is a read-only operation with no side effects.

HTTPGET /v1/llms/&#123;id&#125;

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • id (string) — The unique identifier of the LLM to retrieve

Returns(*models.LLMResponse, error)

Example

llm, err := client.LLMs().Get(ctx, "your-llm-id")
if err != nil {
	log.Fatal(err)
}
_ = llm.DisplayName

func (s *LLMsService) List

func (s *LLMsService) List(ctx context.Context, params *LLMsListParams) (*models.ListLLMsResponse, error)

Retrieves a list of LLM configurations accessible to the caller, with optional filtering. LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production). PERMISSION-BASED FILTERING: With LIST_LLM_OWN permission, you can only see your own LLMs (ownerId filter is ignored if set to another user). With LIST_LLM_ANY permission, you can see all LLMs or filter by any ownerId. This is a read-only operation with no side effects.

HTTPGET /v1/llms

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • params (*LLMsListParams, optional) — typed query parameters; pass nil for an empty filter set. The linked pkg.go.dev page lists every field.

Returns(*models.ListLLMsResponse, error)

Example

resp, err := client.LLMs().List(ctx, nil)
if err != nil {
	log.Fatal(err)
}
for _, llm := range resp.Llms {
	_ = llm.LLMID
	_ = llm.DisplayName
}

func (s *LLMsService) Update

func (s *LLMsService) Update(ctx context.Context, id string, req *models.LLMUpdateRequest) (*models.LLMResponse, error)

Updates an existing LLM configuration including display information, endpoint configuration, model parameters, credentials, and labels. All fields are optional - only specified fields will be updated. SUPPORTED_MODALITIES UPDATE: If the array contains >=1 elements, it replaces the stored set; if empty or omitted, no change occurs and it does not count as an update by itself. IMPORTANT: providerType is IMMUTABLE after creation and cannot be changed. Requires UPDATE_LLM_OWN permission for LLMs you own (or UPDATE_LLM_ANY for admin users).

HTTPPUT /v1/llms/&#123;id&#125;

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • id (string) — The unique identifier of the LLM to update
  • req (*models.LLMUpdateRequest) — the request payload. The linked type documents every field and its JSON wire name.

Returns(*models.LLMResponse, error)

Example

updated, err := client.LLMs().Update(ctx, "your-llm-id", &models.LLMUpdateRequest{
	DisplayName: goodmem.Ptr("Doc LLM (updated)"),
	MergeLabels: map[string]string{"version": "2"},
})
if err != nil {
	log.Fatal(err)
}
_ = updated.LLMID

func (s *LLMsService) Delete

func (s *LLMsService) Delete(ctx context.Context, id string) error

Permanently deletes an LLM configuration. This operation cannot be undone and removes the LLM record and securely deletes stored credentials. IMPORTANT: This does NOT invalidate or delete any previously generated content using this LLM - existing generations remain accessible. Requires DELETE_LLM_OWN permission for LLMs you own (or DELETE_LLM_ANY for admin users).

HTTPDELETE /v1/llms/&#123;id&#125;

Parameters

  • ctx (context.Context) — carries the deadline and cancellation signal for the call.
  • id (string) — The unique identifier of the LLM to delete

Returnserrornil on success.

Example

err := client.LLMs().Delete(ctx, "your-llm-id")
if err != nil {
	log.Fatal(err)
}

type LLMCreationRequest

type LLMCreationRequest struct{ … }

Request body for creating a new LLM. An LLM represents a configuration for text generation services.

  • DisplayName (string, wire displayName) — User-facing name of the LLM
  • Description (string, optional, wire description) — Description of the LLM
  • ProviderType (models.LLMProviderType, wire providerType) — Type of LLM provider
  • EndpointURL (string, wire endpointUrl) — API endpoint base URL (OpenAI-compatible base, typically ends with /v1)
  • APIPath (string, optional, wire apiPath) — API path for chat/completions request (defaults to /chat/completions if not provided)
  • ModelIdentifier (string, wire modelIdentifier) — Model identifier
  • SupportedModalities ([]models.Modality, optional, wire supportedModalities) — Supported content modalities (defaults to TEXT if not provided)
  • Credentials (models.EndpointAuthentication, optional, wire credentials) — Structured credential payload describing how to authenticate with the provider. Required for SaaS providers; optional for local or proxy providers.
  • Labels (map[string]string, optional, wire labels) — User-defined labels for categorization
  • Version (string, optional, wire version) — Version information
  • MonitoringEndpoint (string, optional, wire monitoringEndpoint) — Monitoring endpoint URL
  • Capabilities (models.LLMCapabilities, optional, wire capabilities) — LLM capabilities defining supported features and modes. Optional - server infers capabilities from model identifier if not provided.
  • DefaultSamplingParams (models.LLMSamplingParams, optional, wire defaultSamplingParams) — Default sampling parameters for generation requests
  • MaxContextLength (int32, optional, wire maxContextLength) — Maximum context window size in tokens
  • ClientConfig (map[string]any, optional, wire clientConfig) — Provider-specific client configuration as flexible JSON structure
  • OwnerID (string, optional, wire ownerId) — Optional owner ID. If not provided, derived from the authentication context. Requires CREATE_LLM_ANY permission if specified.
  • LLMID (string, optional, wire llmId) — Optional client-provided UUID for idempotent creation. If not provided, server generates a new UUID. Returns ALREADY_EXISTS if ID is already in use.

type LLMProviderType

type LLMProviderType string

LLM provider types

String enum (type LLMProviderType string): "OPENAI" · "LITELLM_PROXY" · "OPEN_ROUTER" · "VLLM" · "OLLAMA" · "LLAMA_CPP" · "CUSTOM_OPENAI_COMPATIBLE"

type LLMCapabilities

type LLMCapabilities struct{ … }

Capabilities and features supported by an LLM service

  • SupportsChat (bool, optional, wire supportsChat) — Supports conversational/chat completion format with message roles
  • SupportsCompletion (bool, optional, wire supportsCompletion) — Supports raw text completion with prompt continuation
  • SupportsFunctionCalling (bool, optional, wire supportsFunctionCalling) — Supports function/tool calling with structured responses
  • SupportsSystemMessages (bool, optional, wire supportsSystemMessages) — Supports system prompts to define model behavior and context
  • SupportsStreaming (bool, optional, wire supportsStreaming) — Supports real-time token streaming during generation
  • SupportsSamplingParameters (bool, optional, wire supportsSamplingParameters) — Supports sampling parameters like temperature, top_p, and top_k for generation control

type LLMSamplingParams

type LLMSamplingParams struct{ … }

Sampling and generation parameters for controlling LLM text output

  • MaxTokens (int32, optional, wire maxTokens) — Maximum tokens to generate (>0 if set; provider-dependent limits apply)
  • Temperature (float64, optional, wire temperature) — Sampling temperature; valid range depends on the configured provider
  • TopP (float64, optional, wire topP) — Nucleus sampling threshold 0.0-1.0 (smaller values focus on higher probability tokens)
  • TopK (int32, optional, wire topK) — Top-k sampling limit (>0 if set; primarily for local/open-source models)
  • FrequencyPenalty (float64, optional, wire frequencyPenalty) — Frequency penalty; valid range depends on the configured provider
  • PresencePenalty (float64, optional, wire presencePenalty) — Presence penalty; valid range depends on the configured provider
  • StopSequences ([]string, optional, wire stopSequences) — Generation stop sequences; generation halts on exact match

type CreateLLMResponse

type CreateLLMResponse struct{ … }

Response containing the created LLM and any informational status messages

  • LLM (models.LLMResponse, wire llm) — The created LLM configuration
  • Statuses ([]models.GoodMemStatus, optional, wire statuses) — Optional status messages providing information about server-side operations performed during creation, such as capability inference results

type LLMResponse

type LLMResponse struct{ … }

LLM configuration information

  • LLMID (string, wire llmId) — Unique identifier of the LLM
  • DisplayName (string, wire displayName) — User-facing name of the LLM
  • Description (string, optional, wire description) — Description of the LLM
  • ProviderType (models.LLMProviderType, wire providerType) — Type of LLM provider
  • EndpointURL (string, wire endpointUrl) — API endpoint base URL
  • APIPath (string, optional, wire apiPath) — API path for chat/completions request
  • ModelIdentifier (string, wire modelIdentifier) — Model identifier
  • SupportedModalities ([]models.Modality, wire supportedModalities) — Supported content modalities
  • Credentials (models.EndpointAuthentication, optional, wire credentials) — Structured credential payload used for upstream authentication
  • Labels (map[string]string, wire labels) — User-defined labels for categorization
  • Version (string, optional, wire version) — Version information
  • MonitoringEndpoint (string, optional, wire monitoringEndpoint) — Monitoring endpoint URL
  • Capabilities (models.LLMCapabilities, wire capabilities) — LLM capabilities defining supported features and modes
  • DefaultSamplingParams (models.LLMSamplingParams, optional, wire defaultSamplingParams) — Default sampling parameters for generation requests
  • MaxContextLength (int32, optional, wire maxContextLength) — Maximum context window size in tokens
  • ClientConfig (map[string]any, optional, wire clientConfig) — Provider-specific client configuration
  • OwnerID (string, wire ownerId) — Owner ID of the LLM
  • CreatedAt (int64, wire createdAt) — Creation timestamp (milliseconds since epoch)
  • UpdatedAt (int64, wire updatedAt) — Last update timestamp (milliseconds since epoch)
  • CreatedByID (string, wire createdById) — ID of the user who created the LLM
  • UpdatedByID (string, wire updatedById) — ID of the user who last updated the LLM

type ListLLMsResponse

type ListLLMsResponse struct{ … }

Response containing a list of LLM configurations

  • Llms ([]models.LLMResponse, wire llms) — List of LLM configurations matching the request filters

type LLMUpdateRequest

type LLMUpdateRequest struct{ … }

Request body for updating an existing LLM. All fields are optional - only specified fields will be updated. supportedModalities replaces the stored set only when the array contains at least one value; empty or omitted leaves it unchanged and does not count as an update by itself.

  • DisplayName (string, optional, wire displayName) — Update display name
  • Description (string, optional, wire description) — Update description
  • EndpointURL (string, optional, wire endpointUrl) — Update endpoint base URL (OpenAI-compatible base, typically ends with /v1)
  • APIPath (string, optional, wire apiPath) — Update API path
  • ModelIdentifier (string, optional, wire modelIdentifier) — Update model identifier (cannot be empty)
  • SupportedModalities ([]models.Modality, optional, wire supportedModalities) — Update supported modalities (if array contains >=1 elements, replaces stored set; if empty or omitted, no change and does not count as an update by itself)
  • Credentials (models.EndpointAuthentication, optional, wire credentials) — Update credentials
  • Version (string, optional, wire version) — Update version information
  • MonitoringEndpoint (string, optional, wire monitoringEndpoint) — Update monitoring endpoint URL
  • Capabilities (models.LLMCapabilities, optional, wire capabilities) — Update LLM capabilities (replaces entire capability set; clients MUST send all flags)
  • DefaultSamplingParams (models.LLMSamplingParams, optional, wire defaultSamplingParams) — Update default sampling parameters
  • MaxContextLength (int32, optional, wire maxContextLength) — Update maximum context window size in tokens
  • ClientConfig (map[string]any, optional, wire clientConfig) — Update provider-specific client configuration (replaces entire config; no merging)
  • ReplaceLabels (map[string]string, optional, wire replaceLabels) — Replace all existing labels with this set. Empty map clears all labels. Cannot be used with mergeLabels.
  • MergeLabels (map[string]string, optional, wire mergeLabels) — Merge with existing labels: upserts with overwrite. Labels not mentioned are preserved. Cannot be used with replaceLabels.