sap

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package sap provides SAP AI Core's orchestration chat endpoint. SAP AI Core uses a service-key OAuth client-credentials flow, deployment discovery, and the deployment URL's /v2/chat route; it is not treated as a generic hosted API-key provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(selected model.Model, serviceKey ServiceKey, options ...Option) (inference.Client, error)

New constructs an SAP AI Core client. If Model.BaseURL or WithDeploymentURL is absent, the first request discovers a running orchestration deployment through the service key's AI_API_URL; construction itself performs no I/O.

func NewFromEnvironment

func NewFromEnvironment(selected model.Model, options ...Option) (inference.Client, error)

NewFromEnvironment reads AICORE_SERVICE_KEY and the documented deployment metadata environment variables.

Types

type AuthError

type AuthError struct {
	Status int
	Err    error
}

func (*AuthError) Error

func (e *AuthError) Error() string

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

type Client

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

Client lazily resolves SAP's deployment URL and then delegates message encoding, decoding, SSE, usage, tools, and errors to the shared OpenAI codec and transport.

func (*Client) Invoke

func (c *Client) Invoke(ctx context.Context, req inference.Request) (*inference.Response, error)

func (*Client) Stream

type ConfigurationError

type ConfigurationError struct {
	Reason ConfigurationReason
	Err    error
}

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

func (*ConfigurationError) Unwrap

func (e *ConfigurationError) Unwrap() error

type ConfigurationReason

type ConfigurationReason string
const (
	ServiceKeyMissing  ConfigurationReason = "service key is missing"
	InvalidServiceKey  ConfigurationReason = "service key is invalid"
	InvalidModelParams ConfigurationReason = "model parameters are invalid"
	DeploymentMissing  ConfigurationReason = "no running orchestration deployment was found"
)

type CounterSupportError

type CounterSupportError = llm.CounterSupportError

type Option

type Option func(*config)

func WithDeploymentID

func WithDeploymentID(value string) Option

WithDeploymentID selects a deployment from SAP's /v2/lm/deployments list.

func WithDeploymentURL

func WithDeploymentURL(value string) Option

WithDeploymentURL bypasses deployment discovery and uses the already-known orchestration deployment URL. It is also useful for private SAP landscapes.

func WithHeader

func WithHeader(name, value string) Option

func WithModelParam

func WithModelParam(name string, value any) Option

WithModelParam adds one SAP Harmonized API model parameter.

func WithModelParams

func WithModelParams(params map[string]any) Option

WithModelParams merges documented SAP Harmonized API model parameters into the /v2/chat request. Keys are forwarded verbatim in snake_case so SAP can apply model-specific parameters outside the shared inference fields.

func WithResourceGroup

func WithResourceGroup(value string) Option

WithResourceGroup sets the AI-Resource-Group header used for discovery and inference. SAP defaults this value to "default".

type RequestError

type RequestError struct {
	Status int
	Err    error
}

func (*RequestError) Error

func (e *RequestError) Error() string

func (*RequestError) Unwrap

func (e *RequestError) Unwrap() error

type ServiceKey

type ServiceKey struct {
	ClientID     string `json:"clientid"`
	ClientSecret string `json:"clientsecret"`
	TokenURL     string `json:"url"`
	ServiceURLs  struct {
		AIAPIURL string `json:"AI_API_URL"`
	} `json:"serviceurls"`
}

ServiceKey is the client-secret form of an SAP AI Core service key.

func ParseServiceKey

func ParseServiceKey(raw []byte) (ServiceKey, error)

ParseServiceKey parses the JSON value accepted by AICORE_SERVICE_KEY.

Jump to

Keyboard shortcuts

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