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 "image/jpeg", "image/png", "image/gif",
27
// MediaType can be "image/jpeg", "image/png", "image/gif",
28
// or "image/webp".
28
// or "image/webp".
29
MediaType string `json:"media_type"`
29
MediaType string `json:"media_type"`
30
30
31
Data string `json:"data"`
31
Data string `json:"data"`
32
}
32
}
33
33
34
type Usage struct {
34
type Usage struct {
35
InputTokens int `json:"input_tokens"`
35
InputTokens int `json:"input_tokens"`
36
CacheCreationInputTokens *int `json:"cache_creation_input_tokens"`
36
CacheCreationInputTokens *int `json:"cache_creation_input_tokens"`
37
CacheReadInputTokens *int `json:"cache_read_input_tokens"`
37
CacheReadInputTokens *int `json:"cache_read_input_tokens"`
38
OutputTokens int `json:"output_tokens"`
38
OutputTokens int `json:"output_tokens"`
39
}
39
}
40
40
41
type ErrorResponse struct {
41
type ErrorResponse struct {
42
Type string `json:"type"`
42
Type string `json:"type"`
43
Message string `json:"message"`
43
Message string `json:"message"`
44
}
44
}
45
45
46
type MessagesResponse struct {
46
type MessagesResponse struct {
47
Id string `json:"id"`
47
Id string `json:"id"`
48
Type string `json:"type"`
48
Type string `json:"type"`
49
Role string `json:"role"`
49
Role string `json:"role"`
50
Content []ContentBlock `json:"content"`
50
Content []ContentBlock `json:"content"`
51
Model string `json:"model"`
51
Model string `json:"model"`
52
StopReason string `json:"stop_reason"`
52
StopReason string `json:"stop_reason"`
53
StopSequence bool `json:"stop_sequence"`
53
StopSequence bool `json:"stop_sequence"`
54
Usage Usage `json:"usage"`
54
Usage Usage `json:"usage"`
55
Error *ErrorResponse `json:"error"`
55
Error *ErrorResponse `json:"error"`
56
}
56
}