wire

package
v1.261006.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MPL-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicMsgWire

type AnthropicMsgWire struct {
	ID           string             `json:"id"`
	Type         string             `json:"type"`
	Role         string             `json:"role"`
	Content      interface{}        `json:"content"`
	Model        string             `json:"model"`
	StopReason   string             `json:"stop_reason"`
	StopSequence *string            `json:"stop_sequence"` // null unless a custom stop sequence matched
	Usage        AnthropicUsageWire `json:"usage"`
	Container    interface{}        `json:"container"`
	Diagnostics  interface{}        `json:"diagnostics"`
	StopDetails  interface{}        `json:"stop_details"`
}

AnthropicMsgWire is the intermediate JSON representation used to build anthropic.Message / anthropic.BetaMessage via marshal+unmarshal, which is necessary because the SDK content union types have no public constructors.

The resulting RawJSON is what clients receive, so every key the SDK marks required is emitted. Container, Diagnostics and StopDetails are always null: a converted response never used a container, carries no request diagnostics and has no refusal detail. Beta-only keys (context_management, input_transformations) are left out because the same JSON also serves v1.

type AnthropicOutputTokensDetailsWire added in v0.260819.0

type AnthropicOutputTokensDetailsWire struct {
	ThinkingTokens int64 `json:"thinking_tokens"`
}

AnthropicOutputTokensDetailsWire mirrors Anthropic's own usage.output_tokens_details: thinking_tokens is a subset of output_tokens, same relationship as OpenAI's completion_tokens_details.reasoning_tokens.

type AnthropicUsageWire

type AnthropicUsageWire struct {
	InputTokens              int64                             `json:"input_tokens"`
	OutputTokens             int64                             `json:"output_tokens"`
	CacheReadInputTokens     int64                             `json:"cache_read_input_tokens"`
	CacheCreationInputTokens int64                             `json:"cache_creation_input_tokens"`
	OutputTokensDetails      *AnthropicOutputTokensDetailsWire `json:"output_tokens_details"` // null when no thinking tokens were reported
	CacheCreation            interface{}                       `json:"cache_creation"`
	InferenceGeo             interface{}                       `json:"inference_geo"`
	ServerToolUse            interface{}                       `json:"server_tool_use"`
	ServiceTier              interface{}                       `json:"service_tier"`
}

AnthropicUsageWire represents the Anthropic usage wire format. input_tokens = uncached only; cache_read and cache_creation are separate.

CacheCreation, InferenceGeo, ServerToolUse and ServiceTier are always null: OpenAI-side usage has no TTL breakdown, region, server-tool counts or Anthropic tier to translate. Beta-only keys (fallback_credit, iterations, speed) are left out for the same reason as on AnthropicMsgWire.

type ChatCompletionChoiceWire

type ChatCompletionChoiceWire struct {
	Index        int                       `json:"index"`
	Message      ChatCompletionMessageWire `json:"message"`
	FinishReason string                    `json:"finish_reason"`
	Logprobs     interface{}               `json:"logprobs"`
}

ChatCompletionChoiceWire is a single choice in the OpenAI Chat Completions response. Logprobs is always null: the proxy never requests or translates logprobs.

type ChatCompletionFunctionWire

type ChatCompletionFunctionWire struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

ChatCompletionFunctionWire carries the function name and JSON-encoded arguments.

type ChatCompletionMessageWire

type ChatCompletionMessageWire struct {
	Role             string                       `json:"role"`
	Content          string                       `json:"content"`
	Refusal          string                       `json:"refusal"`
	ToolCalls        []ChatCompletionToolCallWire `json:"tool_calls,omitempty"`
	ReasoningContent string                       `json:"reasoning_content,omitempty"`
}

ChatCompletionMessageWire is the message inside a choice. content and refusal are required-but-nullable; see MarshalJSON. The optional annotations/audio keys are left out — nothing upstream maps to them.

func (ChatCompletionMessageWire) MarshalJSON added in v1.261002.1

func (m ChatCompletionMessageWire) MarshalJSON() ([]byte, error)

MarshalJSON always emits content and refusal, as the real API does: refusal is null unless set, and content is null only when the turn is tool calls or a refusal (an empty text answer stays "").

type ChatCompletionOutputDetailsWire added in v0.260806.1

type ChatCompletionOutputDetailsWire struct {
	ReasoningTokens int64 `json:"reasoning_tokens"`
}

ChatCompletionOutputDetailsWire breaks down completion token categories.

type ChatCompletionPromptDetailsWire

type ChatCompletionPromptDetailsWire struct {
	CachedTokens     int64 `json:"cached_tokens"`
	CacheWriteTokens int64 `json:"cache_write_tokens,omitempty"`
}

ChatCompletionPromptDetailsWire breaks down prompt token categories. cached_tokens and cache_write_tokens are disjoint subsets of prompt_tokens.

type ChatCompletionToolCallWire

type ChatCompletionToolCallWire struct {
	ID       string                     `json:"id"`
	Type     string                     `json:"type"`
	Function ChatCompletionFunctionWire `json:"function"`
}

ChatCompletionToolCallWire is a single tool call inside a message.

type ChatCompletionUsageWire

type ChatCompletionUsageWire struct {
	PromptTokens            int64                            `json:"prompt_tokens"`
	CompletionTokens        int64                            `json:"completion_tokens"`
	TotalTokens             int64                            `json:"total_tokens"`
	PromptTokensDetails     *ChatCompletionPromptDetailsWire `json:"prompt_tokens_details,omitempty"`
	CompletionTokensDetails *ChatCompletionOutputDetailsWire `json:"completion_tokens_details,omitempty"`
}

ChatCompletionUsageWire is the usage block in the OpenAI Chat Completions response. prompt_tokens = TOTAL (uncached + cached + written); cached_tokens and cache_write_tokens are reported, disjoint subsets of it.

type ChatCompletionWire

type ChatCompletionWire struct {
	ID          string                     `json:"id"`
	Object      string                     `json:"object"`
	Created     int64                      `json:"created"`
	Model       string                     `json:"model"`
	Choices     []ChatCompletionChoiceWire `json:"choices"`
	Usage       ChatCompletionUsageWire    `json:"usage"`
	ServiceTier *string                    `json:"service_tier"`
	Moderation  json.RawMessage            `json:"moderation"`
}

ChatCompletionWire is the OpenAI Chat Completions response wire format. service_tier and moderation are always emitted, null when the upstream did not report them. system_fingerprint is left out: it identifies an OpenAI backend configuration and has no honest value for a converted response.

func (ChatCompletionWire) ToMap

func (r ChatCompletionWire) ToMap() map[string]any

ToMap serializes to a generic map for callers that apply runtime transforms.

type ChatStreamChoice

type ChatStreamChoice struct {
	Index        int             `json:"index"`
	Delta        ChatStreamDelta `json:"delta"`
	FinishReason *string         `json:"finish_reason"`
}

type ChatStreamChunk

type ChatStreamChunk struct {
	ID          string             `json:"id"`
	Object      string             `json:"object"`
	Created     int64              `json:"created"`
	Model       string             `json:"model"`
	Choices     []ChatStreamChoice `json:"choices"`
	Usage       *ChatStreamUsage   `json:"usage,omitempty"`
	ServiceTier *string            `json:"service_tier"`
	Moderation  json.RawMessage    `json:"moderation,omitempty"`
}

Chat Completions stream DTOs preserve the minimal outbound JSON shape emitted by this proxy. Keep these fields checked against openai-go Chat Completions stream types when updating the SDK. Every SDK-required chunk key is present; optional ones (choice logprobs, system_fingerprint, obfuscation) are deliberately omitted. service_tier rides on every chunk as the real API does; moderation only on the final one.

type ChatStreamDelta

type ChatStreamDelta struct {
	Role      string               `json:"role,omitempty"`
	Content   string               `json:"content,omitempty"`
	ToolCalls []ChatStreamToolCall `json:"tool_calls,omitempty"`
	// ReasoningContent carries extended-thinking text (DeepSeek-style extension;
	// not part of the official OpenAI Chat schema).
	ReasoningContent string `json:"reasoning_content,omitempty"`
}

type ChatStreamError

type ChatStreamError struct {
	Message string `json:"message"`
	Type    string `json:"type"`
	Code    string `json:"code"`
}

type ChatStreamErrorChunk

type ChatStreamErrorChunk struct {
	Error ChatStreamError `json:"error"`
}

type ChatStreamOutputTokenDetails

type ChatStreamOutputTokenDetails struct {
	ReasoningTokens int64 `json:"reasoning_tokens"`
}

type ChatStreamPromptTokenDetails

type ChatStreamPromptTokenDetails struct {
	CachedTokens     int64 `json:"cached_tokens"`
	CacheWriteTokens int64 `json:"cache_write_tokens,omitempty"`
}

ChatStreamPromptTokenDetails breaks down prompt token categories on a streaming usage chunk. cache_write_tokens is only emitted by gpt-5.6+ and stays omitted for providers that never report it, so downstream can tell "no writes" (explicit 0) apart from "channel does not report writes".

type ChatStreamToolCall

type ChatStreamToolCall struct {
	Index    int                    `json:"index"`
	ID       string                 `json:"id,omitempty"`
	Type     string                 `json:"type,omitempty"`
	Function ChatStreamToolFunction `json:"function"`
}

type ChatStreamToolFunction

type ChatStreamToolFunction struct {
	Name      string  `json:"name,omitempty"`
	Arguments *string `json:"arguments,omitempty"`
}

type ChatStreamUsage

type ChatStreamUsage struct {
	PromptTokens            int64                         `json:"prompt_tokens"`
	CompletionTokens        int64                         `json:"completion_tokens"`
	TotalTokens             int64                         `json:"total_tokens"`
	PromptTokensDetails     *ChatStreamPromptTokenDetails `json:"prompt_tokens_details,omitempty"`
	CompletionTokensDetails *ChatStreamOutputTokenDetails `json:"completion_tokens_details,omitempty"`
}

type ResponsesCompletedEvent

type ResponsesCompletedEvent struct {
	Type           string                `json:"type"`
	SequenceNumber int64                 `json:"sequence_number"`
	Response       ResponsesWireResponse `json:"response"`
}

func (ResponsesCompletedEvent) EventType

func (e ResponsesCompletedEvent) EventType() string

type ResponsesContentPartAddedEvent

type ResponsesContentPartAddedEvent struct {
	Type           string                   `json:"type"`
	SequenceNumber int64                    `json:"sequence_number"`
	ItemID         string                   `json:"item_id"`
	OutputIndex    int                      `json:"output_index"`
	ContentIndex   int                      `json:"content_index"`
	Part           ResponsesContentPartWire `json:"part"`
}

func (ResponsesContentPartAddedEvent) EventType

func (e ResponsesContentPartAddedEvent) EventType() string

type ResponsesContentPartDoneEvent

type ResponsesContentPartDoneEvent struct {
	Type           string                   `json:"type"`
	SequenceNumber int64                    `json:"sequence_number"`
	ItemID         string                   `json:"item_id"`
	OutputIndex    int                      `json:"output_index"`
	ContentIndex   int                      `json:"content_index"`
	Part           ResponsesContentPartWire `json:"part"`
}

func (ResponsesContentPartDoneEvent) EventType

func (e ResponsesContentPartDoneEvent) EventType() string

type ResponsesContentPartWire

type ResponsesContentPartWire struct {
	Type        string        `json:"type"`
	Text        string        `json:"text,omitempty"`
	Annotations []interface{} `json:"annotations,omitempty"`
}

func (ResponsesContentPartWire) MarshalJSON added in v0.260611.1

func (p ResponsesContentPartWire) MarshalJSON() ([]byte, error)

MarshalJSON ensures output_text parts always carry "text" and "annotations" (an empty array when unset): the real Responses API always includes both, and strict clients (the AI SDK's zod schemas) require them.

type ResponsesCreatedEvent

type ResponsesCreatedEvent struct {
	Type           string                `json:"type"`
	SequenceNumber int64                 `json:"sequence_number"`
	Response       ResponsesWireResponse `json:"response"`
}

func (ResponsesCreatedEvent) EventType

func (e ResponsesCreatedEvent) EventType() string

type ResponsesEvent

type ResponsesEvent interface {
	EventType() string
}

ResponsesEvent is implemented by all Responses API SSE event structs. The EventType() return value is used as the SSE event name.

type ResponsesFunctionCallArgumentsDeltaEvent

type ResponsesFunctionCallArgumentsDeltaEvent struct {
	Type           string `json:"type"`
	SequenceNumber int64  `json:"sequence_number"`
	ItemID         string `json:"item_id"`
	OutputIndex    int    `json:"output_index"`
	Delta          string `json:"delta"`
}

func (ResponsesFunctionCallArgumentsDeltaEvent) EventType

type ResponsesFunctionCallArgumentsDoneEvent

type ResponsesFunctionCallArgumentsDoneEvent struct {
	Type           string `json:"type"`
	SequenceNumber int64  `json:"sequence_number"`
	ItemID         string `json:"item_id"`
	OutputIndex    int    `json:"output_index"`
	Arguments      string `json:"arguments"`
}

ResponsesFunctionCallArgumentsDoneEvent carries no "name": the API never sends one here (openai-go v3.68 dropped it); the name lives on the function_call item.

func (ResponsesFunctionCallArgumentsDoneEvent) EventType

type ResponsesInProgressEvent

type ResponsesInProgressEvent struct {
	Type           string                `json:"type"`
	SequenceNumber int64                 `json:"sequence_number"`
	Response       ResponsesWireResponse `json:"response"`
}

func (ResponsesInProgressEvent) EventType

func (e ResponsesInProgressEvent) EventType() string

type ResponsesIncompleteDetailsWire added in v0.260611.1

type ResponsesIncompleteDetailsWire struct {
	Reason string `json:"reason"`
}

type ResponsesIncompleteEvent added in v0.260611.1

type ResponsesIncompleteEvent struct {
	Type           string                `json:"type"`
	SequenceNumber int64                 `json:"sequence_number"`
	Response       ResponsesWireResponse `json:"response"`
}

func (ResponsesIncompleteEvent) EventType added in v0.260611.1

func (e ResponsesIncompleteEvent) EventType() string

type ResponsesInputTokensDetailsWire

type ResponsesInputTokensDetailsWire struct {
	CacheWriteTokens int64 `json:"cache_write_tokens,omitempty"`
	CachedTokens     int64 `json:"cached_tokens"`
}

Codex CLI's ResponseCompleted decoder requires cached_tokens and reasoning_tokens to be present; omitempty would drop them when zero and cause "missing field 'reasoning_tokens'" parse errors for chat-only providers (e.g. DeepSeek) routed through chat-to-responses.

cache_write_tokens (gpt-5.6+) is deliberately omitempty instead: it is a newer field that older Codex builds do not expect, and unlike cached_tokens an absent value is meaningful — it says the channel never reported writes (e.g. Azure, which does not surface them at all).

type ResponsesOutputItemAddedEvent

type ResponsesOutputItemAddedEvent struct {
	Type           string                  `json:"type"`
	SequenceNumber int64                   `json:"sequence_number"`
	OutputIndex    int                     `json:"output_index"`
	Item           ResponsesOutputItemWire `json:"item"`
}

func (ResponsesOutputItemAddedEvent) EventType

func (e ResponsesOutputItemAddedEvent) EventType() string

type ResponsesOutputItemDoneEvent

type ResponsesOutputItemDoneEvent struct {
	Type           string                  `json:"type"`
	SequenceNumber int64                   `json:"sequence_number"`
	OutputIndex    int                     `json:"output_index"`
	Item           ResponsesOutputItemWire `json:"item"`
}

func (ResponsesOutputItemDoneEvent) EventType

func (e ResponsesOutputItemDoneEvent) EventType() string

type ResponsesOutputItemWire

type ResponsesOutputItemWire struct {
	ID        string                     `json:"id"`
	Type      string                     `json:"type"`
	Role      string                     `json:"role,omitempty"`
	Status    string                     `json:"status,omitempty"`
	Content   []ResponsesContentPartWire `json:"content,omitempty"`
	CallID    string                     `json:"call_id,omitempty"`
	Name      string                     `json:"name,omitempty"`
	Arguments *string                    `json:"arguments,omitempty"`
}

type ResponsesOutputTextDeltaEvent

type ResponsesOutputTextDeltaEvent struct {
	Type           string        `json:"type"`
	SequenceNumber int64         `json:"sequence_number"`
	ItemID         string        `json:"item_id"`
	OutputIndex    int           `json:"output_index"`
	ContentIndex   int           `json:"content_index"`
	Delta          string        `json:"delta"`
	Logprobs       []interface{} `json:"logprobs"`
}

func (ResponsesOutputTextDeltaEvent) EventType

func (e ResponsesOutputTextDeltaEvent) EventType() string

func (ResponsesOutputTextDeltaEvent) MarshalJSON added in v1.261002.1

func (e ResponsesOutputTextDeltaEvent) MarshalJSON() ([]byte, error)

MarshalJSON emits logprobs as [] when unset: the key is required.

type ResponsesOutputTextDoneEvent

type ResponsesOutputTextDoneEvent struct {
	Type           string        `json:"type"`
	SequenceNumber int64         `json:"sequence_number"`
	ItemID         string        `json:"item_id"`
	OutputIndex    int           `json:"output_index"`
	ContentIndex   int           `json:"content_index"`
	Text           string        `json:"text"`
	Logprobs       []interface{} `json:"logprobs"`
}

func (ResponsesOutputTextDoneEvent) EventType

func (e ResponsesOutputTextDoneEvent) EventType() string

func (ResponsesOutputTextDoneEvent) MarshalJSON added in v1.261002.1

func (e ResponsesOutputTextDoneEvent) MarshalJSON() ([]byte, error)

MarshalJSON emits logprobs as [] when unset: the key is required.

type ResponsesOutputTokensDetailsWire

type ResponsesOutputTokensDetailsWire struct {
	ReasoningTokens int64 `json:"reasoning_tokens"`
}

type ResponsesStreamErrorEvent

type ResponsesStreamErrorEvent struct {
	Type           string  `json:"type"`
	SequenceNumber int64   `json:"sequence_number"`
	Code           string  `json:"code"`
	Message        string  `json:"message"`
	Param          *string `json:"param"`
}

ResponsesStreamErrorEvent mirrors responses.ResponseErrorEvent: code, message and param sit at the top level — unlike Chat Completions, there is no nested "error" envelope. param is null unless an input field is at fault.

func NewResponsesStreamErrorEvent added in v1.261002.1

func NewResponsesStreamErrorEvent(seq int64, code, message string) ResponsesStreamErrorEvent

NewResponsesStreamErrorEvent builds a mid-stream "error" event.

func (ResponsesStreamErrorEvent) EventType

func (e ResponsesStreamErrorEvent) EventType() string

type ResponsesUsageWire

type ResponsesUsageWire struct {
	InputTokens         int64                            `json:"input_tokens"`
	InputTokensDetails  ResponsesInputTokensDetailsWire  `json:"input_tokens_details"`
	OutputTokens        int64                            `json:"output_tokens"`
	OutputTokensDetails ResponsesOutputTokensDetailsWire `json:"output_tokens_details"`
	TotalTokens         int64                            `json:"total_tokens"`
}

type ResponsesWireResponse

type ResponsesWireResponse struct {
	ID                string                          `json:"id"`
	Object            string                          `json:"object"`
	CreatedAt         int64                           `json:"created_at"`
	Status            string                          `json:"status"`
	Output            []ResponsesOutputItemWire       `json:"output"`
	Usage             *ResponsesUsageWire             `json:"usage,omitempty"`
	Model             string                          `json:"model,omitempty"`
	CompletedAt       int64                           `json:"completed_at,omitempty"`
	IncompleteDetails *ResponsesIncompleteDetailsWire `json:"incomplete_details"`
	Error             interface{}                     `json:"error"` // always null: failures surface as error events or HTTP errors
}

ResponsesWireResponse is the Response object carried by lifecycle events and non-stream replies. error and incomplete_details are always emitted (null when unset). The other SDK-required keys echo request parameters (instructions, metadata, parallel_tool_calls, temperature, tool_choice, tools, top_p, access_programs) that a converter cannot see, so they are left out rather than fabricated.

func (ResponsesWireResponse) ToMap added in v0.260806.1

func (r ResponsesWireResponse) ToMap() map[string]any

ToMap converts the typed response contract to the legacy map surface used by existing non-stream handlers. Stage Bridges should pass the typed value. ToMap serializes to a generic map for callers that apply runtime transforms.

Jump to

Keyboard shortcuts

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