GoodMemGoodMem
ReferenceSdkV2.NET

LLMs

LLM management — generation-time model registration.

Namespace: Goodmem.Client.Api · Class: LlmsApi

Reach this surface as client.Llms on a GoodmemClient. Every network method is asynchronous — it returns a Task<T> (or an IAsyncEnumerable<T> for pagination and streaming) and accepts a CancellationToken; the Async suffix marks the standard .NET Task-based async pattern.

Methods

MethodSummary
CreateAsyncCreate a new LLM.
GetAsyncGet an LLM by ID.
ListAsyncList LLMs.
UpdateAsyncUpdate an LLM.
DeleteAsyncDelete an LLM.

CreateAsync

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).

Declaration

public Task<CreateLlmResponse> CreateAsync(LlmCreationRequest request, string? apiKey = null, CancellationToken ct = default)

HTTPPOST /v1/llms

Parameters

TypeNameDescription
LlmCreationRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
stringapiKeyBare provider API key. The convenience layer auto-fills provider / endpoint / dimensionality from the bundled model registry and converts the key to structured credentials. Pass null to keep any credentials already set on request. (optional)
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<CreateLlmResponse> — an awaitable that resolves to CreateLlmResponse.

Exceptions

TypeCondition
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var resp = await client.Llms.CreateAsync(
    new LlmCreationRequest
    {
        DisplayName = "Doc LLM",
        ModelIdentifier = "gpt-4o-mini",
        Labels = new Dictionary<string, string> { ["env"] = "docs" },
    },
    "sk-..."
);
var llm = resp.Llm;
Console.WriteLine(llm.LlmId);


GetAsync

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.

Declaration

public Task<LlmResponse> GetAsync(string id, CancellationToken ct = default)

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

Parameters

TypeNameDescription
stringidThe unique identifier of the LLM to retrieve
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<LlmResponse> — an awaitable that resolves to LlmResponse.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var llm = await client.Llms.GetAsync("your-llm-id");
Console.WriteLine(llm.DisplayName);


ListAsync

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.

Declaration

public Task<ListLlmsResponse> ListAsync(LlmsListOptions? options = null, CancellationToken ct = default)

HTTPGET /v1/llms

Parameters

TypeNameDescription
LlmsListOptionsoptionsOptions bag carrying the lookup key(s) / convenience knobs; the linked type lists them all. (optional)
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<ListLlmsResponse> — an awaitable that resolves to ListLlmsResponse.

Exceptions

TypeCondition
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var resp = await client.Llms.ListAsync();
foreach (var llm in resp.Llms)
    Console.WriteLine($"{llm.LlmId} {llm.DisplayName}");


UpdateAsync

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).

Declaration

public Task<LlmResponse> UpdateAsync(string id, LlmUpdateRequest request, CancellationToken ct = default)

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

Parameters

TypeNameDescription
stringidThe unique identifier of the LLM to update
LlmUpdateRequestrequestThe request payload; the linked model lists every field and its JSON wire name.
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task<LlmResponse> — an awaitable that resolves to LlmResponse.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
ArgumentNullExceptionrequest is null.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

var updated = await client.Llms.UpdateAsync(
    "your-llm-id",
    new LlmUpdateRequest
    {
        DisplayName = "Doc LLM (updated)",
        MergeLabels = new Dictionary<string, string> { ["version"] = "2" },
    }
);
Console.WriteLine(updated.LlmId);


DeleteAsync

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).

Declaration

public Task DeleteAsync(string id, CancellationToken ct = default)

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

Parameters

TypeNameDescription
stringidThe unique identifier of the LLM to delete
CancellationTokenctCancellation / deadline signal for the call. (optional)

Returns

Task — completes when the operation finishes; there is no response body.

Exceptions

TypeCondition
ArgumentExceptionid is null or empty.
NetworkExceptionThe request could not reach the server (DNS, connection, or TLS failure).
ApiExceptionThe server returned a non-success (non-2xx) status. A status-specific subtype is thrown where it applies — e.g. NotFoundException (404), PermissionDeniedException (403), ConflictException (409).

Example

await client.Llms.DeleteAsync("your-llm-id");


Data Models

Types in the Goodmem.Client.Models namespace. Each row lists the C# property, its type, the JSON wire name, and a description.

LLMCreationRequest

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

PropertyTypeJSON (wire)Description
DisplayNamestringdisplayNameUser-facing name of the LLM
DescriptionstringdescriptionDescription of the LLM (optional)
ProviderTypeLlmProviderTypeproviderTypeType of LLM provider
EndpointUrlstringendpointUrlAPI endpoint base URL (OpenAI-compatible base, typically ends with /v1)
ApiPathstringapiPathAPI path for chat/completions request (defaults to /chat/completions if not provided) (optional)
ModelIdentifierstringmodelIdentifierModel identifier
SupportedModalitiesIReadOnlyList<Modality>supportedModalitiesSupported content modalities (defaults to TEXT if not provided) (optional)
CredentialsEndpointAuthenticationcredentialsStructured credential payload describing how to authenticate with the provider. Required for SaaS providers; optional for local or proxy providers. (optional)
LabelsIReadOnlyDictionary<string, string>labelsUser-defined labels for categorization (optional)
VersionstringversionVersion information (optional)
MonitoringEndpointstringmonitoringEndpointMonitoring endpoint URL (optional)
CapabilitiesLlmCapabilitiescapabilitiesLLM capabilities defining supported features and modes. Optional - server infers capabilities from model identifier if not provided. (optional)
DefaultSamplingParamsLlmSamplingParamsdefaultSamplingParamsDefault sampling parameters for generation requests (optional)
MaxContextLengthintmaxContextLengthMaximum context window size in tokens (optional)
ClientConfigIReadOnlyDictionary<string, object>clientConfigProvider-specific client configuration as flexible JSON structure (optional)
OwnerIdstringownerIdOptional owner ID. If not provided, derived from the authentication context. Requires CREATE_LLM_ANY permission if specified. (optional)
LlmIdstringllmIdOptional client-provided UUID for idempotent creation. If not provided, server generates a new UUID. Returns ALREADY_EXISTS if ID is already in use. (optional)

LLMProviderType

LLM provider types

String enum: "OPENAI" · "LITELLM_PROXY" · "OPEN_ROUTER" · "VLLM" · "OLLAMA" · "LLAMA_CPP" · "CUSTOM_OPENAI_COMPATIBLE"

LLMCapabilities

Capabilities and features supported by an LLM service

PropertyTypeJSON (wire)Description
SupportsChatboolsupportsChatSupports conversational/chat completion format with message roles (optional)
SupportsCompletionboolsupportsCompletionSupports raw text completion with prompt continuation (optional)
SupportsFunctionCallingboolsupportsFunctionCallingSupports function/tool calling with structured responses (optional)
SupportsSystemMessagesboolsupportsSystemMessagesSupports system prompts to define model behavior and context (optional)
SupportsStreamingboolsupportsStreamingSupports real-time token streaming during generation (optional)
SupportsSamplingParametersboolsupportsSamplingParametersSupports sampling parameters like temperature, top_p, and top_k for generation control (optional)

LLMSamplingParams

Sampling and generation parameters for controlling LLM text output

PropertyTypeJSON (wire)Description
MaxTokensintmaxTokensMaximum tokens to generate (>0 if set; provider-dependent limits apply) (optional)
TemperaturedoubletemperatureSampling temperature; valid range depends on the configured provider (optional)
TopPdoubletopPNucleus sampling threshold 0.0-1.0 (smaller values focus on higher probability tokens) (optional)
TopKinttopKTop-k sampling limit (>0 if set; primarily for local/open-source models) (optional)
FrequencyPenaltydoublefrequencyPenaltyFrequency penalty; valid range depends on the configured provider (optional)
PresencePenaltydoublepresencePenaltyPresence penalty; valid range depends on the configured provider (optional)
StopSequencesIReadOnlyList<string>stopSequencesGeneration stop sequences; generation halts on exact match (optional)

CreateLLMResponse

Response containing the created LLM and any informational status messages

PropertyTypeJSON (wire)Description
LlmLlmResponsellmThe created LLM configuration
StatusesIReadOnlyList<GoodMemStatus>statusesOptional status messages providing information about server-side operations performed during creation, such as capability inference results (optional)

LLMResponse

LLM configuration information

PropertyTypeJSON (wire)Description
LlmIdstringllmIdUnique identifier of the LLM
DisplayNamestringdisplayNameUser-facing name of the LLM
DescriptionstringdescriptionDescription of the LLM (optional)
ProviderTypeLlmProviderTypeproviderTypeType of LLM provider
EndpointUrlstringendpointUrlAPI endpoint base URL
ApiPathstringapiPathAPI path for chat/completions request (optional)
ModelIdentifierstringmodelIdentifierModel identifier
SupportedModalitiesIReadOnlyList<Modality>supportedModalitiesSupported content modalities
CredentialsEndpointAuthenticationcredentialsStructured credential payload used for upstream authentication (optional)
LabelsIReadOnlyDictionary<string, string>labelsUser-defined labels for categorization
VersionstringversionVersion information (optional)
MonitoringEndpointstringmonitoringEndpointMonitoring endpoint URL (optional)
CapabilitiesLlmCapabilitiescapabilitiesLLM capabilities defining supported features and modes
DefaultSamplingParamsLlmSamplingParamsdefaultSamplingParamsDefault sampling parameters for generation requests (optional)
MaxContextLengthintmaxContextLengthMaximum context window size in tokens (optional)
ClientConfigIReadOnlyDictionary<string, object>clientConfigProvider-specific client configuration (optional)
OwnerIdstringownerIdOwner ID of the LLM
CreatedAtDateTimeOffsetcreatedAtCreation timestamp (milliseconds since epoch)
UpdatedAtDateTimeOffsetupdatedAtLast update timestamp (milliseconds since epoch)
CreatedByIdstringcreatedByIdID of the user who created the LLM
UpdatedByIdstringupdatedByIdID of the user who last updated the LLM

ListLLMsResponse

Response containing a list of LLM configurations

PropertyTypeJSON (wire)Description
LlmsIReadOnlyList<LlmResponse>llmsList of LLM configurations matching the request filters

LLMUpdateRequest

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.

PropertyTypeJSON (wire)Description
DisplayNamestringdisplayNameUpdate display name (optional)
DescriptionstringdescriptionUpdate description (optional)
EndpointUrlstringendpointUrlUpdate endpoint base URL (OpenAI-compatible base, typically ends with /v1) (optional)
ApiPathstringapiPathUpdate API path (optional)
ModelIdentifierstringmodelIdentifierUpdate model identifier (cannot be empty) (optional)
SupportedModalitiesIReadOnlyList<Modality>supportedModalitiesUpdate 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) (optional)
CredentialsEndpointAuthenticationcredentialsUpdate credentials (optional)
VersionstringversionUpdate version information (optional)
MonitoringEndpointstringmonitoringEndpointUpdate monitoring endpoint URL (optional)
CapabilitiesLlmCapabilitiescapabilitiesUpdate LLM capabilities (replaces entire capability set; clients MUST send all flags) (optional)
DefaultSamplingParamsLlmSamplingParamsdefaultSamplingParamsUpdate default sampling parameters (optional)
MaxContextLengthintmaxContextLengthUpdate maximum context window size in tokens (optional)
ClientConfigIReadOnlyDictionary<string, object>clientConfigUpdate provider-specific client configuration (replaces entire config; no merging) (optional)
ReplaceLabelsIReadOnlyDictionary<string, string>replaceLabelsReplace all existing labels with this set. Empty map clears all labels. Cannot be used with mergeLabels. (optional)
MergeLabelsIReadOnlyDictionary<string, string>mergeLabelsMerge with existing labels: upserts with overwrite. Labels not mentioned are preserved. Cannot be used with replaceLabels. (optional)