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 LLMCreationRequest
- type LLMProviderType
- type LLMCapabilities
- type LLMSamplingParams
- type CreateLLMResponse
- type LLMResponse
- type ListLLMsResponse
- type LLMUpdateRequest
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).
HTTP — POST /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 onreq.
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
_ = llmfunc (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.
HTTP — GET /v1/llms/{id}
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.DisplayNamefunc (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.
HTTP — GET /v1/llms
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.params(*LLMsListParams, optional) — typed query parameters; passnilfor 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).
HTTP — PUT /v1/llms/{id}
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.id(string) — The unique identifier of the LLM to updatereq(*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.LLMIDfunc (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).
HTTP — DELETE /v1/llms/{id}
Parameters
ctx(context.Context) — carries the deadline and cancellation signal for the call.id(string) — The unique identifier of the LLM to delete
Returns — error — nil 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, wiredisplayName) — User-facing name of the LLMDescription(string, optional, wiredescription) — Description of the LLMProviderType(models.LLMProviderType, wireproviderType) — Type of LLM providerEndpointURL(string, wireendpointUrl) — API endpoint base URL (OpenAI-compatible base, typically ends with /v1)APIPath(string, optional, wireapiPath) — API path for chat/completions request (defaults to /chat/completions if not provided)ModelIdentifier(string, wiremodelIdentifier) — Model identifierSupportedModalities([]models.Modality, optional, wiresupportedModalities) — Supported content modalities (defaults to TEXT if not provided)Credentials(models.EndpointAuthentication, optional, wirecredentials) — 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, wirelabels) — User-defined labels for categorizationVersion(string, optional, wireversion) — Version informationMonitoringEndpoint(string, optional, wiremonitoringEndpoint) — Monitoring endpoint URLCapabilities(models.LLMCapabilities, optional, wirecapabilities) — LLM capabilities defining supported features and modes. Optional - server infers capabilities from model identifier if not provided.DefaultSamplingParams(models.LLMSamplingParams, optional, wiredefaultSamplingParams) — Default sampling parameters for generation requestsMaxContextLength(int32, optional, wiremaxContextLength) — Maximum context window size in tokensClientConfig(map[string]any, optional, wireclientConfig) — Provider-specific client configuration as flexible JSON structureOwnerID(string, optional, wireownerId) — Optional owner ID. If not provided, derived from the authentication context. Requires CREATE_LLM_ANY permission if specified.LLMID(string, optional, wirellmId) — 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, wiresupportsChat) — Supports conversational/chat completion format with message rolesSupportsCompletion(bool, optional, wiresupportsCompletion) — Supports raw text completion with prompt continuationSupportsFunctionCalling(bool, optional, wiresupportsFunctionCalling) — Supports function/tool calling with structured responsesSupportsSystemMessages(bool, optional, wiresupportsSystemMessages) — Supports system prompts to define model behavior and contextSupportsStreaming(bool, optional, wiresupportsStreaming) — Supports real-time token streaming during generationSupportsSamplingParameters(bool, optional, wiresupportsSamplingParameters) — 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, wiremaxTokens) — Maximum tokens to generate (>0 if set; provider-dependent limits apply)Temperature(float64, optional, wiretemperature) — Sampling temperature; valid range depends on the configured providerTopP(float64, optional, wiretopP) — Nucleus sampling threshold 0.0-1.0 (smaller values focus on higher probability tokens)TopK(int32, optional, wiretopK) — Top-k sampling limit (>0 if set; primarily for local/open-source models)FrequencyPenalty(float64, optional, wirefrequencyPenalty) — Frequency penalty; valid range depends on the configured providerPresencePenalty(float64, optional, wirepresencePenalty) — Presence penalty; valid range depends on the configured providerStopSequences([]string, optional, wirestopSequences) — 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, wirellm) — The created LLM configurationStatuses([]models.GoodMemStatus, optional, wirestatuses) — 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, wirellmId) — Unique identifier of the LLMDisplayName(string, wiredisplayName) — User-facing name of the LLMDescription(string, optional, wiredescription) — Description of the LLMProviderType(models.LLMProviderType, wireproviderType) — Type of LLM providerEndpointURL(string, wireendpointUrl) — API endpoint base URLAPIPath(string, optional, wireapiPath) — API path for chat/completions requestModelIdentifier(string, wiremodelIdentifier) — Model identifierSupportedModalities([]models.Modality, wiresupportedModalities) — Supported content modalitiesCredentials(models.EndpointAuthentication, optional, wirecredentials) — Structured credential payload used for upstream authenticationLabels(map[string]string, wirelabels) — User-defined labels for categorizationVersion(string, optional, wireversion) — Version informationMonitoringEndpoint(string, optional, wiremonitoringEndpoint) — Monitoring endpoint URLCapabilities(models.LLMCapabilities, wirecapabilities) — LLM capabilities defining supported features and modesDefaultSamplingParams(models.LLMSamplingParams, optional, wiredefaultSamplingParams) — Default sampling parameters for generation requestsMaxContextLength(int32, optional, wiremaxContextLength) — Maximum context window size in tokensClientConfig(map[string]any, optional, wireclientConfig) — Provider-specific client configurationOwnerID(string, wireownerId) — Owner ID of the LLMCreatedAt(int64, wirecreatedAt) — Creation timestamp (milliseconds since epoch)UpdatedAt(int64, wireupdatedAt) — Last update timestamp (milliseconds since epoch)CreatedByID(string, wirecreatedById) — ID of the user who created the LLMUpdatedByID(string, wireupdatedById) — ID of the user who last updated the LLM
type ListLLMsResponse
type ListLLMsResponse struct{ … }
Response containing a list of LLM configurations
Llms([]models.LLMResponse, wirellms) — 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, wiredisplayName) — Update display nameDescription(string, optional, wiredescription) — Update descriptionEndpointURL(string, optional, wireendpointUrl) — Update endpoint base URL (OpenAI-compatible base, typically ends with /v1)APIPath(string, optional, wireapiPath) — Update API pathModelIdentifier(string, optional, wiremodelIdentifier) — Update model identifier (cannot be empty)SupportedModalities([]models.Modality, optional, wiresupportedModalities) — 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, wirecredentials) — Update credentialsVersion(string, optional, wireversion) — Update version informationMonitoringEndpoint(string, optional, wiremonitoringEndpoint) — Update monitoring endpoint URLCapabilities(models.LLMCapabilities, optional, wirecapabilities) — Update LLM capabilities (replaces entire capability set; clients MUST send all flags)DefaultSamplingParams(models.LLMSamplingParams, optional, wiredefaultSamplingParams) — Update default sampling parametersMaxContextLength(int32, optional, wiremaxContextLength) — Update maximum context window size in tokensClientConfig(map[string]any, optional, wireclientConfig) — Update provider-specific client configuration (replaces entire config; no merging)ReplaceLabels(map[string]string, optional, wirereplaceLabels) — Replace all existing labels with this set. Empty map clears all labels. Cannot be used with mergeLabels.MergeLabels(map[string]string, optional, wiremergeLabels) — Merge with existing labels: upserts with overwrite. Labels not mentioned are preserved. Cannot be used with replaceLabels.