Documentation
¶
Overview ¶
Package openaicompat adapts the official openai/openai-go v3 client, speaking the Chat Completions API, into an agentcore.Model. It targets an OpenAI-compatible endpoint — in this service, the Envoy AI Gateway (MODEL_MODE=gateway).
In gateway mode the service holds no MODEL credential: the gateway injects it. The adapter therefore sends no Authorization header when neither an API key nor a token file is configured, and forwards whatever per-request attribution headers the loop supplies.
A token file is a separate concern from the model credential: it proves who is calling the gateway, not who may call the model. On the Datum platform the gateway requires a JWT from an in-cluster workload, so the service presents its own projected ServiceAccount token while still holding no model key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is an agentcore.Model backed by the Chat Completions API.
func (*Model) Stream ¶
Stream implements agentcore.Model. It opens a streaming Chat Completions request (with usage reporting enabled), emits text deltas as they arrive, then emits one tool call per requested function call and a terminal step-finish carrying normalized usage.
type Options ¶
type Options struct {
// ModelID is the model name sent on each request.
ModelID string
// BaseURL is the OpenAI-compatible endpoint base URL (the gateway).
BaseURL string
// APIKey is an optional bearer credential. Empty means no Authorization
// header (the gateway injects the upstream key).
APIKey string
// TokenFile names a file holding a bearer token to present to the
// gateway. It is read on every request, not once here: a projected
// ServiceAccount token is rewritten in place by the kubelet, so a value
// captured at startup works until the first rotation and then 401s for
// good. Ignored when APIKey is set.
TokenFile string
// HTTPClient overrides the HTTP client (custom CA, TLS settings). Nil
// uses the default.
HTTPClient *http.Client
}
Options configures a Model. ModelID and BaseURL are required. APIKey is optional: when empty (the gateway posture) no Authorization header is sent.