openai

package
v0.0.0-...-f56615f Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package openai adapts the official OpenAI Go SDK to SuperCode's Provider interface. It uses Chat Completions because that protocol is implemented by OpenAI and most OpenAI-compatible services.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingAPIKey = errors.New("OPENAI_API_KEY is required")

Functions

This section is empty.

Types

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	MaxRetries int
	Headers    map[string]string
}

Config contains only connection settings owned by the OpenAI adapter.

type Provider

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

Provider implements provider.Provider with the OpenAI Chat Completions API.

func New

func New(config Config) (*Provider, error)

New creates an OpenAI-compatible provider. The API key is intentionally supplied by the caller so secret loading stays outside the adapter.

func (*Provider) Generate

func (p *Provider) Generate(ctx context.Context, request provider.Request) (provider.Response, error)

Generate maps a provider-neutral request to Chat Completions.

func (*Provider) Stream

func (p *Provider) Stream(ctx context.Context, request provider.Request) (provider.Stream, error)

Stream starts a streaming Chat Completions request.

Jump to

Keyboard shortcuts

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