wire

package
v0.260806.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MPL-2.0 Imports: 1 Imported by: 0

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"`
	Usage         AnthropicUsageWire `json:"usage"`
	ServerToolUse interface{}        `json:"server_tool_use,omitempty"`
}

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.

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,omitempty"`
}

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

type ChatCompletionChoiceWire

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

ChatCompletionChoiceWire is a single choice in the OpenAI Chat Completions response.

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,omitempty"`
	Refusal          string                       `json:"refusal,omitempty"`
	ToolCalls        []ChatCompletionToolCallWire `json:"tool_calls,omitempty"`
	ReasoningContent string                       `json:"reasoning_content,omitempty"`
}

ChatCompletionMessageWire is the message inside a choice.

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"`
}

ChatCompletionWire is the OpenAI Chat Completions response wire format.

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"`
}

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.

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"`
	Name           string `json:"name,omitempty"`
	Arguments      string `json:"arguments"`
}

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,omitempty"`
}

func (ResponsesOutputTextDeltaEvent) EventType

func (e ResponsesOutputTextDeltaEvent) EventType() string

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,omitempty"`
}

func (ResponsesOutputTextDoneEvent) EventType

func (e ResponsesOutputTextDoneEvent) EventType() string

type ResponsesOutputTokensDetailsWire

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

type ResponsesStreamErrorBody

type ResponsesStreamErrorBody struct {
	Message string `json:"message"`
	Type    string `json:"type"`
}

type ResponsesStreamErrorEvent

type ResponsesStreamErrorEvent struct {
	Type           string                   `json:"type"`
	SequenceNumber int64                    `json:"sequence_number"`
	Error          ResponsesStreamErrorBody `json:"error"`
}

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,omitempty"`
}

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