Generated reference
osyra — Go SDK API reference
Auto-generated from go doc -all using go1.23.12. Do not edit by hand.
Distribution status: This module is currently source-only and is not published through the public Go proxy. The API below describes the reviewed source tree; it is not a public-installation claim.
package osyra // import "github.com/osyra-ai/osyra-go"
Package osyra is a standard-library Go client for Osyra Edge's protected,
OpenAI-compatible Chat Completions, Embeddings, and Models surface.
The resource base defaults to https://api.osyra.ai/v1. OAuth tokens are issued
by https://auth.osyra.ai but are sent to the resource ingress:
import (
"context"
"log"
"os"
osyra "github.com/osyra-ai/osyra-go"
)
client, err := osyra.NewClient(
osyra.WithAccessToken(os.Getenv("OSYRA_ACCESS_TOKEN")),
)
if err != nil {
log.Fatal(err)
}
response, err := client.Chat.Completions.Create(context.Background(), osyra.ChatCompletionRequest{
Model: os.Getenv("OSYRA_MODEL"),
Messages: []osyra.Message{{Role: "user", Content: "Hello"}},
})
if err != nil {
log.Fatal(err)
}
if len(response.Choices) == 0 {
log.Fatal("Osyra returned a completion without choices")
}
log.Print(response.Choices[0].Message.Content)
WithAPIKey sends an exact osy_(sandbox|test|live)_<43-base64url> key as
X-Api-Key. WithAccessToken and WithTokenProvider send OAuth credentials only
as Authorization: Bearer. The SDK never emits both credential headers and
rejects generic attempts to override either one. API-key lifecycle activation
additionally requires the target IAM deployment's API-key crypto backend and KMS
HMAC key; OAuth is the deployment-safe default.
Osyra-specific workspace, cache, and PII-mask options ride X-Osyra-* headers;
they never enter the OpenAI-shaped JSON body. Enforcement remains in Osyra Edge
and downstream services, not in this client.
Edge currently guarantees chat fields model, messages, max_tokens, temperature,
top_p, stop, stream, and stream_options, plus embedding fields model, input,
and dimensions. Other typed fields and Extra values are serialized for wire
compatibility only; serialization does not mean Edge accepts, forwards,
or honors their semantics.
Automatic retry is limited to safe model-list GET requests. Inference POSTs and
streams are not replayed without an idempotency contract.
CONSTANTS
const (
DefaultBaseURL = "https://api.osyra.ai/v1"
DefaultTimeout = 60 * time.Second
DefaultMaxRetries = 2
HeaderAPIKey = "X-Api-Key"
)
Defaults implement the public OpenAI-shaped Edge route contract.
const (
HeaderWorkspace = "X-Osyra-Workspace"
HeaderCacheTTL = "X-Osyra-Cache-TTL"
HeaderCache = "X-Osyra-Cache"
HeaderPIIMask = "X-Osyra-PII-Mask"
)
The three OSYRA extras -> X-Osyra-* request headers.
Mirrors the merged Python SDK's _extras.py byte-for-byte in header names and
semantics (AP00023 §4.2). The extras ride request HEADERS (not OpenAI body
fields) so (a) a native OpenAI endpoint silently ignores them — the A/B-test
invariant — and (b) there is no OpenAI body-schema collision.
WithWorkspace -> X-Osyra-Workspace
WithCacheTTL -> X-Osyra-Cache-TTL (+ X-Osyra-Cache: enabled)
WithCacheDisabled -> X-Osyra-Cache: disabled
WithPIIMask -> X-Osyra-PII-Mask
Go has no kwargs, so the Python UNSET-vs-None-vs-value sentinel is modelled
with functional RequestOptions: an option that is not passed emits no header
(the UNSET case); WithCacheDisabled is the explicit-None-disables case;
WithCacheTTL is the value case.
const Version = "0.2.0"
Version is the SDK version, surfaced in the default User-Agent.
VARIABLES
var (
// ErrAuthentication is wrapped by 401 responses (missing/invalid/expired credential).
ErrAuthentication = errors.New("osyra: authentication failed")
// ErrPermissionDenied is wrapped by 403 responses (valid credential, lacks permission,
// or a cross-tenant X-Osyra-Workspace rejected by the edge — fail-closed).
ErrPermissionDenied = errors.New("osyra: permission denied")
// ErrNotFound is wrapped by 404 responses (route/model not found).
ErrNotFound = errors.New("osyra: not found")
// ErrBadRequest is wrapped by 400/422 responses (malformed request body).
ErrBadRequest = errors.New("osyra: bad request")
// ErrRateLimit is wrapped by 429 responses (edge rate limit; carries RetryAfter).
ErrRateLimit = errors.New("osyra: rate limited")
// ErrInternalServer is wrapped by 5xx responses (edge/broker/provider failure).
ErrInternalServer = errors.New("osyra: internal server error")
)
Sentinel errors for errors.Is checks. An *APIError wraps the matching
sentinel based on its status code, so errors.Is(err, osyra.ErrRateLimit)
works on the returned error.
var ErrInvalidCredential = errors.New("osyra: credential must not contain commas or whitespace")
ErrInvalidCredential is returned when a configured credential cannot be one
unambiguous HTTP credential value. The error deliberately never includes the
rejected value.
var ErrMultipleCredentials = errors.New("osyra: multiple credential sources configured")
ErrMultipleCredentials is returned when more than one credential source is
configured. The SDK never chooses between conflicting auth channels.
var ErrNoAPIKey = errors.New("osyra: no credential provided (use WithAPIKey, WithAccessToken, WithTokenProvider, or OSYRA_API_KEY)")
ErrNoAPIKey is returned by NewClient when no credential is configured.
The historical name is retained for source compatibility; OAuth callers may
use WithAccessToken or WithTokenProvider instead.
var ErrNotImplemented = errors.New("osyra: not yet wired (broker RPC has no edge REST route today)")
ErrNotImplemented is returned by the native Osyra.* methods whose broker
RPC is designed but not yet projected through the edge REST surface
(EstimateCost / RoutingDecision / ProviderHealth — AP00023 §12 OQ-2).
It NEVER returns fabricated data; the wrapping *NotImplementedError names
the missing edge route. errors.Is(err, osyra.ErrNotImplemented) detects it.
var ErrReservedHeader = errors.New("osyra: credential header is reserved")
ErrReservedHeader is returned when a generic header option attempts to
set Authorization, X-Api-Key, or the unsupported X-Osyra-Api-Key alias.
This prevents dual credentials, credential substitution, and contract drift.
FUNCTIONS
func IsAuth(err error) bool
IsAuth reports whether err is an authentication (401) failure.
func IsBadRequest(err error) bool
IsBadRequest reports whether err is a bad-request (400/422) failure.
func IsNotFound(err error) bool
IsNotFound reports whether err is a not-found (404) failure.
func IsPermissionDenied(err error) bool
IsPermissionDenied reports whether err is a permission (403) failure.
func IsRateLimit(err error) bool
IsRateLimit reports whether err is a rate-limit (429) failure.
func RetryAfter(err error) (float64, bool)
RetryAfter returns the Retry-After (seconds) carried by a 429 *APIError,
and whether it was present.
TYPES
type APIError struct {
// StatusCode is the HTTP status of the failing response.
StatusCode int
// Message is the human-readable message (best-effort from the body).
Message string
// Code is the OpenAI-style machine error code from body.error.code, if any.
Code string
// Type is the OpenAI-style error type from body.error.type, if any.
Type string
// Body is the raw response body bytes (never logged automatically).
Body []byte
// RequestID is the X-Request-Id echoed by the edge, if present.
RequestID string
// RetryAfter is the parsed Retry-After in seconds (>0 only on 429 with the header).
RetryAfter float64
// Has unexported fields.
}
APIError is a non-2xx response from the OSYRA edge / model broker.
It carries the HTTP status code, the raw response body, a best-effort
OpenAI error code/type extracted from the body, the echoed X-Request-Id,
and (for 429) the parsed Retry-After in seconds.
func (e *APIError) Error() string
func (e *APIError) Unwrap() error
Unwrap returns the wrapped sentinel so errors.Is(err, ErrRateLimit) works.
type ChatCompletion struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage *CompletionUsage `json:"usage,omitempty"`
// OSYRA extension: the broker surfaces which upstream provider served the call.
Provider string `json:"provider,omitempty"`
}
ChatCompletion is the OpenAI /v1/chat/completions response.
type ChatCompletionChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChunkChoice `json:"choices"`
Provider string `json:"provider,omitempty"`
}
ChatCompletionChunk is one SSE chunk of a streamed chat completion.
type ChatCompletionMessage struct {
Role string `json:"role"`
Content string `json:"content"`
}
ChatCompletionMessage is the assistant message inside a Choice.
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
// Stream is set internally by CreateStream; Create always sends a
// non-streaming body. A caller setting Stream on Create is ignored.
Stream bool `json:"stream,omitempty"`
// OpenAI-shaped compatibility fields (ENG-2502 serialization parity with the
// Python port). Pointers let explicit zero values differ from unset values.
// See the type comment for the smaller Edge-guaranteed semantic subset.
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
N *int `json:"n,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
MaxCompletionTokens *int `json:"max_completion_tokens,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
Seed *int `json:"seed,omitempty"`
User string `json:"user,omitempty"`
ResponseFormat any `json:"response_format,omitempty"`
Tools []any `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
LogitBias map[string]int `json:"logit_bias,omitempty"`
Logprobs *bool `json:"logprobs,omitempty"`
TopLogprobs *int `json:"top_logprobs,omitempty"`
Modalities []string `json:"modalities,omitempty"`
ServiceTier string `json:"service_tier,omitempty"`
Store *bool `json:"store,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
StreamOptions any `json:"stream_options,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
// Extra serializes additional OpenAI-wire params verbatim into the outgoing
// body. Keys are merged at the top level; a typed field of the same name wins.
// Edge acceptance, forwarding, and semantics are not guaranteed.
Extra map[string]any `json:"-"`
}
ChatCompletionRequest is the OpenAI /v1/chat/completions request body.
Edge currently guarantees model, messages, max_tokens, temperature,
top_p, stop, stream, and stream_options. Other fields are serialized for
OpenAI-shaped wire compatibility, but the current Edge contract does not
guarantee that it accepts, forwards, or honors them. The three OSYRA extras
are NOT here: they ride X-Osyra-* headers via per-call RequestOption (see
extras.go); putting them in the body is a bug the tests assert against.
type ChatCompletionStream struct {
// Has unexported fields.
}
ChatCompletionStream is an iterator over a streamed chat completion. Call
Recv() until it returns io.EOF, then Close() — or defer Close() immediately.
Close is safe to call multiple times and releases the HTTP connection.
func (s *ChatCompletionStream) Close() error
Close releases the underlying HTTP response body. Safe to call repeatedly.
func (s *ChatCompletionStream) Err() error
Err returns the terminal non-EOF error, if any, after Recv stopped.
func (s *ChatCompletionStream) Recv() (*ChatCompletionChunk, error)
Recv returns the next ChatCompletionChunk, or io.EOF when the stream ends
(either the [DONE] sentinel or the connection closing). A malformed non-JSON
data line is skipped rather than crashing the iterator, matching the Python
SDK. The underlying read honors the request context: a cancelled context
surfaces as an error from Recv.
type ChatService struct {
Completions *CompletionsService
}
ChatService is client.Chat — owns the Completions sub-resource, mirroring
the OpenAI Go client's client.Chat.Completions shape.
type Choice struct {
Index int `json:"index"`
Message ChatCompletionMessage `json:"message"`
FinishReason string `json:"finish_reason"`
}
Choice is one OpenAI chat-completion choice.
type ChoiceDelta struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
}
ChoiceDelta is the incremental delta in a streaming chunk choice.
type ChunkChoice struct {
Index int `json:"index"`
Delta ChoiceDelta `json:"delta"`
FinishReason string `json:"finish_reason"`
}
ChunkChoice is one choice inside a streaming chunk.
type Client struct {
// OpenAI-symmetric resource namespaces.
Chat *ChatService
Embeddings *EmbeddingsService
Models *ModelsService
// Osyra is the OSYRA-native surface (no OpenAI analog): models / cost /
// routing / health. See osyra.go.
Osyra *OsyraService
// Has unexported fields.
}
Client is the OpenAI-shaped OSYRA client.
Construct via NewClient with exactly one credential source. It exposes the
supported OpenAI-shaped resource namespaces Chat, Embeddings, and Models.
func NewClient(opts ...ClientOption) (*Client, error)
NewClient builds a Client from functional options. Credentials come
from WithAPIKey, WithAccessToken, WithTokenProvider, or OSYRA_API_KEY.
The base URL comes from WithBaseURL, OSYRA_BASE_URL, or DefaultBaseURL.
HTTP is rejected unless WithAllowInsecure is set and the parsed host is
exact loopback.
It returns ErrNoAPIKey when no credential is configured — fail-closed,
never a silent unauthenticated client.
func (c *Client) BaseURL() string
BaseURL returns the resolved base URL (test/introspection helper).
type ClientOption func(*clientConfig)
ClientOption mutates the client config during NewClient.
func WithAPIKey(key string) ClientOption
WithAPIKey sets the OSYRA credential. An exact IAM API key of the form
osy_(sandbox|test|live)_<43 base64url characters> is sent as X-Api-Key.
Other values that pass credential validation retain the pre-ENG-3092
compatibility behavior and are sent as OAuth Bearer credentials. Prefer
WithAccessToken for new OAuth integrations.
func WithAccessToken(token string) ClientOption
WithAccessToken sets a static OAuth access token. It is always sent as
Authorization: Bearer <token>, even if its opaque value resembles an API
key.
func WithAllowInsecure() ClientOption
WithAllowInsecure permits an http:// base URL (localhost dev only). Without
it, a non-https base URL is rejected at NewClient.
func WithBaseURL(url string) ClientOption
WithBaseURL overrides the default OSYRA edge base URL
(https://api.osyra.ai/v1). Useful for staging/localhost.
func WithCacheDisabled() ClientOption
WithCacheDisabled sets the client-default X-Osyra-Cache: disabled (the
Python cache_ttl=None case).
func WithCacheTTL(seconds int) ClientOption
WithCacheTTL sets the client-default semantic-cache TTL (seconds) ->
X-Osyra-Cache-TTL + X-Osyra-Cache: enabled.
func WithDefaultHeader(key, value string) ClientOption
WithDefaultHeader sets a default header sent on every request (overridable
per call). Credential headers and the unsupported X-Osyra-Api-Key alias are
rejected case-insensitively; credentials must use the dedicated options.
func WithHTTPClient(hc *http.Client) ClientOption
WithHTTPClient injects a caller-owned *http.Client (e.g. custom transport,
proxy, or RoundTripper for testing). The SDK shallow-copies it and disables
redirects so credentials and non-idempotent inference are never replayed.
func WithMaxRetries(n int) ClientOption
WithMaxRetries bounds retries on 429/503 for safe/idempotent requests
(currently Models.List GET). Inference POSTs are never retried. 0 disables
retries.
func WithPIIMask(strategy string) ClientOption
WithPIIMask sets the client-default X-Osyra-PII-Mask (a strategy string).
func WithPIIMaskEnabled(enabled bool) ClientOption
WithPIIMaskEnabled sets the client-default X-Osyra-PII-Mask to
"true"/"false".
func WithTimeout(d time.Duration) ClientOption
WithTimeout sets the per-request HTTP timeout (default 60s). Ignored if
WithHTTPClient supplies a caller-owned *http.Client.
func WithTokenProvider(provider TokenProvider) ClientOption
WithTokenProvider configures a dynamic OAuth token source. The provider is
called once per request and its result is always sent as Authorization:
Bearer. It is mutually exclusive with WithAPIKey and WithAccessToken.
func WithUserAgent(ua string) ClientOption
WithUserAgent overrides the default User-Agent.
func WithWorkspace(workspace string) ClientOption
WithWorkspace sets the client-default X-Osyra-Workspace tenant.
type CompletionUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
// OSYRA extension surfaced when present on the wire (non-OpenAI).
EstimatedCostMicrocents *int `json:"estimated_cost_microcents,omitempty"`
}
CompletionUsage is the OpenAI token-usage block.
type CompletionsService struct {
// Has unexported fields.
}
CompletionsService is client.Chat.Completions.
func (s *CompletionsService) Create(ctx context.Context, req ChatCompletionRequest, opts ...RequestOption) (*ChatCompletion, error)
Create sends a non-streaming chat completion request. It builds the exact
OpenAI-shaped /v1/chat/completions JSON body (model + messages + any set
compatibility fields), sends it via net/http to Osyra Edge, and parses the
response into a typed *ChatCompletion. Serialization of a field does not
imply Edge guarantees that field's semantics; see ChatCompletionRequest.
The three OSYRA extras are passed as RequestOptions and ride X-Osyra-*
headers; they never enter the JSON body.
func (s *CompletionsService) CreateStream(ctx context.Context, req ChatCompletionRequest, opts ...RequestOption) (*ChatCompletionStream, error)
CreateStream opens a streaming chat completion. It sets stream:true in the
body, hits /chat/completions/stream, and returns a *ChatCompletionStream the
caller iterates with Recv() until io.EOF. The caller MUST Close the stream.
type CostEstimateRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
}
CostEstimateRequest is the input to EstimateCost (broker EstimateCost).
type CreateEmbeddingResponse struct {
Object string `json:"object"`
Data []Embedding `json:"data"`
Model string `json:"model"`
Usage *CompletionUsage `json:"usage,omitempty"`
Provider string `json:"provider,omitempty"`
}
CreateEmbeddingResponse is the OpenAI /v1/embeddings response.
type Embedding struct {
Object string `json:"object"`
Index int `json:"index"`
Embedding []float64 `json:"embedding"`
}
Embedding is a single OpenAI embedding object.
type EmbeddingRequest struct {
Model string `json:"model"`
Input any `json:"input"`
Dimensions *int `json:"dimensions,omitempty"`
EncodingFormat string `json:"encoding_format,omitempty"`
User string `json:"user,omitempty"`
// Extra serializes additional OpenAI-wire params into the outgoing body;
// Edge acceptance, forwarding, and semantics are not guaranteed.
Extra map[string]any `json:"-"`
}
EmbeddingRequest is the OpenAI /v1/embeddings request body.
Edge currently guarantees model, input, and dimensions. Input accepts a
string or []string and the JSON encoder serializes it as-is. EncodingFormat,
User, and Extra remain wire-compatibility fields; current Edge semantics for
them are not guaranteed.
type EmbeddingsService struct {
// Has unexported fields.
}
EmbeddingsService exposes Osyra Edge's OpenAI-shaped /v1/embeddings route.
func (s *EmbeddingsService) Create(ctx context.Context, req EmbeddingRequest, opts ...RequestOption) (*CreateEmbeddingResponse, error)
Create sends an embeddings request, building an OpenAI-shaped JSON body and
parsing the response into a typed *CreateEmbeddingResponse. Serialization
of a field does not imply Edge guarantees that field's semantics; see
EmbeddingRequest. OSYRA extras ride X-Osyra-* headers and never enter the
body.
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Name string `json:"name,omitempty"`
}
Message is a single OpenAI chat message.
type Model struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
OwnedBy string `json:"owned_by"`
// OSYRA-native broker extensions (also present on the legacy native route).
Name string `json:"name,omitempty"`
Provider string `json:"provider,omitempty"`
Type string `json:"type,omitempty"`
ContextWindow int `json:"context_window,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
InputCostPer1K int `json:"input_cost_per_1k,omitempty"`
OutputCostPer1K int `json:"output_cost_per_1k,omitempty"`
Available *bool `json:"available,omitempty"`
Capabilities map[string]any `json:"capabilities,omitempty"`
}
Model is one model, OpenAI /v1/models-shaped (id/object/created/owned_by)
with the OSYRA-native broker fields surfaced as additive extensions.
A native OpenAI client reads ID; OSYRA callers can read the routing/cost
metadata.
The legacy native model route returns the broker ModelResponse shape
({id,name,provider,type,context_window,...}); we decode it directly and
project OwnedBy from Provider when the OpenAI owned_by field is absent (see
normalize, called by Models.List).
type ModelList struct {
Object string `json:"object"`
Data []Model `json:"data"`
}
ModelList is the OpenAI /v1/models list envelope: {object:"list",
data:Model}.
type ModelsService struct {
// Has unexported fields.
}
ModelsService exposes Osyra Edge's OpenAI-shaped /v1/models route (AP00023
§3.2 v0.2).
The edge exposes the OpenAI-compatible catalog at GET /v1/models, returning
an OpenAI list envelope. parseModelList also accepts the legacy bare array
so callers can roll through an edge upgrade without fabricated fallback
data.
func (s *ModelsService) List(ctx context.Context, opts ...RequestOption) (*ModelList, error)
List returns the supported models from GET {baseURL}/models. An optional
workspace selector remains an X-Osyra-Workspace header subordinate to the
authenticated principal; it is never interpolated into the URL.
type NotImplementedError struct {
Method string // e.g. "Osyra.EstimateCost"
EdgeRoute string // the future edge route, e.g. "POST /api/v1/estimate/cost"
}
NotImplementedError is the typed error for a designed-but-unwired native
surface. It carries the future edge route so the dependency is explicit.
func (e *NotImplementedError) Error() string
func (e *NotImplementedError) Unwrap() error
Unwrap lets errors.Is(err, ErrNotImplemented) match.
type OsyraService struct {
// Has unexported fields.
}
OsyraService is client.Osyra — the OSYRA-native surface with no
OpenAI analog (AP00023 §4.3). EstimateCost / EstimateRoutingDecision
/ GetProviderHealth / ListSupportedModels are OSYRA-native (no OpenAI
equivalent) so they live under a dedicated client.Osyra.* namespace and
never pollute the OpenAI-shaped surface (they vanish when a customer points
the base URL back at OpenAI).
WIRED REALITY (NO STUBS — verified against AP00001-edge/internal/rest):
- Models is wired as an alias of client.Models.List over GET /v1/models.
- EstimateCost / RoutingDecision / ProviderHealth map to the broker RPCs
EstimateCost / EstimateRoutingDecision / GetProviderHealth, which EXIST
on AP00006 but are NOT projected through the edge REST surface today.
Rather than fabricate a response, these return a *NotImplementedError
naming the missing edge route — an honest, fail-loud "pending" marker
(§12 OQ-2). When the edge route lands the method body fills in;
the signature is stable now.
func (s *OsyraService) EstimateCost(ctx context.Context, req CostEstimateRequest) (map[string]any, error)
EstimateCost estimates the cost of a completion (broker EstimateCost).
PENDING: no edge REST route is wired for this broker RPC yet (AP00023 §12
OQ-2). Returns a *NotImplementedError — fabricates no cost figure.
func (s *OsyraService) Models(ctx context.Context, opts ...RequestOption) (*ModelList, error)
Models lists supported models and delegates to client.Models.List.
func (s *OsyraService) ProviderHealth(ctx context.Context) (map[string]any, error)
ProviderHealth reports upstream-provider health (broker GetProviderHealth).
PENDING: no edge REST route is wired for this broker RPC yet (AP00023 §12
OQ-2). Returns a *NotImplementedError — fabricates no health data.
func (s *OsyraService) RoutingDecision(ctx context.Context, req RoutingDecisionRequest) (map[string]any, error)
RoutingDecision previews the broker's routing decision (broker
EstimateRoutingDecision).
PENDING: no edge REST route is wired for this broker RPC yet (AP00023 §12
OQ-2). Returns a *NotImplementedError — fabricates no plan.
type RequestOption func(*requestConfig)
RequestOption overrides extras / headers for a single Create call.
func RequestWithCacheDisabled() RequestOption
RequestWithCacheDisabled emits X-Osyra-Cache: disabled for this call.
func RequestWithCacheTTL(seconds int) RequestOption
RequestWithCacheTTL overrides the semantic-cache TTL (seconds) for this
call.
func RequestWithHeader(key, value string) RequestOption
RequestWithHeader sets an arbitrary extra header for this call (overrides
client defaults). Credential headers and the unsupported X-Osyra-Api-Key
alias are rejected case-insensitively. Use dedicated options for OSYRA
extras.
func RequestWithPIIMask(strategy string) RequestOption
RequestWithPIIMask overrides X-Osyra-PII-Mask (strategy string) for this
call.
func RequestWithPIIMaskEnabled(enabled bool) RequestOption
RequestWithPIIMaskEnabled overrides X-Osyra-PII-Mask to "true"/"false".
func RequestWithWorkspace(workspace string) RequestOption
RequestWithWorkspace overrides X-Osyra-Workspace for this call.
type RoutingDecisionRequest struct {
Prompt string `json:"prompt,omitempty"`
Model string `json:"model,omitempty"`
Policy string `json:"policy,omitempty"`
}
RoutingDecisionRequest is the input to RoutingDecision (broker
EstimateRoutingDecision).
type TokenProvider func(context.Context) (string, error)
TokenProvider returns a current OAuth access token for one request.
The SDK invokes it with the request context and sends its result only as
Authorization: Bearer <token>.