Help us shape the future of Go! Take the 2026 Go Developer Survey

goodmem

package module
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

README

GoodMem Go SDK

Official Go SDK for GoodMem: persistent memory and hybrid retrieval for AI agents.

Install

Requires Go 1.23 or later:

go get github.com/PAIR-Systems-Inc/goodmem-go@v0.1.13
import (
    goodmem "github.com/PAIR-Systems-Inc/goodmem-go"
    "github.com/PAIR-Systems-Inc/goodmem-go/models"
)

The module uses Go's normal module resolution; no Gemfury proxy configuration is needed for this import path. Existing Gemfury users must update both their module requirement and imports when moving to this module.

Quickstart

package main

import (
    "context"
    "log"
    "os"

    goodmem "github.com/PAIR-Systems-Inc/goodmem-go"
)

func main() {
    client, err := goodmem.New(os.Getenv("GOODMEM_BASE_URL"), os.Getenv("GOODMEM_API_KEY"))
    if err != nil {
        log.Fatal(err)
    }
    page, err := client.Spaces().List(context.Background(), nil)
    if err != nil {
        log.Fatal(err)
    }
    for space, err := range page.All(context.Background()) {
        if err != nil {
            log.Fatal(err)
        }
        log.Println(space.SpaceID, space.Name)
    }
}

The SDK supports context cancellation, typed models and errors, automatic pagination, NDJSON streaming, file uploads, and model-registry conveniences. A running GoodMem server and an API key are required to use it.

Development and validation

go build ./...
go vet ./...
go test ./...

Unit tests use local HTTP test servers. The documentation integration suite skips unless GOODMEM_BASE_URL and GOODMEM_API_KEY are set; some integration examples also require model-provider credentials. CI runs build, vet, and unit tests without those credentials.

Source changes and regeneration are maintained in GoodMem's development repository. Generated files should not be edited here. Please report SDK issues in this repository.

Publication status and provenance

Releases are exported and tested by GoodMem's release pipeline, then pushed here with immutable version tags. No private repository history is imported. provenance.json identifies the source commit and module path. New releases are published here only. Existing Gemfury users must change both their module requirement and imports to use this GitHub module.

License

Apache License 2.0, consistent with GoodMem's published SDK licensing policy. The separately deployed GoodMem server has its own license.

Documentation

Overview

Package goodmem is the Go SDK for the GoodMem memory API.

It is generated from the same universal API IR (api_ir.json) that drives the Python, Java and MCP SDKs, so the wire contract is identical across every language. Generated wire types live in the models subpackage; the user-facing client surface (services, pagination, streaming, convenience transforms) is layered on top in later generation phases.

Code in this module is produced by clients/_clients_gen/go — do not edit generated files by hand. Regenerate with: ./clients/clients_gen.sh

Deliberate Go-idiomatic divergences from the Python/Java SDKs (see clients/notes/new_language.md for the cross-language symmetry checklist):

  • Synchronous only. Every method takes a context.Context; cancellation and deadlines come from the context rather than a parallel async surface (checklist item 15). There is no AsyncClient.
  • String resource IDs. IDs stay plain strings rather than typed handles (SpaceID, MemoryID, …); Go callers conventionally pass string ids and the compiler-safety win doesn't justify the surface weight (checklist item 5).
  • Unknown response enums are tolerated for free. Enums are typed string constants, so an unrecognized server value deserializes without error (inv-unknown-server-enum-coerces-not-crash) — no coercion layer needed.
  • Numeric range guards are request-side only. They run in a model's Validate() (called before a request is sent) but not on response deserialization, so a zero-valued server response is never rejected (inv-numeric-range-from-ir).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to v. Optional request fields are modeled as *T so an unset field (nil) is distinguishable from a zero value, which otherwise forces callers to introduce a temporary just to take its address. Ptr removes that boilerplate at the call site:

req := &models.EmbedderCreationRequest{
    DisplayName:     "OpenAI Small",
    ModelIdentifier: "text-embedding-3-small",
    MaxSequenceLen:  goodmem.Ptr(int32(512)),
}

The type parameter is inferred from the argument, so a numeric literal keeps its default type — write goodmem.Ptr(int32(5)) when the field is *int32.

Types

type APIError

type APIError struct {
	StatusCode int
	Body       string
	Message    string
}

APIError is the base for any HTTP 4xx/5xx returned by the server. Its Message embeds the server's response body (truncated to 500 chars) so logging the error shows why the call failed instead of a bare status code (inv-http-error-body). The full payload is on Body; branch on StatusCode.

Typed subclasses cover the common statuses; a status without a typed subclass surfaces as a plain *APIError. Every subclass exposes the base via errors.As(err, &apiErr) where apiErr is *APIError.

func (*APIError) Error

func (e *APIError) Error() string

type APIKeysListParams

type APIKeysListParams struct {
	// SubjectPrincipalID Filter by exact subject-principal UUID
	SubjectPrincipalID *string `json:"-"`
	// OwnerPrincipalID Filter by exact administrative-owner UUID
	OwnerPrincipalID *string `json:"-"`
	// LifecycleState Filter by precise lifecycle state
	LifecycleState *string `json:"-"`
	// View Metadata projection; omission defaults to FULL
	View *string `json:"-"`
	// MaxResults Page size; FULL defaults to 10 and permits at most 20, while BASIC defaults to 50 and permits at most 1,000
	MaxResults *int32 `json:"-"`
	// NextToken Opaque continuation token returned by the preceding page
	NextToken *string `json:"-"`
}

APIKeysListParams holds the optional query parameters for APIKeysService.List.

type APIKeysService

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

APIKeysService groups the apikeys namespace methods.

func (*APIKeysService) Create

Create Create a new API key

func (*APIKeysService) Delete

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

Delete Delete an API key

func (*APIKeysService) Get

Get Get an API key

func (*APIKeysService) List

List List API keys

func (*APIKeysService) Update

Update Update an API key

type AccessPolicyGrantsGetParams

type AccessPolicyGrantsGetParams struct {
	// IncludeRevoked Include a revoked historical row
	IncludeRevoked *bool `json:"-"`
}

AccessPolicyGrantsGetParams holds the optional query parameters for AccessPolicyService.GrantsGet.

type AccessPolicyGrantsListParams

type AccessPolicyGrantsListParams struct {
	// ResourceKind Required target resource kind
	ResourceKind *string `json:"-"`
	// ResourceID Required target UUID except when resourceKind is INSTANCE
	ResourceID *string `json:"-"`
	// IncludeRevoked Include revoked history
	IncludeRevoked *bool `json:"-"`
	// MaxResults Page size; 0 or omission uses the default of 50, maximum 1,000
	MaxResults *int32 `json:"-"`
	// NextToken Opaque continuation token
	NextToken *string `json:"-"`
}

AccessPolicyGrantsListParams holds the optional query parameters for AccessPolicyService.GrantsList.

type AccessPolicyRoleAssignmentsGetParams

type AccessPolicyRoleAssignmentsGetParams struct {
	// IncludeRevoked Include a revoked historical row
	IncludeRevoked *bool `json:"-"`
}

AccessPolicyRoleAssignmentsGetParams holds the optional query parameters for AccessPolicyService.RoleAssignmentsGet.

type AccessPolicyRoleAssignmentsListParams

type AccessPolicyRoleAssignmentsListParams struct {
	// ResourceKind Required INSTANCE or SPACE kind
	ResourceKind *string `json:"-"`
	// ResourceID Required space UUID; omitted for INSTANCE
	ResourceID *string `json:"-"`
	// IncludeRevoked Include revoked history
	IncludeRevoked *bool `json:"-"`
	// MaxResults Page size; 0 or omission uses the default of 50, maximum 1,000
	MaxResults *int32 `json:"-"`
	// NextToken Opaque continuation token
	NextToken *string `json:"-"`
}

AccessPolicyRoleAssignmentsListParams holds the optional query parameters for AccessPolicyService.RoleAssignmentsList.

type AccessPolicyService

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

AccessPolicyService groups the access_policy namespace methods.

func (*AccessPolicyService) Check

Check Check effective authorization

func (*AccessPolicyService) GrantsCreate

GrantsCreate Create an authorization grant

func (*AccessPolicyService) GrantsDelete

GrantsDelete Revoke an authorization grant

func (*AccessPolicyService) GrantsGet

GrantsGet Get an authorization grant

func (*AccessPolicyService) GrantsList

GrantsList List authorization grants

func (*AccessPolicyService) RoleAssignmentsCreate

func (s *AccessPolicyService) RoleAssignmentsCreate(ctx context.Context, req *models.AssignRoleRequest) (*models.RoleAssignment, error)

RoleAssignmentsCreate Assign a scoped role

func (*AccessPolicyService) RoleAssignmentsDelete

func (s *AccessPolicyService) RoleAssignmentsDelete(ctx context.Context, id string) (*models.RoleAssignment, error)

RoleAssignmentsDelete Revoke a scoped role assignment

func (*AccessPolicyService) RoleAssignmentsGet

RoleAssignmentsGet Get a scoped role assignment

func (*AccessPolicyService) RoleAssignmentsList

RoleAssignmentsList List scoped role assignments

type AdminRetrieveMemoryLogPoliciesGetParams

type AdminRetrieveMemoryLogPoliciesGetParams struct {
	// IncludeDeleted Whether to include tombstoned policies. Also accepts include_deleted.
	IncludeDeleted *bool `json:"-"`
}

AdminRetrieveMemoryLogPoliciesGetParams holds the optional query parameters for AdminService.RetrieveMemoryLogPoliciesGet.

type AdminRetrieveMemoryLogPoliciesListParams

type AdminRetrieveMemoryLogPoliciesListParams struct {
	// IncludeDeleted Whether to include tombstoned policies. Also accepts include_deleted.
	IncludeDeleted *bool `json:"-"`
	// NameFilter Case-insensitive substring filter on policy display names. Also accepts name_filter.
	NameFilter *string `json:"-"`
	// ActiveAt Only return policies active at this millisecond epoch timestamp. Also accepts active_at.
	ActiveAt *int64 `json:"-"`
	// MaxResults Maximum number of policies to return. Also accepts max_results.
	MaxResults *int32 `json:"-"`
	// NextToken Opaque pagination token returned by the previous list response. Also accepts next_token.
	NextToken *string `json:"-"`
	// SortBy Sort field: created_at, updated_at, or display_name. Also accepts sort_by.
	SortBy *string `json:"-"`
	// SortOrder Sort order. Also accepts sort_order.
	SortOrder *models.SortOrder `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

AdminRetrieveMemoryLogPoliciesListParams holds the optional query parameters for AdminService.RetrieveMemoryLogPoliciesList.

type AdminService

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

AdminService groups the admin namespace methods.

func (*AdminService) BackgroundJobsPurge

BackgroundJobsPurge Purge completed background jobs

func (*AdminService) Drain

Drain Request the server to enter drain mode

func (*AdminService) LicenseReload

LicenseReload Reload the active license from disk

func (*AdminService) RetrieveMemoryLogPoliciesCreate

RetrieveMemoryLogPoliciesCreate Create a RetrieveMemory log policy

func (*AdminService) RetrieveMemoryLogPoliciesDelete

RetrieveMemoryLogPoliciesDelete Delete a RetrieveMemory log policy

func (*AdminService) RetrieveMemoryLogPoliciesGet

func (s *AdminService) RetrieveMemoryLogPoliciesGet(ctx context.Context, id string, params *AdminRetrieveMemoryLogPoliciesGetParams) (*models.RetrieveMemoryLogPolicy, error)

RetrieveMemoryLogPoliciesGet Get a RetrieveMemory log policy

func (*AdminService) RetrieveMemoryLogPoliciesList

RetrieveMemoryLogPoliciesList List RetrieveMemory log policies

func (*AdminService) TransferInstanceOwnership

TransferInstanceOwnership Transfer GoodMem instance ownership

type AuthenticationError

type AuthenticationError struct{ *APIError }

AuthenticationError is HTTP 401.

func (*AuthenticationError) Unwrap

func (e *AuthenticationError) Unwrap() error

type BadRequestError

type BadRequestError struct{ *APIError }

BadRequestError is HTTP 400.

func (*BadRequestError) Unwrap

func (e *BadRequestError) Unwrap() error

type Client

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

Client is a synchronous client for the GoodMem REST API. Construct it with New, then reach each namespace through its accessor — c.Spaces().Create(...), c.Memories().Get(...), and so on. Methods take a context.Context (cancel or set a deadline on it to bound a call) and return a typed response plus an error; non-2xx responses come back as *APIError subclasses and transport failures as *NetworkError.

A Client is safe for concurrent use by multiple goroutines.

func New

func New(baseURL, apiKey string, opts ...Option) (*Client, error)

New returns a Client for the given base URL and API key. The base URL may carry a mount path prefix (e.g. https://host/api) — it is preserved on every request. An empty base URL is rejected here because there is no host to send to; an empty apiKey is allowed (the unauthenticated bootstrap endpoints /v1/system/info and /v1/system/init are callable without a key, and every other endpoint returns 401 from the server) — so the server, not the SDK, owns the "missing key" error (inv-empty-string-required-args).

func (*Client) APIKeys

func (c *Client) APIKeys() *APIKeysService

APIKeys returns the apikeys namespace.

func (*Client) AccessPolicy

func (c *Client) AccessPolicy() *AccessPolicyService

AccessPolicy returns the access_policy namespace.

func (*Client) Admin

func (c *Client) Admin() *AdminService

Admin returns the admin namespace.

func (*Client) DecisionModels added in v0.1.12

func (c *Client) DecisionModels() *DecisionModelsService

DecisionModels returns the decision_models namespace.

func (*Client) Embedders

func (c *Client) Embedders() *EmbeddersService

Embedders returns the embedders namespace.

func (*Client) Instance

func (c *Client) Instance() *InstanceService

Instance returns the instance namespace.

func (*Client) LLMs

func (c *Client) LLMs() *LLMsService

LLMs returns the llms namespace.

func (*Client) Memories

func (c *Client) Memories() *MemoriesService

Memories returns the memories namespace.

func (*Client) OCR

func (c *Client) OCR() *OCRService

OCR returns the ocr namespace.

func (*Client) Ping

func (c *Client) Ping() *PingService

Ping returns the ping namespace.

func (*Client) Rerankers

func (c *Client) Rerankers() *RerankersService

Rerankers returns the rerankers namespace.

func (*Client) ServiceIdentities

func (c *Client) ServiceIdentities() *ServiceIdentitiesService

ServiceIdentities returns the service_identities namespace.

func (*Client) Spaces

func (c *Client) Spaces() *SpacesService

Spaces returns the spaces namespace.

func (*Client) System

func (c *Client) System() *SystemService

System returns the system namespace.

func (*Client) UserEnrollments

func (c *Client) UserEnrollments() *UserEnrollmentsService

UserEnrollments returns the user_enrollments namespace.

func (*Client) Users

func (c *Client) Users() *UsersService

Users returns the users namespace.

type ConflictError

type ConflictError struct{ *APIError }

ConflictError is HTTP 409.

func (*ConflictError) Unwrap

func (e *ConflictError) Unwrap() error

type DecisionModelsGetParams added in v0.1.12

type DecisionModelsGetParams struct {
	// IncludeCredentials Include stored credentials. Requires READ_DECISION_MODEL_CREDENTIALS in addition to READ_DECISION_MODEL.
	IncludeCredentials *bool `json:"-"`
}

DecisionModelsGetParams holds the optional query parameters for DecisionModelsService.Get.

type DecisionModelsListParams added in v0.1.12

type DecisionModelsListParams struct {
	// OwnerID Return only decision models owned by this principal UUID.
	OwnerID *string `json:"-"`
	// ProviderType Return only decision models that use this provider.
	ProviderType *models.DecisionModelProviderType `json:"-"`
	// PageSize Maximum number of models to return, from 1 to 1000. Omit this parameter or use 0 for 50.
	PageSize *int32 `json:"-"`
	// PageToken Use nextPageToken from the previous response to request the next page. Keep the filters and pageSize unchanged.
	PageToken *string `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

DecisionModelsListParams holds the optional query parameters for DecisionModelsService.List.

type DecisionModelsService added in v0.1.12

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

DecisionModelsService groups the decision_models namespace methods.

func (*DecisionModelsService) Create added in v0.1.12

Create Create a decision model

func (*DecisionModelsService) Decide added in v0.1.12

Decide Request decisions from a model

func (*DecisionModelsService) Delete added in v0.1.12

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

Delete Delete a decision model

func (*DecisionModelsService) Get added in v0.1.12

Get Get a decision model

func (*DecisionModelsService) List added in v0.1.12

List List decision models

func (*DecisionModelsService) Update added in v0.1.12

Update Update a decision model

type EmbeddersGetParams

type EmbeddersGetParams struct {
	// IncludeCredentials Whether to return stored credentials. Also accepts include_credentials. Requires READ_EMBEDDER_CREDENTIALS in addition to READ_EMBEDDER.
	IncludeCredentials *bool `json:"-"`
}

EmbeddersGetParams holds the optional query parameters for EmbeddersService.Get.

type EmbeddersListParams

type EmbeddersListParams struct {
	// OwnerID Filter the already-authorized result set by owner principal UUID. Omitting this parameter does not bypass per-embedder READ_EMBEDDER filtering.
	OwnerID *string `json:"-"`
	// ProviderType Filter embedders by provider type. Allowed values match the ProviderType schema.
	ProviderType *models.ProviderType `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

EmbeddersListParams holds the optional query parameters for EmbeddersService.List.

type EmbeddersService

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

EmbeddersService groups the embedders namespace methods.

func (*EmbeddersService) Create

Create Create a new embedder

func (*EmbeddersService) Delete

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

Delete Delete an embedder

func (*EmbeddersService) Get

Get Get an embedder by ID

func (*EmbeddersService) List

List List embedders

func (*EmbeddersService) Update

Update Update an embedder

type Error

type Error interface {
	error
	// contains filtered or unexported methods
}

Error is the supertype of every error this SDK returns. Catch any SDK-originated failure with errors.As(err, &goodmemErr) where goodmemErr is a goodmem.Error — it matches HTTP status errors (*APIError and its typed kin), transport failures (*NetworkError), and SDK-internal failures (*GoodmemError) without enumerating concrete types.

Plain caller-fault argument validation (empty path id, nil request) is returned as a standard error (fmt.Errorf), NOT as a goodmem.Error — mirroring the cross-language rule (inv-exception-types-mapping) that caller-input validation stays a language-standard error rather than collapsing into the SDK-error catch bucket.

type GoodmemError

type GoodmemError struct {
	Message string
	Cause   error
}

GoodmemError is a generic SDK-internal failure that is neither an HTTP status error nor a transport failure — most commonly an unparseable response body. Go analogue of Java's GoodmemException base.

func (*GoodmemError) Error

func (e *GoodmemError) Error() string

func (*GoodmemError) Unwrap

func (e *GoodmemError) Unwrap() error

type InstanceService

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

InstanceService groups the instance namespace methods.

func (*InstanceService) Get

Get Get the GoodMem instance

type InternalServerError

type InternalServerError struct{ *APIError }

InternalServerError is HTTP 5xx.

func (*InternalServerError) Unwrap

func (e *InternalServerError) Unwrap() error

type LLMsGetParams

type LLMsGetParams struct {
	// IncludeCredentials Whether to return stored credentials. Also accepts include_credentials. Requires READ_LLM_CREDENTIALS in addition to READ_LLM.
	IncludeCredentials *bool `json:"-"`
}

LLMsGetParams holds the optional query parameters for LLMsService.Get.

type LLMsListParams

type LLMsListParams struct {
	// OwnerID Filter the already-authorized result set by owner principal UUID. Omitting this parameter does not bypass per-LLM READ_LLM filtering.
	OwnerID *string `json:"-"`
	// ProviderType Filter LLMs by provider type. Allowed values match the LLMProviderType schema.
	ProviderType *models.LLMProviderType `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

LLMsListParams holds the optional query parameters for LLMsService.List.

type LLMsService

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

LLMsService groups the llms namespace methods.

func (*LLMsService) Create

Create Create a new LLM

func (*LLMsService) Delete

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

Delete Delete an LLM

func (*LLMsService) Get

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

Get Get an LLM by ID

func (*LLMsService) List

List List LLMs

func (*LLMsService) Update

Update Update an LLM

type MemoriesGetParams

type MemoriesGetParams struct {
	// IncludeContent Whether to include the original content in the response (defaults to false).
	IncludeContent *bool `json:"-"`
	// IncludeProcessingHistory Whether to include background job processing history in the response (defaults to false).
	IncludeProcessingHistory *bool `json:"-"`
}

MemoriesGetParams holds the optional query parameters for MemoriesService.Get.

type MemoriesListParams

type MemoriesListParams struct {
	// IncludeContent Whether to include the original content in the response (defaults to false).
	IncludeContent *bool `json:"-"`
	// IncludeProcessingHistory Whether to include background job processing history in the response (defaults to false).
	IncludeProcessingHistory *bool `json:"-"`
	// StatusFilter Filter memories by processing status (PENDING, PROCESSING, COMPLETED, FAILED).
	StatusFilter *string `json:"-"`
	// Filter Optional metadata filter expression for list results
	Filter *string `json:"-"`
	// MaxResults Maximum number of results per page (defaults to 50, clamped to [1, 500]).
	MaxResults *int32 `json:"-"`
	// NextToken Opaque pagination token for the next page. URL-safe Base64 without padding; do not parse or construct it.
	NextToken *string `json:"-"`
	// SortBy Field to sort by (e.g., 'created_at').
	SortBy *string `json:"-"`
	// SortOrder Sort direction (ASCENDING or DESCENDING).
	SortOrder *models.SortOrder `json:"-"`
}

MemoriesListParams holds the optional query parameters for MemoriesService.List.

type MemoriesPagesImageParams

type MemoriesPagesImageParams struct {
	// Dpi Optional rendition filter. If omitted, the unique page-image rendition for the page is returned; if multiple renditions exist, specify dpi and/or contentType.
	Dpi *int32 `json:"-"`
	// ContentType Optional rendition filter. MIME type of the desired page image, such as image/png.
	ContentType *string `json:"-"`
}

MemoriesPagesImageParams holds the optional query parameters for MemoriesService.PagesImage.

type MemoriesPagesParams

type MemoriesPagesParams struct {
	// StartPageIndex Optional lower bound for returned page indices, inclusive.
	StartPageIndex *int32 `json:"-"`
	// EndPageIndex Optional upper bound for returned page indices, inclusive.
	EndPageIndex *int32 `json:"-"`
	// Dpi Optional rendition filter for page-image DPI.
	Dpi *int32 `json:"-"`
	// ContentType Optional rendition filter for page-image MIME type, such as image/png.
	ContentType *string `json:"-"`
	// MaxResults Maximum number of results per page.
	MaxResults *int32 `json:"-"`
	// NextToken Opaque pagination token for the next page. Do not parse or construct it.
	NextToken *string `json:"-"`
}

MemoriesPagesParams holds the optional query parameters for MemoriesService.Pages.

type MemoriesService

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

MemoriesService groups the memories namespace methods.

func (*MemoriesService) BatchCreate

BatchCreate Create multiple memories in a batch

func (*MemoriesService) BatchDelete

BatchDelete Delete memories in batch

func (*MemoriesService) BatchGet

BatchGet Get multiple memories by ID

func (*MemoriesService) Content

func (s *MemoriesService) Content(ctx context.Context, id string) ([]byte, error)

Content Download memory content

func (*MemoriesService) ContentWithHeaders added in v0.1.13

func (s *MemoriesService) ContentWithHeaders(ctx context.Context, id string, headers map[string]string) ([]byte, error)

ContentWithHeaders Download memory content Headers apply only to this call (for example Range, Accept-Encoding, If-Match).

func (*MemoriesService) Create

Create Create a new memory

func (*MemoriesService) CreateFromFile

func (s *MemoriesService) CreateFromFile(ctx context.Context, filePath string, req *models.JSONMemoryCreationRequest) (*models.Memory, error)

CreateFromFile creates a memory from a local file via a multipart upload — the Go analog of the Python/Java memories.create(file_path) overload. req supplies the space and any metadata (SpaceID is required); the file is the content, so any OriginalContent/OriginalContentB64 on req is ignored. When req.ContentType is empty it is inferred from the file extension.

func (*MemoriesService) CreateFromReader

func (s *MemoriesService) CreateFromReader(ctx context.Context, r io.Reader, filename string, req *models.JSONMemoryCreationRequest) (*models.Memory, error)

CreateFromReader creates a memory by streaming an arbitrary io.Reader as the multipart file part — the streaming sibling of CreateFromFile for content that isn't a local file (an object-store stream, an HTTP response body, an in-memory buffer). The body is streamed with io.Pipe so a large upload never stages the whole payload in memory. filename names the part and, when req.ContentType is empty, drives MIME inference from its extension (pass "" to fall back to application/octet-stream). req supplies the space and metadata (SpaceID required); any OriginalContent/OriginalContentB64 on it is ignored — the reader is the content.

func (*MemoriesService) Delete

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

Delete Delete a memory

func (*MemoriesService) Get

Get Get a memory by ID

func (*MemoriesService) List

func (s *MemoriesService) List(ctx context.Context, spaceID string, params *MemoriesListParams) (*Page[models.Memory], error)

List List memories in a space

func (*MemoriesService) Pages

Pages List memory page images

func (*MemoriesService) PagesImage

func (s *MemoriesService) PagesImage(ctx context.Context, id string, pageIndex string, params *MemoriesPagesImageParams) ([]byte, error)

PagesImage Download memory page image content

func (*MemoriesService) PagesImageWithHeaders added in v0.1.13

func (s *MemoriesService) PagesImageWithHeaders(ctx context.Context, id string, pageIndex string, params *MemoriesPagesImageParams, headers map[string]string) ([]byte, error)

PagesImageWithHeaders Download memory page image content Headers apply only to this call (for example Range, Accept-Encoding, If-Match).

func (*MemoriesService) Retrieve

Retrieve runs a memory retrieval using the flat convenience parameters, expanding SpaceIDs into SpaceKeys and the flat post-processor keys into a ChatPostProcessor (space_ids_to_space_keys + flat_to_nested transforms). The returned Stream must be closed. Use RetrieveRaw to pass a fully-formed RetrieveMemoryRequest.

RetrieveOptions and the request assembly (buildRetrieveRequest / buildChatPostProcessor) are generated into gen_convenience.go from convenience.json; this thin wrapper is the only hand-written piece because it depends on the RetrieveRaw service method signature.

func (*MemoriesService) RetrieveRaw

RetrieveRaw Advanced semantic memory retrieval with JSON

type NetworkError

type NetworkError struct {
	Message string
	Cause   error
}

NetworkError wraps a transport-level failure (DNS, connect, timeout, mid-read drop). The underlying cause is available via errors.Unwrap so users who catch goodmem.Error still see transport failures. inv-network-error-wrap.

func (*NetworkError) Error

func (e *NetworkError) Error() string

func (*NetworkError) Unwrap

func (e *NetworkError) Unwrap() error

type NotFoundError

type NotFoundError struct{ *APIError }

NotFoundError is HTTP 404.

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

type OCRService

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

OCRService groups the ocr namespace methods.

func (*OCRService) Document

Document Run OCR on a document or image

func (*OCRService) DocumentFromFile

func (s *OCRService) DocumentFromFile(ctx context.Context, filePath string, req *models.OCRDocumentRequest) (*models.OCRDocumentResponse, error)

DocumentFromFile runs OCR over a local file — the Go analog of the Python/Java ocr.document(file_path) overload. It reads the file and sends it as base64 in the normal JSON body; the document format is NOT inferred (the server auto-detects it from the bytes — set req.Format only to override). Any req.Content is replaced by the file's contents.

type Option

type Option func(*Client)

Option customizes a Client at construction time.

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

WithHTTPClient supplies a pre-configured *http.Client (BYO mode) instead of the SDK-built default. In BYO mode the caller owns the redirect policy; the SDK-built default refuses to follow redirects so the x-api-key custom header cannot leak across a host boundary (inv-no-redirect-with-custom-auth-header).

func WithStreamMaxLineBytes

func WithStreamMaxLineBytes(n int) Option

WithStreamMaxLineBytes overrides the maximum size of a single NDJSON stream event (memories.retrieve, ping.stream). The default is 8 MiB; a single retrieved item can approach that when Retrieve runs with FetchMemoryContent set, so raise this if a large document ends iteration with a "line cap" error. A value <= 0 keeps the default.

type Page

type Page[T any] struct {
	// contains filtered or unexported fields
}

Page is a single page of a paginated list response plus the means to fetch the following pages on demand. The list methods (spaces.List, memories.List) return the first page; iterate every item across all pages with All:

page, err := client.Spaces().List(ctx, nil)
if err != nil { ... }
for sp, err := range page.All(ctx) {
    if err != nil { ... }
    fmt.Println(sp.SpaceID)
}

Or walk page by page with Items()/Next().

func (*Page[T]) All

func (p *Page[T]) All(ctx context.Context) iter.Seq2[T, error]

All returns a range-over-func iterator (Go 1.23+) over every item across all pages, fetching subsequent pages lazily. If a page fetch fails, the iterator yields the zero value with the error once and stops.

func (*Page[T]) HasMore

func (p *Page[T]) HasMore() bool

HasMore reports whether another page is available.

func (*Page[T]) Items

func (p *Page[T]) Items() []T

Items returns the items on this page only.

func (*Page[T]) Next

func (p *Page[T]) Next(ctx context.Context) (*Page[T], error)

Next fetches the following page, or returns (nil, nil) when there are no more.

func (*Page[T]) NextToken

func (p *Page[T]) NextToken() string

NextToken returns the pagination token for the following page ("" if none).

type PermissionDeniedError

type PermissionDeniedError struct{ *APIError }

PermissionDeniedError is HTTP 403.

func (*PermissionDeniedError) Unwrap

func (e *PermissionDeniedError) Unwrap() error

type PingService

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

PingService groups the ping namespace methods.

func (*PingService) Once

Once Run a single ping probe

func (*PingService) Stream

Stream Stream ping probe results

type RateLimitError

type RateLimitError struct {
	*APIError
	RetryAfterSeconds *int64
}

RateLimitError is HTTP 429. RetryAfterSeconds holds the parsed Retry-After header in seconds, or nil when the server did not send it (or sent a value the SDK could not parse — see parseRetryAfter). A missing hint never masks the error itself: the typed 429 is always returned with the status and body.

func (*RateLimitError) Unwrap

func (e *RateLimitError) Unwrap() error

type RerankersGetParams

type RerankersGetParams struct {
	// IncludeCredentials Whether to return stored credentials. Also accepts include_credentials. Requires READ_RERANKER_CREDENTIALS in addition to READ_RERANKER.
	IncludeCredentials *bool `json:"-"`
}

RerankersGetParams holds the optional query parameters for RerankersService.Get.

type RerankersListParams

type RerankersListParams struct {
	// OwnerID Filter the already-authorized result set by owner principal UUID. Omitting this parameter does not bypass per-reranker READ_RERANKER filtering.
	OwnerID *string `json:"-"`
	// ProviderType Filter rerankers by provider type. Allowed values match the ProviderType schema.
	ProviderType *models.ProviderType `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

RerankersListParams holds the optional query parameters for RerankersService.List.

type RerankersService

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

RerankersService groups the rerankers namespace methods.

func (*RerankersService) Create

Create Create a new reranker

func (*RerankersService) Delete

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

Delete Delete a reranker

func (*RerankersService) Get

Get Get a reranker by ID

func (*RerankersService) List

List List rerankers

func (*RerankersService) Update

Update Update a reranker

type RetrieveOptions

type RetrieveOptions struct {
	// SpaceIDs is the shorthand for "these spaces, no per-space configuration":
	// each id becomes an unfiltered SpaceKey. Mutually exclusive with SpaceKeys.
	SpaceIDs []string

	// SpaceKeys is the full per-space configuration — each entry carries its own
	// optional Filter (metadata filter expression) and EmbedderWeights. Use this
	// instead of SpaceIDs when different spaces need different filters; mutually
	// exclusive with it. Filter is forwarded verbatim (grammar is a server concern).
	SpaceKeys []models.SpaceKey

	// Context supplies optional additional context for the search (text or binary),
	// e.g. recent conversation turns. Forwarded verbatim.
	Context []models.ContextItem

	FetchMemory        *bool
	FetchMemoryContent *bool
	RequestedSize      *int32

	// ChatPostProcessor flat keys. LLM-bound keys apply only when LLMID is set,
	// RelevanceThreshold only when RerankerID is set, and the pipeline keys only
	// when either is set — Retrieve rejects orphans rather than letting the server
	// silently drop them.
	LLMID               *string
	RerankerID          *string
	LLMTemp             *float64
	GenTokenBudget      *int32
	RelevanceThreshold  *float64
	MaxResults          *int32
	Prompt              *string
	SysPrompt           *string
	ChronologicalResort *bool
}

RetrieveOptions holds the flat convenience parameters for MemoriesService.Retrieve. SpaceIDs is expanded into unfiltered SpaceKeys, SpaceKeys is forwarded verbatim for per-space filters, Context is carried through, and the flat ChatPostProcessor keys are assembled into a PostProcessor. Exactly one of SpaceIDs / SpaceKeys is required; every other field is optional. For full control over the request body use RetrieveRaw.

type ServiceIdentitiesGetParams

type ServiceIdentitiesGetParams struct {
	// IncludeDeleted Permit an authorized read of a permanent tombstone
	IncludeDeleted *bool `json:"-"`
}

ServiceIdentitiesGetParams holds the optional query parameters for ServiceIdentitiesService.Get.

type ServiceIdentitiesListParams

type ServiceIdentitiesListParams struct {
	// OwnerPrincipalID Exact current administrative-owner principal UUID
	OwnerPrincipalID *string `json:"-"`
	// IncludeDeleted Include readable permanent tombstones
	IncludeDeleted *bool `json:"-"`
	// MaxResults Page size; defaults to 50 and must be between 1 and 1000
	MaxResults *int32 `json:"-"`
	// NextToken Opaque continuation token
	NextToken *string `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

ServiceIdentitiesListParams holds the optional query parameters for ServiceIdentitiesService.List.

type ServiceIdentitiesService

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

ServiceIdentitiesService groups the service_identities namespace methods.

func (*ServiceIdentitiesService) Create

Create Create a service identity

func (*ServiceIdentitiesService) Delete

Delete Delete a service identity

func (*ServiceIdentitiesService) Get

Get Get a service identity

func (*ServiceIdentitiesService) List

List List service identities

func (*ServiceIdentitiesService) TransferOwnership

TransferOwnership Transfer service-identity ownership

func (*ServiceIdentitiesService) Update

Update Update a service identity

type SpacesListParams

type SpacesListParams struct {
	// OwnerID Filter the already-authorized result set by owner principal UUID. Omitting this parameter does not bypass per-space READ_SPACE filtering.
	OwnerID *string `json:"-"`
	// NameFilter Filter spaces by name using glob pattern matching
	NameFilter *string `json:"-"`
	// MaxResults Maximum number of results to return in a single page (defaults to 50, clamped to [1, 1000])
	MaxResults *int32 `json:"-"`
	// NextToken Pagination token for retrieving the next set of results
	NextToken *string `json:"-"`
	// SortBy Field to sort by: 'created_time', 'updated_time', or 'name' (default: 'created_time'). Unsupported values return INVALID_ARGUMENT.
	SortBy *string `json:"-"`
	// SortOrder Sort order (ASCENDING or DESCENDING, default: DESCENDING)
	SortOrder *models.SortOrder `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

SpacesListParams holds the optional query parameters for SpacesService.List.

type SpacesService

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

SpacesService groups the spaces namespace methods.

func (*SpacesService) Create

Create Create a new Space

func (*SpacesService) Delete

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

Delete Delete a space

func (*SpacesService) Get

func (s *SpacesService) Get(ctx context.Context, id string) (*models.Space, error)

Get Get a space by ID

func (*SpacesService) List

func (s *SpacesService) List(ctx context.Context, params *SpacesListParams) (*Page[models.Space], error)

List List spaces

func (*SpacesService) TransferOwnership

TransferOwnership Transfer ownership of a space

func (*SpacesService) Update

Update Update a space

type Stream

type Stream[T any] struct {
	// contains filtered or unexported fields
}

Stream is a lazily-consumed NDJSON event stream. Iterate it with Events and always Close it (the underlying HTTP response holds a connection):

stream, err := client.Ping().Stream(ctx, req)
if err != nil { ... }
defer stream.Close()
for ev, err := range stream.Events() {
    if err != nil { ... }
    // handle ev
}

func (*Stream[T]) Close

func (s *Stream[T]) Close() error

Close releases the underlying HTTP response. Safe to call multiple times: the body is closed exactly once (Events() also closes on iteration end, and the documented usage adds a defer Close()), so concurrent/duplicate calls are a no-op after the first.

func (*Stream[T]) Events

func (s *Stream[T]) Events() iter.Seq2[T, error]

Events returns a range-over-func iterator over each NDJSON event.

All-null oneOf frames — the server's *_NOT_SET sentinel, serialized as `{}` or `{"retrievedItem":{}}` — are skipped silently so a single empty frame doesn't tear down the stream (inv-stream-tolerates-null-oneof-frames). A non-empty line that fails to parse surfaces as a *GoodmemError; a transport read failure surfaces as a *NetworkError. The response is closed when iteration ends.

type SystemService

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

SystemService groups the system namespace methods.

func (*SystemService) Info

Info Retrieve server build metadata

func (*SystemService) Init

Init Initialize the system

type UnprocessableEntityError

type UnprocessableEntityError struct{ *APIError }

UnprocessableEntityError is HTTP 422.

func (*UnprocessableEntityError) Unwrap

func (e *UnprocessableEntityError) Unwrap() error

type UserEnrollmentsService

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

UserEnrollmentsService groups the user_enrollments namespace methods.

func (*UserEnrollmentsService) Complete

Complete Complete human-user enrollment

type UsersGetByUsernameParams

type UsersGetByUsernameParams struct {
	// IncludeDeleted Permit an authorized read of a permanent tombstone
	IncludeDeleted *bool `json:"-"`
}

UsersGetByUsernameParams holds the optional query parameters for UsersService.GetByUsername.

type UsersGetOptions

type UsersGetOptions struct {
	ID             *string `json:"-"`
	Email          *string `json:"-"`
	IncludeDeleted *bool   `json:"includeDeleted,omitempty"`
}

UsersGetOptions selects one lookup key for UsersService.Get; set exactly one field.

type UsersListEnrollmentsParams

type UsersListEnrollmentsParams struct {
	// MaxResults Page size; defaults to 50 and must be between 1 and 1000
	MaxResults *int32 `json:"-"`
	// NextToken Opaque continuation token
	NextToken *string `json:"-"`
}

UsersListEnrollmentsParams holds the optional query parameters for UsersService.ListEnrollments.

type UsersListParams

type UsersListParams struct {
	// IncludeDeleted Include readable permanent tombstones
	IncludeDeleted *bool `json:"-"`
	// IncludeEnrollmentSummary Request non-secret enrollment posture on active rows where the caller also has MANAGE_USER_ENROLLMENT
	IncludeEnrollmentSummary *bool `json:"-"`
	// MaxResults Page size; defaults to 50 and must be between 1 and 1000
	MaxResults *int32 `json:"-"`
	// NextToken Opaque continuation token
	NextToken *string `json:"-"`
	// Label Filter by label key-value pairs. Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
	Label map[string]string `json:"-"`
}

UsersListParams holds the optional query parameters for UsersService.List.

type UsersService

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

UsersService groups the users namespace methods.

func (*UsersService) Create

Create Create a human user

func (*UsersService) CreateEnrollment

CreateEnrollment Create a human-user enrollment

func (*UsersService) Delete

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

Delete Delete a human user

func (*UsersService) Get

Get Get a user by ID

func (*UsersService) GetByUsername

func (s *UsersService) GetByUsername(ctx context.Context, username string, params *UsersGetByUsernameParams) (*models.UserResponse, error)

GetByUsername Get user by username

func (*UsersService) GetEnrollment

func (s *UsersService) GetEnrollment(ctx context.Context, userID string, enrollmentID string) (*models.UserEnrollmentResponse, error)

GetEnrollment Get a human-user enrollment

func (*UsersService) List

List List human users

func (*UsersService) ListEnrollments

ListEnrollments List a human user's enrollments

func (*UsersService) Me

Me Get current user profile

func (*UsersService) RevokeEnrollment

func (s *UsersService) RevokeEnrollment(ctx context.Context, userID string, enrollmentID string) error

RevokeEnrollment Revoke a human-user enrollment

func (*UsersService) Update

Update Update a human user

Directories

Path Synopsis
examples
basic_rag command
Building a Basic RAG Agent with GoodMem — Go SDK.
Building a Basic RAG Agent with GoodMem — Go SDK.

Jump to

Keyboard shortcuts

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