Skip to content

v0.12.0 — responses.Request 100% OpenAPI spec compliance

Choose a tag to compare

@timofriedlberlin timofriedlberlin released this 21 Apr 21:59
· 1 commit to main since this release

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 and JSONSchema() 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.Request and responses.Request, with a field-coverage comment documenting every wire field's source
  • Conversation: Builder.ToolResultWithError for error-flagged tool results

Breaking changes

responses.Request fields:

  • Pointer types for nullable semantics: Instructions, MaxOutputTokens, Temperature, TopP, Stream, PreviousResponseID, Store, ParallelToolCalls, PromptCacheRetention
  • Input changed from []Input to InputParam (use InputText() or InputItems())
  • Tools changed from []Tool to []ToolParam (use ToolFromFunction() etc.)
  • ToolChoice changed from any to *ToolChoiceParam
  • Metadata changed from map[string]any to map[string]string
  • Reasoning fields changed to *ReasoningEffort / *ReasoningSummary

unified types:

  • Request.Metadata renamed to Request.Identity (type *RequestIdentity)
  • ResponsesExtras.ExtraMetadata → OpenAIMetadata map[string]string
  • CompletionsExtras.ExtraMetadata → OpenAIMetadata map[string]string

Removed:

  • responses.Request.MaxTokens (use MaxOutputTokens)
  • responses.Request.TopK (not in Responses API spec)
  • responses.Request.ResponseFormat (replaced by Text.Format)
  • responses.ResponseFormat, responses.Input, responses.Tool structs
  • unified.RequestMetadata (replaced by RequestIdentity)
  • unified.ResponsesExtras.UsedMaxTokenField

Dependencies

  • github.com/invopop/jsonschema v0.13.0 (promoted from indirect)
  • github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 (promoted from indirect)