Skip to content

Commit 8742081

Browse files
committed
update models api response structs
1 parent 2b8d13b commit 8742081

1 file changed

Lines changed: 82 additions & 22 deletions

File tree

models.go

Lines changed: 82 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,103 @@ const (
1313

1414
type ModelArchitecture struct {
1515
InputModalities []string `json:"input_modalities"`
16+
Modality *string `json:"modality"`
1617
OutputModalities []string `json:"output_modalities"`
18+
InstructType *string `json:"instruct_type"`
1719
Tokenizer string `json:"tokenizer"`
18-
InstructType *string `json:"instruct_type,omitempty"`
1920
}
2021

21-
type ModelTopProvider struct {
22-
IsModerated bool `json:"is_moderated"`
23-
ContextLength *int64 `json:"context_length,omitempty"`
24-
MaxCompletionTokens *int64 `json:"max_completion_tokens,omitempty"`
22+
type ModelDefaultParameters struct {
23+
FrequencyPenalty *float64 `json:"frequency_penalty"`
24+
PresencePenalty *float64 `json:"presence_penalty"`
25+
RepetitionPenalty *float64 `json:"repetition_penalty"`
26+
Temperature *float64 `json:"temperature"`
27+
TopK *int64 `json:"top_k"`
28+
TopP *float64 `json:"top_p"`
29+
}
30+
31+
type ModelLinks struct {
32+
Details string `json:"details"`
33+
}
34+
35+
type ModelPerRequestLimits struct {
36+
CompletionTokens float64 `json:"completion_tokens"`
37+
PromptTokens float64 `json:"prompt_tokens"`
2538
}
2639

2740
type ModelPricing struct {
28-
Prompt string `json:"prompt"`
2941
Completion string `json:"completion"`
42+
Prompt string `json:"prompt"`
43+
Audio string `json:"audio"`
44+
AudioOutput string `json:"audio_output"`
45+
Discount float64 `json:"discount"`
3046
Image string `json:"image"`
47+
ImageOutput string `json:"image_output"`
48+
ImageToken string `json:"image_token"`
49+
InputAudioCache string `json:"input_audio_cache"`
50+
InputCacheRead string `json:"input_cache_read"`
51+
InputCacheWrite string `json:"input_cache_write"`
52+
InternalReasoning string `json:"internal_reasoning"`
3153
Request string `json:"request"`
3254
WebSearch string `json:"web_search"`
33-
InternalReasoning string `json:"internal_reasoning"`
34-
InputCacheRead *string `json:"input_cache_read,omitempty"`
35-
InputCacheWrite *string `json:"input_cache_write,omitempty"`
55+
}
56+
57+
type ModelTopProvider struct {
58+
IsModerated bool `json:"is_moderated"`
59+
ContextLength *int64 `json:"context_length"`
60+
MaxCompletionTokens *int64 `json:"max_completion_tokens"`
61+
}
62+
63+
type ModelDesignArenaBenchmark struct {
64+
Arena string `json:"arena"`
65+
Category string `json:"category"`
66+
Elo float64 `json:"elo"`
67+
Rank int64 `json:"rank"`
68+
WinRate float64 `json:"win_rate"`
69+
}
70+
71+
type ModelArtificialAnalysisBenchmark struct {
72+
AgenticIndex *float64 `json:"agentic_index"`
73+
CodingIndex *float64 `json:"coding_index"`
74+
IntelligenceIndex *float64 `json:"intelligence_index"`
75+
}
76+
77+
type ModelBenchmarks struct {
78+
DesignArena []ModelDesignArenaBenchmark `json:"design_arena"`
79+
ArtificialAnalysis ModelArtificialAnalysisBenchmark `json:"artificial_analysis"`
80+
}
81+
82+
type ModelReasoning struct {
83+
DefaultEffort *string `json:"default_effort"`
84+
SupportedEfforts *[]string `json:"supported_efforts"`
85+
Mandatory bool `json:"mandatory"`
86+
DefaultEnabled bool `json:"default_enabled"`
87+
SupportsMaxTokens bool `json:"supports_max_tokens"`
3688
}
3789

3890
type Model struct {
39-
ID string `json:"id"`
40-
Name string `json:"name"`
41-
Created int64 `json:"created"`
42-
Description string `json:"description"`
43-
Architecture ModelArchitecture `json:"architecture"`
44-
TopProvider ModelTopProvider `json:"top_provider"`
45-
Pricing ModelPricing `json:"pricing"`
46-
CanonicalSlug *string `json:"canonical_slug,omitempty"`
47-
ContextLength *int64 `json:"context_length,omitempty"`
48-
HuggingFaceID *string `json:"hugging_face_id,omitempty"`
49-
PerRequestLimits any `json:"per_request_limits,omitempty"`
50-
SupportedParameters []string `json:"supported_parameters,omitempty"`
91+
Architecture ModelArchitecture `json:"architecture"`
92+
CanonicalSlug string `json:"canonical_slug"`
93+
ContextLength *int64 `json:"context_length"`
94+
Created int64 `json:"created"`
95+
DefaultParameters ModelDefaultParameters `json:"default_parameters"`
96+
ID string `json:"id"`
97+
Links ModelLinks `json:"links"`
98+
Name string `json:"name"`
99+
PerRequestLimits ModelPerRequestLimits `json:"per_request_limits"`
100+
Pricing ModelPricing `json:"pricing"`
101+
SupportedParameters []string `json:"supported_parameters"`
102+
SupportedVoices *[]string `json:"supported_voices"`
103+
TopProvider ModelTopProvider `json:"top_provider"`
104+
Benchmarks *ModelBenchmarks `json:"benchmarks,omitempty"`
105+
Description string `json:"description"`
106+
ExpirationDate *string `json:"expiration_date"`
107+
HuggingFaceID *string `json:"hugging_face_id"`
108+
KnowledgeCutoff *string `json:"knowledge_cutoff"`
109+
Reasoning *ModelReasoning `json:"reasoning,omitempty"`
51110
}
52111

112+
// ListModels lists all models and their properties.
53113
func (c *Client) ListModels(ctx context.Context) (models []Model, err error) {
54114
req, err := c.newRequest(
55115
ctx,
@@ -70,6 +130,7 @@ func (c *Client) ListModels(ctx context.Context) (models []Model, err error) {
70130
return
71131
}
72132

133+
// ListUserModels lists models filtered by user provider preferences, privacy settings and guardrails.
73134
func (c *Client) ListUserModels(ctx context.Context) (models []Model, err error) {
74135
req, err := c.newRequest(
75136
ctx,
@@ -91,7 +152,6 @@ func (c *Client) ListUserModels(ctx context.Context) (models []Model, err error)
91152
}
92153

93154
// ListEmbeddingsModels returns all available embeddings models and their properties.
94-
// API reference: https://openrouter.ai/docs/api/api-reference/embeddings/list-embeddings-models
95155
func (c *Client) ListEmbeddingsModels(ctx context.Context) ([]Model, error) {
96156
req, err := c.newRequest(
97157
ctx,

0 commit comments

Comments
 (0)