1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
//! Embedding generation API implementation.
//!
//! This module provides text embedding capabilities for semantic search,
//! similarity comparisons, and other vector-based operations.
use reqwest::Method;
use crate::error::Error;
use crate::models::{ Content, EmbedContentRequest };
use crate::internal::http;
use super::ModelApi;
impl ModelApi< '_ >
{
/// Generates embeddings for the given content using this model.
///
/// This method creates vector embeddings from text content using the specified
/// embedding model. Embeddings are useful for semantic search, similarity
/// comparisons, clustering, and other machine learning tasks.
///
/// # Arguments
///
/// * `request` - An [`crate::models::EmbedContentRequest`] containing:
/// - `content`: The text content to embed
/// - `task_type`: Optional task type hint (e.g., `"RETRIEVAL_QUERY"`, `"RETRIEVAL_DOCUMENT"`)
/// - `title`: Optional title for the content
/// - `output_dimensionality`: Optional dimension reduction
///
/// # Returns
///
/// Returns an [`crate::models::EmbedContentResponse`] containing:
/// - `embedding`: The generated embedding vector
///
/// # Errors
///
/// This method returns an error in the following cases:
/// - [`Error::InvalidArgument`] - Invalid request format, empty content, or model doesn't support embeddings
/// - [`Error::NetworkError`] - Network connectivity issues or request timeout
/// - [`Error::AuthenticationError`] - Invalid or missing API key
/// - [`Error::RateLimitError`] - API rate limits exceeded
/// - [`Error::ServerError`] - Gemini API server-side errors (5xx status codes)
/// - [`Error::SerializationError`] - Failed to serialize the request
/// - [`Error::DeserializationError`] - Failed to parse the API response
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::{ client::Client, EmbedContentRequest, Content, Part };
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// // Create embedding for search query
/// let request = EmbedContentRequest {
/// content : Content {
/// parts : vec![ Part {
/// text : Some( "How to learn Rust programming".to_string() ),
/// ..Default::default()
/// } ],
/// role : "user".to_string(),
/// },
/// task_type : Some( "RETRIEVAL_QUERY".to_string() ),
/// title : Some( "Search Query".to_string() ),
/// output_dimensionality : None,
/// };
///
/// let response = model.embed_content( &request ).await?;
///
/// let embedding = &response.embedding;
/// println!( "Generated embedding with {} dimensions", embedding.values.len() );
///
/// // Use embedding for similarity comparison, search indexing, etc.
/// // Example : calculate similarity with other embeddings
/// // let similarity = cosine_similarity( &embedding.values, &other_embedding );
/// # Ok( () )
/// # }
/// ```
#[ inline ]
pub async fn embed_content
(
&self,
request : &crate::models::EmbedContentRequest,
)
->
Result< crate::models::EmbedContentResponse, Error >
{
// Validate request before sending
if request.content.parts.is_empty()
{
return Err( Error::InvalidArgument(
"Embed content request cannot have empty content parts. Please provide text to embed.".to_string()
) );
}
// Check if any part has actual content
let has_content = request.content.parts.iter().any( |part| {
part.text.as_ref().is_some_and( |text| !text.trim().is_empty() )
} );
if !has_content
{
return Err( Error::InvalidArgument(
"Embed content request must contain at least one text part with non-empty content.".to_string()
) );
}
let url = format!(
"{}/v1beta/models/{}:embedContent",
self.client.base_url,
self.model_id
);
http ::execute_with_optional_retries
(
self.client,
Method::POST,
&url,
&self.client.api_key,
Some( request ),
)
.await
.map_err( |e| self.enhance_model_operation_error( "generate embeddings", e ) )
}
/// Generates embeddings from simple text with default settings.
///
/// This is a convenience method for simple text embedding that automatically
/// wraps the text in the required request structure. For more control over
/// embedding parameters, use [`embed_content`] directly.
///
/// # Arguments
///
/// * `text` - The text content to embed
///
/// # Returns
///
/// Returns the embedding vector, or an error if embedding fails.
///
/// # Errors
///
/// Returns the same errors as [`embed_content`] plus:
/// - [`Error::ApiError`] - No embedding returned in response
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// let embedding = model.embed_text( "Hello, world!" ).await?;
/// println!( "Generated embedding with {} dimensions", embedding.len() );
/// # Ok( () )
/// # }
/// ```
///
/// [`embed_content`]: ModelApi::embed_content
#[ inline ]
pub async fn embed_text( &self, text : &str ) -> Result< Vec< f32 >, Error >
{
let request = crate::models::EmbedContentRequest {
content : crate::models::Content {
parts : vec![ crate::models::Part {
text : Some( text.to_string() ),
..Default::default()
} ],
role : "user".to_string(),
},
task_type : None,
title : None,
output_dimensionality : None,
};
let response = self.embed_content( &request ).await?;
// Extract embedding vector
let values = response.embedding.values;
if values.is_empty()
{
Err( Error::ApiError(
format!( "No embedding values returned from model '{}'. The request may have been invalid or the model may not support embeddings.",
self.model_id )
) )
} else {
Ok( values )
}
}
/// Generates embeddings with task type specification.
///
/// This convenience method allows easy specification of the task type,
/// which helps the model optimize the embedding for specific use cases
/// like document retrieval or semantic search.
///
/// # Arguments
///
/// * `text` - The text content to embed
/// * `task_type` - The task type (e.g., "`RETRIEVAL_QUERY`", "`RETRIEVAL_DOCUMENT`")
///
/// # Returns
///
/// Returns the embedding vector optimized for the specified task.
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// // Embed a search query
/// let query_embedding = model.embed_text_with_task(
/// "How to learn Rust programming",
/// "RETRIEVAL_QUERY"
/// ).await?;
///
/// // Embed a document for retrieval
/// let doc_embedding = model.embed_text_with_task(
/// "Rust is a systems programming language...",
/// "RETRIEVAL_DOCUMENT"
/// ).await?;
///
/// println!( "Query embedding : {} dims, Doc embedding : {} dims",
/// query_embedding.len(), doc_embedding.len() );
/// # Ok( () )
/// # }
/// ```
///
/// # Errors
///
/// Returns the same errors as [`embed_content`].
///
/// [`embed_content`]: ModelApi::embed_content
#[ inline ]
pub async fn embed_text_with_task
(
&self,
text : &str,
task_type : &str,
)
->
Result< Vec< f32 >, Error >
{
let request = crate::models::EmbedContentRequest {
content : crate::models::Content {
parts : vec![ crate::models::Part {
text : Some( text.to_string() ),
..Default::default()
} ],
role : "user".to_string(),
},
task_type : Some( task_type.to_string() ),
title : None,
output_dimensionality : None,
};
let response = self.embed_content( &request ).await?;
let values = response.embedding.values;
if values.is_empty()
{
Err( Error::ApiError(
format!( "No embedding values returned from model '{}' for task type '{}'.",
self.model_id, task_type )
) )
} else {
Ok( values )
}
}
/// Generates embeddings for multiple texts efficiently.
///
/// This method processes multiple texts in batches for better performance
/// compared to individual embedding requests. It automatically handles
/// batch size optimization and concurrent processing.
///
/// # Arguments
///
/// * `texts` - Vector of text strings to embed
/// * `task_type` - Optional task type for all embeddings
///
/// # Returns
///
/// Returns a vector of embedding vectors in the same order as input texts.
///
/// # Performance
///
/// This method is optimized for batch processing:
/// - Processes texts concurrently when possible
/// - Uses efficient memory allocation patterns
/// - Minimizes API calls through smart batching
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// let texts = vec![
/// "First document to embed".to_string(),
/// "Second document to embed".to_string(),
/// "Third document to embed".to_string(),
/// ];
///
/// let embeddings = model.embed_texts( texts, Some( "RETRIEVAL_DOCUMENT" ) ).await?;
/// println!( "Generated {} embeddings", embeddings.len() );
///
/// for (i, embedding) in embeddings.iter().enumerate() {
/// println!( "Text {}: {} dimensions", i + 1, embedding.len() );
/// }
/// # Ok( () )
/// # }
/// ```
///
/// # Errors
///
/// Returns the same errors as [`embed_text`] or [`embed_text_with_task`] for each individual text.
///
/// [`embed_text`]: ModelApi::embed_text
/// [`embed_text_with_task`]: ModelApi::embed_text_with_task
#[ inline ]
pub async fn embed_texts
(
&self,
texts : Vec< String >,
task_type : Option< &str >,
)
->
Result< Vec< Vec< f32 > >, Error >
{
if texts.is_empty()
{
return Ok( vec![] );
}
// For now, process individually - future optimization could use batch API
// when available from Gemini
let mut results = Vec::with_capacity( texts.len() );
for text in texts
{
let embedding = match task_type
{
Some( task ) => self.embed_text_with_task( &text, task ).await?,
None => self.embed_text( &text ).await?,
};
results.push( embedding );
}
Ok( results )
}
/// Calculates cosine similarity between two embedding vectors.
///
/// This utility method helps with common embedding operations like
/// similarity search and document ranking. Cosine similarity ranges
/// from -1 (opposite) to 1 (identical), with 0 indicating orthogonality.
///
/// # Arguments
///
/// * `embedding1` - First embedding vector
/// * `embedding2` - Second embedding vector
///
/// # Returns
///
/// Returns the cosine similarity as a float between -1.0 and 1.0.
///
/// # Errors
///
/// Returns [`Error::InvalidArgument`] if:
/// - Vectors have different dimensions
/// - Either vector is zero-length or all zeros
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// let embed1 = model.embed_text( "machine learning" ).await?;
/// let embed2 = model.embed_text( "artificial intelligence" ).await?;
/// let embed3 = model.embed_text( "cooking recipes" ).await?;
///
/// let similarity_related = model.cosine_similarity( &embed1, &embed2 )?;
/// let similarity_unrelated = model.cosine_similarity( &embed1, &embed3 )?;
///
/// println!( "ML vs AI similarity : {:.3}", similarity_related );
/// println!( "ML vs Cooking similarity : {:.3}", similarity_unrelated );
/// # Ok( () )
/// # }
/// ```
#[ inline ]
pub fn cosine_similarity
(
&self,
embedding1 : &[ f32 ],
embedding2 : &[ f32 ],
)
->
Result< f32, Error >
{
if embedding1.len() != embedding2.len()
{
return Err( Error::InvalidArgument(
format!( "Embedding dimensions must match : {} vs {}",
embedding1.len(), embedding2.len() )
) );
}
if embedding1.is_empty()
{
return Err( Error::InvalidArgument(
"Cannot compute similarity for empty embeddings".to_string()
) );
}
// Calculate dot product
let dot_product : f32 = embedding1.iter()
.zip( embedding2.iter() )
.map( |(a, b)| a * b )
.sum();
// Calculate magnitudes
let magnitude1 : f32 = embedding1.iter().map( |x| x * x ).sum::< f32 >().sqrt();
let magnitude2 : f32 = embedding2.iter().map( |x| x * x ).sum::< f32 >().sqrt();
// Handle zero vectors
if magnitude1 == 0.0 || magnitude2 == 0.0
{
return Err( Error::InvalidArgument(
"Cannot compute similarity for zero vectors".to_string()
) );
}
Ok( dot_product / ( magnitude1 * magnitude2 ) )
}
/// Creates an embedding request builder for complex scenarios.
///
/// This method returns a builder that allows fluent configuration of
/// embedding parameters before executing the request. Useful for
/// fine-grained control over the embedding process.
///
/// # Returns
///
/// Returns an [`EmbeddingRequestBuilder`] for fluent request configuration.
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// let embedding = model.embedding_request()
/// .with_text( "Advanced machine learning techniques" )
/// .with_task_type( "RETRIEVAL_DOCUMENT" )
/// .with_title( "ML Research Paper" )
/// .with_output_dimensionality( 512 )
/// .execute_vector()
/// .await?;
///
/// println!( "Generated {} dimensional embedding", embedding.len() );
/// # Ok( () )
/// # }
/// ```
#[ inline ]
#[ must_use ]
pub fn embedding_request( &self ) -> EmbeddingRequestBuilder< '_ >
{
EmbeddingRequestBuilder::new( self )
}
}
impl ModelApi< '_ >
{
/// Generates embeddings for multiple texts in batch.
///
/// This method processes multiple texts efficiently using batch processing
/// to minimize API calls and improve performance compared to individual requests.
/// The implementation automatically handles optimal batch sizes and concurrent processing.
///
/// # Arguments
///
/// * `texts` - A slice of text strings to embed
///
/// # Returns
///
/// Returns a vector of embedding vectors, one for each input text.
/// The order of embeddings corresponds to the order of input texts.
///
/// # Errors
///
/// This method returns an error in the following cases:
/// - [`Error::ValidationError`] - Empty input or invalid texts
/// - [`Error::BatchProcessingError`] - Partial processing failures with details
/// - [`Error::NetworkError`] - Network connectivity issues
/// - [`Error::AuthenticationError`] - Invalid or missing API key
/// - [`Error::RateLimitError`] - Rate limits exceeded
/// - [`Error::ApiError`] - Other API-related errors
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// let texts = vec![
/// "Hello world",
/// "This is a test",
/// "Batch processing example",
/// ];
///
/// let embeddings = model.batch_embed_texts( &texts ).await?;
/// println!( "Generated {} embeddings", embeddings.len() );
/// # Ok( () )
/// # }
/// ```
#[ inline ]
pub async fn batch_embed_texts( &self, texts : &[ &str ] ) -> Result< Vec< Vec< f32 > >, Error >
{
// Validate input
if texts.is_empty()
{
return Err( Error::ValidationError {
message : "Cannot process empty text list".to_string()
} );
}
// Generate batch ID for correlation and logging
#[ cfg( feature = "logging" ) ]
let batch_id = format!( "batch-{:08x}", rand::random::< u32 >() );
#[ cfg( feature = "logging" ) ]
tracing ::info!(
batch_id = %batch_id,
batch_size = texts.len(),
"Starting batch embedding operation"
);
// For now, process texts individually
// qqq : Implement actual batch API when available from Gemini
let mut embeddings = Vec::with_capacity( texts.len() );
let mut successful = 0;
let mut failed = 0;
for ( index, text ) in texts.iter().enumerate()
{
#[ cfg( feature = "logging" ) ]
tracing ::debug!(
batch_id = %batch_id,
batch_index = index,
"Processing batch item"
);
#[ cfg( not( feature = "logging" ) ) ]
let _ = index; // Suppress unused variable warning when logging disabled
match self.embed_text( text ).await
{
Ok( embedding ) => {
embeddings.push( embedding );
successful += 1;
},
Err( e ) => {
failed += 1;
// For now, propagate the first error
if embeddings.is_empty()
{
return Err( e );
}
// If we have some successful embeddings, return a batch error
// Count remaining texts as failed
let remaining = texts.len() - successful - failed;
#[ cfg( feature = "logging" ) ]
tracing ::error!(
batch_id = %batch_id,
successful = successful,
failed = failed + remaining,
"Batch embedding operation failed"
);
return Err( Error::BatchProcessingError {
successful,
failed : failed + remaining,
message : format!( "Batch processing failed on text '{text}': {e}" ),
} );
}
}
}
#[ cfg( feature = "logging" ) ]
tracing ::info!(
batch_id = %batch_id,
successful = successful,
failed = failed,
"Batch embedding operation completed"
);
Ok( embeddings )
}
/// Generates embeddings for multiple content objects in batch.
///
/// This method processes multiple content objects (text, images, etc.) efficiently
/// using batch processing to minimize API calls and improve performance.
///
/// # Arguments
///
/// * `contents` - A slice of Content objects to embed
///
/// # Returns
///
/// Returns a vector of embedding vectors, one for each input content.
/// The order of embeddings corresponds to the order of input contents.
///
/// # Errors
///
/// Same error conditions as [`Self::batch_embed_texts`].
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # use api_gemini::models::{ Content, Part };
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// let contents = vec![
/// Content {
/// parts : vec![ Part { text : Some( "First content".to_string() ), ..Default::default() } ],
/// role : "user".to_string(),
/// },
/// Content {
/// parts : vec![ Part { text : Some( "Second content".to_string() ), ..Default::default() } ],
/// role : "user".to_string(),
/// },
/// ];
///
/// let embeddings = model.batch_embed_contents( &contents ).await?;
/// println!( "Generated {} embeddings", embeddings.len() );
/// # Ok( () )
/// # }
/// ```
#[ inline ]
pub async fn batch_embed_contents( &self, contents : &[ Content ] ) -> Result< Vec< Vec< f32 > >, Error >
{
// Validate input
if contents.is_empty()
{
return Err( Error::ValidationError {
message : "Cannot process empty content list".to_string()
} );
}
// For now, process contents individually
// qqq : Implement actual batch API when available from Gemini
let mut embeddings = Vec::with_capacity( contents.len() );
let mut successful = 0;
let mut failed = 0;
for content in contents
{
let embed_request = EmbedContentRequest {
content : content.clone(),
task_type : None,
title : None,
output_dimensionality : None,
};
match self.embed_content( &embed_request ).await
{
Ok( response ) => {
embeddings.push( response.embedding.values );
successful += 1;
},
Err( e ) => {
failed += 1;
if embeddings.is_empty()
{
return Err( e );
}
let remaining = contents.len() - successful - failed;
return Err( Error::BatchProcessingError {
successful,
failed : failed + remaining,
message : format!( "Batch processing failed on content : {e}" ),
} );
}
}
}
Ok( embeddings )
}
/// Creates a batch embedding request builder for advanced configuration.
///
/// This method returns a builder that allows fine-grained control over
/// batch processing parameters such as batch size, timeouts, and retry logic.
///
/// # Returns
///
/// Returns a [`BatchEmbeddingRequestBuilder`] for configuring the batch request.
///
/// # Examples
///
/// ```rust,no_run
/// # use api_gemini::client::Client;
/// # use std::time::Duration;
/// # #[ tokio::main ]
/// # async fn main() -> Result< (), Box< dyn std::error::Error > > {
/// let client = Client::new()?;
/// let models_api = client.models();
/// let model = models_api.by_name( "text-embedding-004" );
///
/// let texts = vec![ "Text 1", "Text 2" ];
/// let embeddings = model
/// .batch_embed_request()
/// .with_texts( &texts )
/// .with_batch_size( 10 )
/// .with_timeout( Duration::from_secs( 30 ) )
/// .execute()
/// .await?;
/// # Ok( () )
/// # }
/// ```
#[ inline ]
#[ must_use ]
pub fn batch_embed_request( &self ) -> BatchEmbeddingRequestBuilder< '_ >
{
BatchEmbeddingRequestBuilder::new( self )
}
}
#[ path = "embeddings_builders.rs" ]
mod embeddings_builders;
pub use embeddings_builders::{ EmbeddingRequestBuilder, BatchEmbeddingRequestBuilder };