openairesponses

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: 35 Imported by: 0

Documentation

Overview

Package openairesponses implements the OpenAI Responses–compatible HTTP frontend: JSON decode to lipapi.Call, core execution, and JSON or SSE encode for official clients. Routing uses header X-LIP-Route (selector like backend:model) until task 11 wires config.

v1 subset vs vendor spec (cross-check)

Spec: https://platform.openai.com/docs/api-reference/responses , https://platform.openai.com/docs/api-reference/responses/create , https://platform.openai.com/docs/api-reference/responses-streaming

| Area | v1 status | Tests | |-----------------|------------|-------| | POST …/responses | Supported | integration_test.go, decode_test.go, encode_test.go | | Other endpoints | Out of scope | — | | input string/array of message | Supported | decode_test.go | | input item types except message | Rejected | decode_test.go | | instructions string | Supported | decode_test.go | | instructions non-string | Rejected | decode_test.go | | tools (function) | Supported (decode) | decode_test.go | | Tool/reasoning on response wire | Supported (encode) | encode_test.go, integration_test.go | | Reasoning on wire | Supported (encode) | encode_test.go | | Multimodal input_text/image/file | Supported | decode_test.go, integration_test.go |

Index

Constants

View Source
const (
	RouteOperationCreate = "openai_responses_create"
	RouteOperationCancel = "openai_responses_cancel"
)
View Source
const (
	HeaderRouteSelector = routeselect.HeaderRouteSelector
)
View Source
const ID = "openai-responses"

ID is the reserved plugin identifier for the OpenAI Responses frontend.

View Source
const ProfileID = "openai_responses_v1"

ProfileID is the static identifier for the certified OpenAI Responses fast-path profile (Requirements 4, 17).

Variables

This section is empty.

Functions

func ModelFromCall

func ModelFromCall(c *lipapi.Call) string

ModelFromCall returns the wire model string stored during decode.

func Mount

func Mount(mux *http.ServeMux, opts lipsdk.FrontendMountOptions) error

Mount registers the OpenAI Responses API handler on mux.

func RouteClaims

func RouteClaims(ownerID string) ([]httpcontract.RouteClaim, error)

RouteClaims describes the routes owned by this frontend instance.

func WireWriteNonStreamJSON

func WireWriteNonStreamJSON(ctx context.Context, w http.ResponseWriter, rc frontendpipe.ResponseContext, es lipapi.EventStream, exposeExt bool) error

WireWriteNonStreamJSON encodes a completed canonical stream as OpenAI Responses JSON for wire fast-path execution.

func WireWriteStreamSSE

func WireWriteStreamSSE(ctx context.Context, w http.ResponseWriter, rc frontendpipe.ResponseContext, es lipapi.EventStream, exposeExt bool) error

WireWriteStreamSSE emits responses SSE events incrementally from the canonical stream for wire fast-path execution.

func WriteErrorJSON

func WriteErrorJSON(w http.ResponseWriter, status int, message, errType, code string) error

WriteErrorJSON writes an OpenAI-shaped JSON error before any streamed bytes.

func WriteNonStreamJSON

func WriteNonStreamJSON(ctx context.Context, w http.ResponseWriter, call *lipapi.Call, es lipapi.EventStream, opts EncodeOptions) error

func WriteStreamSSE

func WriteStreamSSE(ctx context.Context, w http.ResponseWriter, call *lipapi.Call, es lipapi.EventStream, opts EncodeOptions) error

Types

type Config

type Config = frontendconfig.Config

func DecodeConfig

func DecodeConfig(n yaml.Node) (Config, error)

type DecodeOptions

type DecodeOptions struct {
	// RouteSelector is required (e.g. "stub:gpt-4o-mini"); usually from X-LIP-Route header.
	RouteSelector string
	// Headers carries optional HTTP carriers (e.g. LIP session resume headers).
	Headers http.Header
}

DecodeOptions configures decoding of a Responses API create request.

type DecodedCreate

type DecodedCreate struct {
	Call   *lipapi.Call
	Stream bool
	Model  string
}

DecodedCreate is the result of decoding POST /v1/responses JSON.

func DecodeCreateRequest

func DecodeCreateRequest(body []byte, opts DecodeOptions) (*DecodedCreate, error)

DecodeCreateRequest maps an OpenAI Responses create JSON body into a canonical call.

type EncodeOptions

type EncodeOptions struct {
	ResponseID               string
	MessageID                string
	CreatedAt                int64
	ExposeLipUsageExtensions bool
}

EncodeOptions controls wire identifiers for encoded Responses payloads.

type Handler

type Handler struct {
	Exec lipsdk.ExecutorView
	// DefaultRouteSelector is used when HeaderRouteSelector is absent.
	DefaultRouteSelector string
	// RoutePrefixes are backend route-selector prefixes accepted from body model.
	RoutePrefixes routeselect.PrefixSet
	// MaxRequestBodyBytes caps the request body; zero uses reqbody.DefaultMaxBytes.
	MaxRequestBodyBytes     int64
	Log                     *slog.Logger
	TrafficPorts            traffic.PortBundle
	DecodeAdmission         lipsdk.DecodeAdmission
	PreRequestKeepalive     lipsdk.FrontendKeepaliveConfig
	Config                  Config
	HTTPHeaders             lipsdk.HTTPHeaders
	StreamKeepaliveInterval time.Duration
	// Profile optionally overrides the large-payload fast-path profile (defaults to NewProfile()).
	Profile frontendpipe.FrontendProfile
	// LargePayload configures the large-payload fast-path candidate limits.
	LargePayload frontendpipe.LargePayloadConfig
	// contains filtered or unexported fields
}

Handler wires HTTP POST /v1/responses to decode → executor → encode.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements OpenAI Responses create on POST …/responses.

func (*Handler) Spec

func (h *Handler) Spec() *frontendpipe.Spec[EncodeOptions]

Spec returns the configured frontendpipe.Spec for this handler.

type Profile

type Profile struct{}

Profile implements frontendpipe.FrontendProfile for OpenAI Responses create (POST /v1/responses).

func NewProfile

func NewProfile() *Profile

NewProfile returns an initialized OpenAI Responses frontend profile.

func (*Profile) CompileProof

CompileProof compiles protocol proof and response seeds from the captured request replay under decode admission (Requirements 4, 13, 14, 16, 17). Uses the streaming proof pass without allocating or retaining the full request body.

func (*Profile) ProfileID

func (p *Profile) ProfileID() string

ProfileID returns the static identifier for this certified profile.

Jump to

Keyboard shortcuts

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