xai_openapi/models.rs
1//! Model information types for `/v1/models` and related endpoints.
2
3use serde::{Deserialize, Serialize};
4
5use crate::prelude::*;
6
7/// Model information (OpenAI-compatible minimal format).
8#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
9pub struct Model {
10 /// Model ID.
11 pub id: String,
12
13 /// Model creation time in Unix timestamp.
14 pub created: i64,
15
16 /// The object type, which is always `"model"`.
17 pub object: String,
18
19 /// Owner of the model.
20 pub owned_by: String,
21}
22
23/// Details of a language model.
24#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
25pub struct LanguageModel {
26 /// Model ID.
27 pub id: String,
28
29 /// Fingerprint of the xAI system configuration hosting the model.
30 pub fingerprint: String,
31
32 /// Creation time of the model in Unix timestamp.
33 pub created: i64,
34
35 /// The object type, which is always `"model"`.
36 pub object: String,
37
38 /// Owner of the model.
39 pub owned_by: String,
40
41 /// Version of the model.
42 pub version: String,
43
44 /// The input modalities supported by the model, e.g. `"text"`, `"image"`.
45 pub input_modalities: Vec<String>,
46
47 /// The output modalities supported by the model, e.g. `"text"`, `"image"`.
48 pub output_modalities: Vec<String>,
49
50 /// Price of the prompt text token in USD cents per 100 million token.
51 pub prompt_text_token_price: i64,
52
53 /// Price of a prompt text token that was cached previously.
54 pub cached_prompt_text_token_price: i64,
55
56 /// Price of the prompt image token in USD cents per 100 million token.
57 pub prompt_image_token_price: i64,
58
59 /// Price of the completion text token in USD cents per 100 million token.
60 pub completion_text_token_price: i64,
61
62 /// Price of the search in USD cents per 100 million searches.
63 pub search_price: i64,
64
65 /// Alias ID(s) of the model that user can use in a request's model field.
66 pub aliases: Vec<String>,
67}
68
69/// Details of an embedding model.
70#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
71pub struct EmbeddingModel {
72 /// Model ID.
73 pub id: String,
74
75 /// Fingerprint of the xAI system configuration hosting the model.
76 pub fingerprint: String,
77
78 /// Model creation time in Unix timestamp.
79 pub created: i64,
80
81 /// Object type, should be model.
82 pub object: String,
83
84 /// Owner of the model.
85 pub owned_by: String,
86
87 /// Version of the model.
88 pub version: String,
89
90 /// The input modalities supported by the model.
91 pub input_modalities: Vec<String>,
92
93 /// The output modalities supported by the model.
94 #[serde(default)]
95 pub output_modalities: Vec<String>,
96
97 /// Price of the prompt text token in USD cents per million token.
98 pub prompt_text_token_price: i64,
99
100 /// Price of the prompt image token in USD cents per million token.
101 pub prompt_image_token_price: i64,
102
103 /// Alias ID(s) of the model that user can use in a request's model field.
104 pub aliases: Vec<String>,
105}
106
107/// Details of an image generation model.
108#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
109pub struct ImageGenerationModel {
110 /// Model ID.
111 pub id: String,
112
113 /// Fingerprint of the xAI system configuration hosting the model.
114 pub fingerprint: String,
115
116 /// Maximum prompt length.
117 pub max_prompt_length: i64,
118
119 /// Model creation time in Unix timestamp.
120 pub created: i64,
121
122 /// The object type, which is always `"model"`.
123 pub object: String,
124
125 /// Owner of the model.
126 pub owned_by: String,
127
128 /// Version of the model.
129 pub version: String,
130
131 /// The input modalities supported by the model.
132 #[serde(default)]
133 pub input_modalities: Vec<String>,
134
135 /// The output modalities supported by the model.
136 #[serde(default)]
137 pub output_modalities: Vec<String>,
138
139 /// Price of a single image in USD cents.
140 pub image_price: i64,
141
142 /// Alias ID(s) of the model that user can use in a request's model field.
143 pub aliases: Vec<String>,
144}
145
146/// Response listing all models.
147#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
148pub struct ListModelsResponse {
149 /// A list of models with minimalized information.
150 pub data: Vec<Model>,
151
152 /// The object type of `data` field, which is always `"list"`.
153 pub object: String,
154}
155
156/// Response listing all language models.
157#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
158pub struct ListLanguageModelsResponse {
159 /// Array of available language models.
160 pub models: Vec<LanguageModel>,
161}
162
163/// Response listing all embedding models.
164#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
165pub struct ListEmbeddingModelsResponse {
166 /// Array of available embedding models.
167 pub models: Vec<EmbeddingModel>,
168}
169
170/// Response listing all image generation models.
171#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
172pub struct ListImageGenerationModelsResponse {
173 /// Array of available image generation models.
174 pub models: Vec<ImageGenerationModel>,
175}