Documentation
¶
Overview ¶
Package openai is a thin wrapper around the official OpenAI SDK (github.com/openai/openai-go), used to validate a user-supplied API key (via ListModels, a zero-token metadata call) and to run single-turn, non-streaming completions (via Complete) for the tract engine's "Call LLM" step.
No streaming, no tool use, no multi-turn conversation — deliberately out of scope for this first pass. See docs/byok/04_tract_llm_step.md for the full design rationale.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatusCode ¶
StatusCode extracts the HTTP status code from an error returned by this client, when the error originated from an actual API response (as opposed to a network-level failure like a timeout or DNS error, which the SDK does not wrap in *sdk.Error). ok is false for those network-level cases.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the OpenAI SDK client with the narrow surface the connection service and tract engine actually need.
func New ¶
New constructs a Client authenticated with apiKey. If baseUrl is non-empty, it overrides the SDK's default API host (e.g. for a proxy, regional endpoint, or OpenAI-compatible provider).
func (*Client) Complete ¶
func (c *Client) Complete(ctx context.Context, req CompleteRequest) (CompleteResult, error)
Complete performs a single-turn, non-streaming call to the Chat Completions API.
func (*Client) ListModels ¶
ListModels wraps the SDK's models-list call (GET /v1/models). It is a metadata endpoint — no completion tokens billed — so it doubles as the key-validation call: an auth failure surfaces here as an error before any completion is ever attempted.
func (*Client) Ping ¶
Ping confirms apiKey authenticates and model is usable by sending the cheapest possible completion request, discarding the reply. It exists as a fallback key-validation path for providers whose OpenAI-compatible endpoint doesn't implement GET /v1/models (ListModels) — common for third-party proxies that only mirror the Chat Completions API surface.
type CompleteRequest ¶
CompleteRequest is a single-turn, non-streaming completion request: one user message (Prompt), an optional SystemPrompt, and a model. No tool use, no thinking, no history.
type CompleteResult ¶
CompleteResult is the text of the model's reply plus its token usage.
type ModelInfo ¶
ModelInfo is the subset of the Models-List response fields relevant to Artel. It is intentionally thinner than Anthropic's ModelInfo: OpenAI's GET /v1/models response only carries an id and an owning org — no display name or token-limit metadata is returned.