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