package api // ChatRequest is the request body for POST /v1/chat/completions. type ChatRequest struct { Model string `json:"model"` Messages []Message `json:"messages"` Stream bool `json:"stream,omitempty"` SessionID string `json:"session_id,omitempty"` IdempotencyKey string `json:"idempotency_key,omitempty"` Priority string `json:"priority,omitempty"` MaxOutputTokens int `json:"max_output_tokens,omitempty"` ContextPolicy string `json:"context_policy,omitempty"` Timeouts *RequestTimeouts `json:"timeouts,omitempty"` Routing *RoutingOptions `json:"routing,omitempty"` Metadata map[string]string `json:"metadata,omitempty"` Temperature *float64 `json:"temperature,omitempty"` TopP *float64 `json:"top_p,omitempty"` } type Message struct { Role string `json:"role"` Content any `json:"content"` // string or []ContentPart for vision } type RequestTimeouts struct { QueueMs int `json:"queue_ms,omitempty"` FirstTokenMs int `json:"first_token_ms,omitempty"` InferenceMs int `json:"inference_ms,omitempty"` TotalMs int `json:"total_ms,omitempty"` } type RoutingOptions struct { LocalOnly bool `json:"local_only,omitempty"` AllowSmallerModel bool `json:"allow_smaller_model,omitempty"` } // ChatResponse is the non-streaming response. type ChatResponse struct { RequestID string `json:"request_id"` TaskID string `json:"task_id"` SessionID string `json:"session_id,omitempty"` Status string `json:"status"` Model string `json:"model"` Choices []Choice `json:"choices"` LogicalModel string `json:"logical_model"` ActualModel string `json:"actual_model"` NodeID string `json:"node_id,omitempty"` Usage *Usage `json:"usage,omitempty"` Timing *Timing `json:"timing,omitempty"` Degraded bool `json:"degraded,omitempty"` } type Choice struct { Index int `json:"index"` Message *Message `json:"message,omitempty"` Delta *Message `json:"delta,omitempty"` FinishReason string `json:"finish_reason,omitempty"` } type Usage struct { InputTokens int `json:"input_tokens"` OutputTokens int `json:"output_tokens"` TotalTokens int `json:"total_tokens"` } type Timing struct { QueueMs int `json:"queue_ms"` FirstTokenMs int `json:"first_token_ms"` InferenceMs int `json:"inference_ms"` TotalMs int `json:"total_ms"` } // ErrorResponse is the unified error response format. type ErrorResponse struct { Error ErrorBody `json:"error"` } type ErrorBody struct { Code string `json:"code"` Message string `json:"message"` RequestID string `json:"request_id,omitempty"` } // ModelListResponse is the response for GET /v1/models. type ModelListResponse struct { Object string `json:"object"` Data []ModelInfo `json:"data"` } type ModelInfo struct { ID string `json:"id"` Object string `json:"object"` OwnedBy string `json:"owned_by"` Provider string `json:"provider,omitempty"` ContextWindow int `json:"context_window,omitempty"` MaxOutputTokens int `json:"max_output_tokens,omitempty"` } // SessionRequest is the request body for POST /v1/sessions. type SessionRequest struct { ApplicationID string `json:"application_id"` UserID string `json:"user_id,omitempty"` Config map[string]any `json:"config,omitempty"` } // SessionResponse is the response for session operations. type SessionResponse struct { SessionID string `json:"session_id"` ApplicationID string `json:"application_id"` UserID string `json:"user_id,omitempty"` CreatedAt string `json:"created_at"` LastActive string `json:"last_active"` }