openailegacy

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package openailegacy implements the legacy OpenAI Chat Completions backend connector using github.com/openai/openai-go/v3. It maps lipapi.Call to chat/completions and streams canonical events from the official SSE stream.

Index

Constants

View Source
const (
	DefaultBaseURL = "https://api.openai.com/v1"
)
View Source
const ID = "openai-legacy"

ID is the reserved plugin identifier for the legacy OpenAI-compatible backend.

Variables

This section is empty.

Functions

func CompletionEvents

func CompletionEvents(comp openai.ChatCompletion) []lipapi.Event

CompletionEvents converts a non-streaming ChatCompletion response into canonical events.

func New

func New(cfg Config) execbackend.Backend

New returns a runtime backend that invokes the OpenAI Chat Completions API using openai-go.

func ParamsForCall

ParamsForCall builds an OpenAI Chat Completions create payload from a canonical call.

Types

type Config

type Config struct {
	BaseURL string
	APIKey  string
	// APIKeys is the ordered credential list for this backend instance.
	// When non-empty, APIKey should match APIKeys[0] for SDK compatibility.
	APIKeys []string
	// Credentials is the structured credential list. When set, it takes precedence
	// over APIKey/APIKeys and preserves non-secret credential IDs for diagnostics.
	Credentials []credpool.Credential
	// HTTPClient is optional; when nil the SDK default is used.
	HTTPClient *http.Client
	// SDKMaxRetries optionally sets the official SDK MaxRetries (nil = SDK default).
	// Integration tests that assert a single upstream attempt on 429/401 should use a pointer to 0.
	SDKMaxRetries    *int
	DefaultVerbosity lipapi.VerbosityLevel
}

Config configures the legacy OpenAI Chat Completions backend connector (official SDK). BaseURL must include the API prefix (e.g. https://api.openai.com/v1).

Jump to

Keyboard shortcuts

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