openairesponses

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextError

func ContextError(ctx context.Context) error

ContextError preserves both cancellation identity and a distinct cause.

func MergeChunk

func MergeChunk(response *llm.Response, chunk llm.Chunk)

MergeChunk assembles a streamed chunk into response.

Types

type APIError

type APIError struct {
	Type    string `json:"type,omitempty"`
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

APIError is an error reported by an OpenAI Responses endpoint.

func (*APIError) Error

func (e *APIError) Error() string

type Codec

type Codec struct {
	Provider             string
	ProviderDataAPI      string
	MaxProviderDataBytes int
}

Codec translates llm-go's neutral conversation representation to and from the OpenAI Responses protocol.

func (Codec) FailedResponse added in v0.2.0

func (c Codec) FailedResponse(op string, response sdkresponses.Response) error

FailedResponse converts a failed non-streaming Responses object into a provider error.

func (Codec) FullResponse added in v0.2.0

func (c Codec) FullResponse(op, configuredModel string, tools []llm.Tool, format llm.ResponseFormat, response sdkresponses.Response) (*llm.Response, error)

FullResponse converts one completed or incomplete non-streaming Responses object with the same output validation and replay envelope used by streaming.

func (Codec) Produce

func (c Codec) Produce(ctx context.Context, op, model string, params openairesponses.ResponseNewParams, open OpenStream, emit internalstream.Emit) error

Produce decodes one Responses API event stream into neutral chunks.

func (Codec) ProduceEvents

func (c Codec) ProduceEvents(ctx context.Context, op, model string, params openairesponses.ResponseNewParams, stream EventStream, emit internalstream.Emit) error

ProduceEvents decodes an already-open decoded Responses event source through the same validation and chunk state machine used by SSE.

func (Codec) Request

func (c Codec) Request(op, model string, request llm.Request, options RequestOptions) (openairesponses.ResponseNewParams, error)

Request converts a validated neutral request into Responses API parameters.

type EventStream

type EventStream interface {
	Next() bool
	Current() openairesponses.ResponseStreamEventUnion
	Err() error
	Close() error
}

EventStream is a decoded Responses event source. The OpenAI SSE stream and provider-specific transports such as Codex WebSocket implement this contract.

type InputAudioOptions

type InputAudioOptions struct {
	MaxDecodedBytes int
}

InputAudioOptions enables the private Responses input_audio content variant used by endpoints that explicitly support it. Public Responses callers leave this nil.

type OpenStream

OpenStream starts one Responses API event stream.

type RequestOptions

type RequestOptions struct {
	Subscription        bool
	ReasoningSummary    bool
	EncryptedReasoning  bool
	JSONObjectOutput    bool
	NamedToolChoice     bool
	StrictTools         bool
	ExplicitPromptCache bool
	AdditionalTools     bool
	ToolSearch          bool
	InputAudio          *InputAudioOptions
}

RequestOptions captures endpoint differences within the Responses protocol.

type Stream

Stream is the OpenAI SDK stream consumed by Codec.

Jump to

Keyboard shortcuts

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