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

client

package
v0.2.55 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBadRequest added in v0.2.43

func IsBadRequest(err error) bool

func IsConflict added in v0.2.41

func IsConflict(err error) bool

func IsForbidden added in v0.2.42

func IsForbidden(err error) bool

func IsNotFound added in v0.2.41

func IsNotFound(err error) bool

func NormalizeURL added in v0.1.7

func NormalizeURL(apiURL string) string

NormalizeURL strips a trailing "/api/v1" suffix (with or without a trailing slash) so that the SDK — which appends "api/v1" itself — does not double it. Self-hosted users commonly set LANGSMITH_ENDPOINT to "https://host/api/v1".

Types

type Client

type Client struct {
	SDK *langsmith.Client
	// contains filtered or unexported fields
}

Client wraps the LangSmith Go SDK and provides helpers for raw HTTP calls.

func New

func New(apiKey, apiURL string) *Client

New creates a new Client.

func NewWithOptions added in v0.2.26

func NewWithOptions(options Options) *Client

NewWithOptions creates a new Client from resolved options.

func (*Client) APIKey added in v0.2.15

func (c *Client) APIKey() string

APIKey returns the client's API key.

func (*Client) APIURL added in v0.2.15

func (c *Client) APIURL() string

APIURL returns the client's normalized API URL.

func (*Client) CustomAppPath added in v0.2.48

func (c *Client) CustomAppPath(appID string) string

CustomAppPath addresses one app.

func (*Client) CustomAppsPath added in v0.2.48

func (c *Client) CustomAppsPath() string

CustomAppsPath is the custom-apps collection.

func (*Client) FetchCustomAppSource added in v0.2.43

func (c *Client) FetchCustomAppSource(ctx context.Context, appID string) ([]byte, error)

FetchCustomAppSource returns the stored .tar.gz bytes for a custom app. The response is binary, so it bypasses the JSON-decoding raw helpers.

func (*Client) OAuthAccessToken added in v0.2.26

func (c *Client) OAuthAccessToken() string

OAuthAccessToken returns the client's OAuth access token.

func (*Client) PlatformPath added in v0.2.48

func (c *Client) PlatformPath(elem ...string) string

PlatformPath builds a platform-service path.

func (*Client) RawDelete

func (c *Client) RawDelete(ctx context.Context, path string, result any) error

RawDelete performs a DELETE request to the LangSmith API.

func (*Client) RawDo added in v0.2.15

func (c *Client) RawDo(ctx context.Context, method, path string, body io.Reader, extraHeaders http.Header) (statusCode int, proto string, respHeaders http.Header, respBody []byte, err error)

RawDo performs an arbitrary HTTP request and returns the raw response. Unlike RawGet/RawPost/RawDelete, it does not unmarshal the response and does not treat 4xx/5xx as errors — callers decide how to handle status codes. body may be nil. extraHeaders are merged on top of the default auth headers.

func (*Client) RawGet

func (c *Client) RawGet(ctx context.Context, path string, result any) error

RawGet performs a GET request to the LangSmith API.

func (*Client) RawPatch added in v0.2.13

func (c *Client) RawPatch(ctx context.Context, path string, body any, result any) error

RawPatch performs a PATCH request to the LangSmith API.

func (*Client) RawPost

func (c *Client) RawPost(ctx context.Context, path string, body any, result any) error

RawPost performs a POST request to the LangSmith API.

func (*Client) ResolveSessionID

func (c *Client) ResolveSessionID(ctx context.Context, projectName string) (string, error)

ResolveSessionID resolves a project name to its session UUID, with caching.

func (*Client) UseV2API added in v0.2.43

func (c *Client) UseV2API(ctx context.Context) (bool, error)

UseV2API reports whether the connected deployment's v2 (SmithDB) API should be used, resolved once from GET /info and cached.

type CustomAppRequest added in v0.2.43

type CustomAppRequest struct {
	Name          *string           `json:"name,omitempty"`
	Description   *string           `json:"description,omitempty"`
	Files         map[string]string `json:"files,omitempty"`
	Entrypoint    *string           `json:"entrypoint,omitempty"`
	SourceArchive *string           `json:"source_archive,omitempty"`
}

CustomAppRequest is the body of custom-app create (POST) and update (PATCH). Unset pointer fields are omitted, leaving the server value untouched.

type OAuthMetadata added in v0.2.46

type OAuthMetadata struct {
	Issuer                      string
	DeviceAuthorizationEndpoint string
	TokenEndpoint               string
	RegistrationEndpoint        string
	// Resource is the RFC 8707 resource indicator; it equals the issuer.
	Resource string
}

OAuthMetadata holds absolute authorization server endpoints. The AS lives at <origin>/oauth on SaaS and <origin>/api/oauth on self-hosted, so callers use these rather than building paths themselves.

func DiscoverOAuth added in v0.2.46

func DiscoverOAuth(ctx context.Context, apiURL string) (*OAuthMetadata, error)

DiscoverOAuth returns the endpoints from the first candidate serving a valid RFC 8414 metadata document. A transient failure against any candidate is reported in preference to errNoOAuthMetadata so callers do not mistake an outage for a legacy backend.

func ResolveOAuth added in v0.2.46

func ResolveOAuth(ctx context.Context, apiURL string) (*OAuthMetadata, error)

ResolveOAuth prefers discovery, falling back to <base>/oauth/* so backends that serve no metadata document keep working. Transient discovery failures are returned rather than masked, because the fallback would post credentials to an endpoint the deployment may not serve.

type Options added in v0.2.26

type Options struct {
	APIKey           string
	OAuthAccessToken string
	APIURL           string
	WorkspaceID      string
	ProfileName      string
}

Options controls LangSmith client authentication and routing.

Jump to

Keyboard shortcuts

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