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
type MessagesRequest struct {
8
type MessagesRequest struct {
9
Model string `json:"model"`
9
Model string `json:"model"`
10
Messages []ChatMessage `json:"messages"`
10
Messages []ChatMessage `json:"messages"`
11
MaxTokens int `json:"max_tokens"`
11
MaxTokens int `json:"max_tokens"`
12
System string `json:"system"`
12
System string `json:"system"`
13
Temperature float64 `json:"temperature"`
13
Temperature float64 `json:"temperature"`
14
}
14
}
15
15
16
type ContentBlock struct {
16
type ContentBlock struct {
17
// Type is "text", "image", "tool_use", or "tool_result".
17
// Type is "text", "image", "tool_use", or "tool_result".
18
Type string `json:"type"`
18
Type string `json:"type"`
19
Text string `json:"text"`
19
Text string `json:"text"`
20
Source *ContentSource `json:"source"`
20
Source *ContentSource `json:"source"`
21
}
21
}
22
22
23
type ContentSource struct {
23
type ContentSource struct {
24
// Type can only be "base64".
24
// Type can only be "base64".
25
Type string `json:"type"`
25
Type string `json:"type"`
26
26
27
// MediaType can be one of:
27
// MediaType can be one of:
28
// - "image/jpeg",
28
// - "image/jpeg",
29
// - "image/png",
29
// - "image/png",
30
// - "image/gif", or
30
// - "image/gif", or
31
// - "image/webp".
31
// - "image/webp".
32
MediaType string `json:"media_type,omitempty"`
32
MediaType string `json:"media_type,omitempty"`
33
33
34
Data string `json:"data,omitempty"`
34
Data string `json:"data,omitempty"`
35
}
35
}
36
36
37
type Usage struct {
37
type Usage struct {
38
InputTokens int `json:"input_tokens"`
38
InputTokens int `json:"input_tokens"`
39
CacheCreationInputTokens *int `json:"cache_creation_input_tokens"`
39
CacheCreationInputTokens *int `json:"cache_creation_input_tokens"`
40
CacheReadInputTokens *int `json:"cache_read_input_tokens"`
40
CacheReadInputTokens *int `json:"cache_read_input_tokens"`
41
OutputTokens int `json:"output_tokens"`
41
OutputTokens int `json:"output_tokens"`
42
}
42
}
43
43
44
type ErrorResponse struct {
44
type ErrorResponse struct {
45
Type string `json:"type"`
45
Type string `json:"type"`
46
Message string `json:"message"`
46
Message string `json:"message"`
47
}
47
}
48
48
49
type MessagesResponse struct {
49
type MessagesResponse struct {
50
Id string `json:"id"`
50
Id string `json:"id"`
51
Type string `json:"type"`
51
Type string `json:"type"`
52
Role string `json:"role"`
52
Role string `json:"role"`
53
Content []ContentBlock `json:"content"`
53
Content []ContentBlock `json:"content"`
54
Model string `json:"model"`
54
Model string `json:"model"`
55
StopReason string `json:"stop_reason"`
55
StopReason string `json:"stop_reason"`
56
StopSequence bool `json:"stop_sequence"`
56
StopSequence bool `json:"stop_sequence"`
57
Usage Usage `json:"usage"`
57
Usage Usage `json:"usage"`
58
Error *ErrorResponse `json:"error"`
58
Error *ErrorResponse `json:"error"`
59
}
59
}