1
            package api
          
          
            
            1
            package api
          
        
          
            
            2
            
          
          
            
            2
            
          
        
          
            
            3
            type ChatMessage struct {
          
          
            
            3
            type ChatMessage struct {
          
        
          
            
            4
              Role    string         `json:"role"`
          
          
            
            4
              Role    string         `json:"role"`
          
        
          
            
            5
              Content []ContentBlock `json:"content"`
          
          
            
            5
              Content []ContentBlock `json:"content"`
          
        
          
            
            6
            }
          
          
            
            6
            }
          
        
          
            
            7
            
          
          
            
            7
            
          
        
          
            
            8
            // MessageRequest is generalizes across OpenAI, Anthropic, etc.
          
          
            
            8
            // MessageRequest is generalizes across OpenAI, Anthropic, etc.
          
        
          
            
            9
            type MessagesRequest struct {
          
          
            
            9
            type MessagesRequest struct {
          
        
          
            
            10
              Model       string        `json:"model"`
          
          
            
            10
              Model       string        `json:"model"`
          
        
          
            
            11
              Messages    []ChatMessage `json:"messages"`
          
          
            
            11
              Messages    []ChatMessage `json:"messages"`
          
        
          
            
            12
              MaxTokens   int           `json:"max_tokens"`
          
          
            
            12
              MaxTokens   int           `json:"max_tokens"`
          
        
          
            
            13
              System      string        `json:"system,omitempty"`
          
          
            
            13
              System      string        `json:"system,omitempty"`
          
        
          
            
            14
              Temperature float64       `json:"temperature"`
          
          
            
            14
              Temperature float64       `json:"temperature"`
          
        
          
            
            15
              Tools       []Tool        `json:"tools,omitempty"`
          
          
            
            15
              Tools       []Tool        `json:"tools,omitempty"`
          
        
          
            
            16
            }
          
          
            
            16
            }
          
        
          
            
            17
            
          
          
            
            17
            
          
        
          
            
            18
            type ContentBlock struct {
          
          
            
            18
            type ContentBlock struct {
          
        
          
            
            19
              // Type is "text", "image", "tool_use", or "tool_result".
          
          
            
            19
              // Type is "text", "image", "tool_use", or "tool_result".
          
        
          
            
            20
              Type string           `json:"type"`
          
          
            
            20
              Type string           `json:"type"`
          
        
          
            
            21
            
          
          
            
            21
            
          
        
          
            
            22
              // Text is for Type="text"
          
          
            
            22
              // Text is for Type="text"
          
        
          
            
            23
              Text string           `json:"text,omitempty"`
          
          
            
            23
              Text string           `json:"text,omitempty"`
          
        
          
            
            24
            
          
          
            
            24
            
          
        
          
            
            25
              // Source is for Type="image"
          
          
            
            25
              // Source is for Type="image"
          
        
          
            
            26
              Source *ContentSource `json:"source,omitempty"`
          
          
            
            26
              Source *ContentSource `json:"source,omitempty"`
          
        
          
            
            27
            
          
          
            
            27
            
          
        
          
            
            28
              // Id, Name, and Input are for Type="tool_use".
          
          
            
            28
              // Id, Name, and Input are for Type="tool_use".
          
        
          
            
            29
              ID     string         `json:"id,omitempty"`
          
          
            
            29
              ID     string         `json:"id,omitempty"`
          
        
          
            
            30
              Name   string         `json:"name,omitempty"`
          
          
            
            30
              Name   string         `json:"name,omitempty"`
          
        
          
            
            31
              Input  interface{}    `json:"input,omitempty"`
          
          
            
            31
              Input  interface{}    `json:"input,omitempty"`
          
        
          
            
            32
              Output string         `json:"output,omitempty"`
          
          
            
            32
              Output string         `json:"output,omitempty"`
          
        
          
            
            33
            }
          
          
            
            33
            }
          
        
          
            
            34
            
          
          
            
            34
            
          
        
          
            
            35
            type ContentSource struct {
          
          
            
            35
            type ContentSource struct {
          
        
          
            
            36
              // Type can only be "base64".
          
          
            
            36
              // Type can only be "base64".
          
        
          
            
            37
              Type string `json:"type"`
          
          
            
            37
              Type string `json:"type"`
          
        
          
            
            38
            
          
          
            
            38
            
          
        
          
            
            39
              // MediaType can be one of:
          
          
            
            39
              // MediaType can be one of:
          
        
          
            
            40
              // - "image/jpeg",
          
          
            
            40
              // - "image/jpeg",
          
        
          
            
            41
              // - "image/png",
          
          
            
            41
              // - "image/png",
          
        
          
            
            42
              // - "image/gif", or
          
          
            
            42
              // - "image/gif", or
          
        
          
            
            43
              // - "image/webp".
          
          
            
            43
              // - "image/webp".
          
        
          
            
            44
              MediaType string `json:"media_type,omitempty"`
          
          
            
            44
              MediaType string `json:"media_type,omitempty"`
          
        
          
            
            45
            
          
          
            
            45
            
          
        
          
            
            46
              Data string `json:"data,omitempty"`
          
          
            
            46
              Data string `json:"data,omitempty"`
          
        
          
            
            47
            }
          
          
            
            47
            }
          
        
          
            
            48
            
          
          
            
            48
            
          
        
          
            
            49
            type Usage struct {
          
          
            
            49
            type Usage struct {
          
        
          
            
            50
              InputTokens               int  `json:"input_tokens"`
          
          
            
            50
              InputTokens               int  `json:"input_tokens"`
          
        
          
            
            51
              CacheCreationInputTokens  *int `json:"cache_creation_input_tokens"`
          
          
            
            51
              CacheCreationInputTokens  *int `json:"cache_creation_input_tokens"`
          
        
          
            
            52
              CacheReadInputTokens      *int `json:"cache_read_input_tokens"`
          
          
            
            52
              CacheReadInputTokens      *int `json:"cache_read_input_tokens"`
          
        
          
            
            53
              OutputTokens              int  `json:"output_tokens"`
          
          
            
            53
              OutputTokens              int  `json:"output_tokens"`
          
        
          
            
            54
            }
          
          
            
            54
            }
          
        
          
            
            55
            
          
          
            
            55
            
          
        
          
            
            56
            type ErrorResponse struct {
          
          
            
            56
            type ErrorResponse struct {
          
        
          
            
            57
              Type    string `json:"type"`
          
          
            
            57
              Type    string `json:"type"`
          
        
          
            
            58
              Message string `json:"message"`
          
          
            
            58
              Message string `json:"message"`
          
        
          
            
            59
            }
          
          
            
            59
            }
          
        
          
            
            60
            
          
          
            
            60
            
          
        
          
            
            61
            type MessagesResponse struct {
          
          
            
            61
            type MessagesResponse struct {
          
        
          
            
            62
              Id           string         `json:"id"`
          
          
            
            62
              Id           string         `json:"id"`
          
        
          
            
            63
              Type         string         `json:"type"`
          
          
            
            63
              Type         string         `json:"type"`
          
        
          
            
            64
              Role         string         `json:"role"`
          
          
            
            64
              Role         string         `json:"role"`
          
        
          
            
            65
              Content      []ContentBlock `json:"content"`
          
          
            
            65
              Content      []ContentBlock `json:"content"`
          
        
          
            
            66
              Model        string         `json:"model"`
          
          
            
            66
              Model        string         `json:"model"`
          
        
          
            
            67
              StopReason   *string        `json:"stop_reason,omitempty"`
          
          
            
            67
              StopReason   *string        `json:"stop_reason,omitempty"`
          
        
          
            
            68
              StopSequence *string        `json:"stop_sequence,omitempty"`
          
          
            
            68
              StopSequence *string        `json:"stop_sequence,omitempty"`
          
        
          
            
            69
              Usage        Usage          `json:"usage"`
          
          
            
            69
              Usage        Usage          `json:"usage"`
          
        
          
            
            70
              Error        *ErrorResponse `json:"error"`
          
          
            
            70
              Error        *ErrorResponse `json:"error"`
          
        
          
            
            71
            }
          
          
            
            71
            }
          
        
          
            
            72
            
          
          
            
            72
            
          
        
          
            
            73
            type Tool struct {
          
          
            
            73
            type Tool struct {
          
        
          
            
            74
              Type     string        `json:"type"`
          
          
            
            74
              Type     string        `json:"type"`
          
        
          
            
            75
              Function *ToolFunction `json:"function"`
          
          
            
            75
              Function *ToolFunction `json:"function"`
          
        
          
            
            76
            }
          
          
            
            76
            }
          
        
          
            
            77
            
          
          
            
            77
            
          
        
          
            
            78
            type ToolFunction struct {
          
          
            
            78
            type ToolFunction struct {
          
        
          
            
            79
              Name        string      `json:"name"`
          
          
            
            79
              Name        string      `json:"name"`
          
        
          
            
            80
              Description string      `json:"description"`
          
          
            
            80
              Description string      `json:"description"`
          
        
          
            
            81
              InputSchema interface{} `json:"input_schema"`
          
          
            
            81
              InputSchema interface{} `json:"input_schema"`
          
        
          
            
            82
            }
          
          
            
            82
            }