v0.12.0 — responses.Request 100% OpenAPI spec compliance
Complete rework of responses.Request to exactly model the OpenAI CreateResponse OpenAPI schema — every field present, correctly typed, correctly constrained.
Highlights
- Schema-validated decoding:
DecodeRequest([]byte)validates JSON against the derived schema before unmarshaling.RequestSchema()exports the schema as JSON. - 12 new fields:
Text,Truncation,Include,StreamOptions,Background,MaxToolCalls,Conversation,ContextManagement,Prompt,SafetyIdentifier,ServiceTier,TopLogprobs - Discriminated union types:
InputParam(string | []InputItem),ToolParam,ToolChoiceParam,TextResponseFormat,ConversationParam— each with named constructors andJSONSchema()methods - 7 typed enum aliases:
ReasoningEffort,ReasoningSummary,PromptCacheRetention,ServiceTier,Truncation,IncludeItem,Verbosity - Metadata separation: internal adapter state no longer leaks to the OpenAI wire.
RequestMetadata→RequestIdentity;ExtraMetadata→OpenAIMetadata map[string]string - Full bridge coverage: all new fields bridged forward and reverse between
unified.Requestandresponses.Request, with a field-coverage comment documenting every wire field's source - Conversation:
Builder.ToolResultWithErrorfor error-flagged tool results
Breaking changes
responses.Request fields:
- Pointer types for nullable semantics:
Instructions,MaxOutputTokens,Temperature,TopP,Stream,PreviousResponseID,Store,ParallelToolCalls,PromptCacheRetention Inputchanged from[]InputtoInputParam(useInputText()orInputItems())Toolschanged from[]Toolto[]ToolParam(useToolFromFunction()etc.)ToolChoicechanged fromanyto*ToolChoiceParamMetadatachanged frommap[string]anytomap[string]stringReasoningfields changed to*ReasoningEffort/*ReasoningSummary
unified types:
Request.Metadatarenamed toRequest.Identity(type*RequestIdentity)ResponsesExtras.ExtraMetadata→OpenAIMetadata map[string]stringCompletionsExtras.ExtraMetadata→OpenAIMetadata map[string]string
Removed:
responses.Request.MaxTokens(useMaxOutputTokens)responses.Request.TopK(not in Responses API spec)responses.Request.ResponseFormat(replaced byText.Format)responses.ResponseFormat,responses.Input,responses.Toolstructsunified.RequestMetadata(replaced byRequestIdentity)unified.ResponsesExtras.UsedMaxTokenField
Dependencies
github.com/invopop/jsonschemav0.13.0 (promoted from indirect)github.com/santhosh-tekuri/jsonschema/v6v6.0.2 (promoted from indirect)