litellm-rs 0.4.16

A high-performance AI Gateway written in Rust, providing OpenAI-compatible APIs with intelligent routing, load balancing, and enterprise features
Documentation
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
//! Runway ML Provider Implementation
//!
//! Main provider implementation for Runway ML video and image generation.

use futures::Stream;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use std::pin::Pin;
use std::sync::Arc;

use crate::core::providers::base::{
    GlobalPoolManager, HeaderPair, HttpMethod, get_pricing_db, header,
};
use crate::core::providers::unified_provider::ProviderError;
use crate::core::traits::{
    error_mapper::trait_def::ErrorMapper, provider::ProviderConfig,
    provider::llm_provider::trait_definition::LLMProvider,
};
use crate::core::types::{
    chat::ChatRequest,
    context::RequestContext,
    health::HealthStatus,
    image::ImageGenerationRequest,
    model::ModelInfo,
    model::ProviderCapability,
    responses::{ChatChunk, ChatResponse, ImageData, ImageGenerationResponse},
};

use super::{RunwayMLConfig, RunwayMLErrorMapper, get_runwayml_registry};

const PROVIDER_NAME: &str = "runwayml";

/// Runway ML task status
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum TaskStatus {
    /// Task is pending
    Pending,
    /// Task is in the queue
    Throttled,
    /// Task is running
    Running,
    /// Task completed successfully
    Succeeded,
    /// Task failed
    Failed,
    /// Task was cancelled
    Cancelled,
}

/// Runway ML task request
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateTaskRequest {
    /// The model to use (e.g., "gen3a_turbo")
    pub model: String,
    /// Text prompt for generation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prompt_text: Option<String>,
    /// Image URL for image-to-video
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prompt_image: Option<String>,
    /// Video duration in seconds (5 or 10)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<u32>,
    /// Aspect ratio
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ratio: Option<String>,
    /// Seed for reproducibility
    #[serde(skip_serializing_if = "Option::is_none")]
    pub seed: Option<u64>,
    /// Whether to watermark the output
    #[serde(skip_serializing_if = "Option::is_none")]
    pub watermark: Option<bool>,
}

/// Runway ML task response
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TaskResponse {
    /// Task ID
    pub id: String,
    /// Task status
    pub status: TaskStatus,
    /// Creation timestamp
    #[serde(default)]
    pub created_at: Option<String>,
    /// Output URLs (available when succeeded)
    #[serde(default)]
    pub output: Option<Vec<String>>,
    /// Error message (if failed)
    #[serde(default)]
    pub failure: Option<String>,
    /// Failure code
    #[serde(default)]
    pub failure_code: Option<String>,
    /// Progress percentage
    #[serde(default)]
    pub progress: Option<f32>,
}

/// Runway ML video generation response
#[derive(Debug, Clone)]
pub struct VideoGenerationResponse {
    /// Task ID
    pub task_id: String,
    /// Video URLs
    pub video_urls: Vec<String>,
    /// Generation duration
    pub duration_seconds: u32,
}

/// Runway ML provider implementation
#[derive(Debug, Clone)]
pub struct RunwayMLProvider {
    config: RunwayMLConfig,
    pool_manager: Arc<GlobalPoolManager>,
    supported_models: Vec<ModelInfo>,
}

impl RunwayMLProvider {
    /// Create a new Runway ML provider
    pub fn new(config: RunwayMLConfig) -> Result<Self, ProviderError> {
        config
            .validate()
            .map_err(|e| ProviderError::configuration(PROVIDER_NAME, e))?;

        let pool_manager = Arc::new(
            GlobalPoolManager::new()
                .map_err(|e| ProviderError::configuration(PROVIDER_NAME, e.to_string()))?,
        );

        let supported_models = get_runwayml_registry().models().to_vec();

        Ok(Self {
            config,
            pool_manager,
            supported_models,
        })
    }

    /// Create provider with API key
    pub async fn with_api_key(api_key: impl Into<String>) -> Result<Self, ProviderError> {
        let config = RunwayMLConfig::new(api_key);
        Self::new(config)
    }

    /// Create provider from environment
    pub fn from_env() -> Result<Self, ProviderError> {
        let config = RunwayMLConfig::from_env();
        Self::new(config)
    }

    /// Generate headers for Runway ML API requests
    fn get_request_headers(&self) -> Vec<HeaderPair> {
        let mut headers = Vec::with_capacity(3);

        if let Some(api_key) = &self.config.base.api_key {
            headers.push(header("Authorization", format!("Bearer {}", api_key)));
        }

        headers.push(header("Content-Type", "application/json".to_string()));
        headers.push(header("Accept", "application/json".to_string()));

        // Add API version header if specified
        if let Some(api_version) = &self.config.base.api_version {
            headers.push(header("X-Runway-Version", api_version.clone()));
        }

        headers
    }

    /// Create a video generation task
    pub async fn create_video_task(
        &self,
        prompt_text: Option<String>,
        prompt_image: Option<String>,
        model: Option<&str>,
        duration: Option<u32>,
        ratio: Option<String>,
        seed: Option<u64>,
    ) -> Result<TaskResponse, ProviderError> {
        let api_model = model
            .map(|m| get_runwayml_registry().get_api_model(m))
            .unwrap_or("gen3a_turbo");

        let request = CreateTaskRequest {
            model: api_model.to_string(),
            prompt_text,
            prompt_image,
            duration: duration.or(Some(self.config.default_video_duration)),
            ratio,
            seed,
            watermark: Some(self.config.watermark),
        };

        self.submit_task(&request).await
    }

    /// Submit a task to Runway ML
    async fn submit_task(
        &self,
        request: &CreateTaskRequest,
    ) -> Result<TaskResponse, ProviderError> {
        let url = self.config.get_generate_url();
        let headers = self.get_request_headers();
        let body = serde_json::to_value(request)
            .map_err(|e| ProviderError::serialization(PROVIDER_NAME, e.to_string()))?;

        let response = self
            .pool_manager
            .execute_request(&url, HttpMethod::POST, headers, Some(body))
            .await?;

        let status = response.status();
        let response_bytes = response
            .bytes()
            .await
            .map_err(|e| ProviderError::network(PROVIDER_NAME, e.to_string()))?;

        if !status.is_success() {
            let error_text = String::from_utf8_lossy(&response_bytes);
            let mapper = RunwayMLErrorMapper;
            return Err(mapper.map_http_error(status.as_u16(), &error_text));
        }

        serde_json::from_slice(&response_bytes)
            .map_err(|e| ProviderError::response_parsing(PROVIDER_NAME, e.to_string()))
    }

    /// Get task status
    async fn get_task(&self, task_id: &str) -> Result<TaskResponse, ProviderError> {
        let url = self.config.get_task_url(task_id);
        let headers = self.get_request_headers();

        let response = self
            .pool_manager
            .execute_request(&url, HttpMethod::GET, headers, None)
            .await?;

        let status = response.status();
        let response_bytes = response
            .bytes()
            .await
            .map_err(|e| ProviderError::network(PROVIDER_NAME, e.to_string()))?;

        if !status.is_success() {
            let error_text = String::from_utf8_lossy(&response_bytes);
            let mapper = RunwayMLErrorMapper;
            return Err(mapper.map_http_error(status.as_u16(), &error_text));
        }

        serde_json::from_slice(&response_bytes)
            .map_err(|e| ProviderError::response_parsing(PROVIDER_NAME, e.to_string()))
    }

    /// Poll task until completion
    async fn poll_task(&self, task_id: &str) -> Result<TaskResponse, ProviderError> {
        let polling_delay = std::time::Duration::from_secs(self.config.polling_delay_seconds);

        for _ in 0..self.config.polling_retries {
            tokio::time::sleep(polling_delay).await;

            let task = self.get_task(task_id).await?;

            match task.status {
                TaskStatus::Succeeded => return Ok(task),
                TaskStatus::Failed => {
                    let error_msg = task.failure.unwrap_or_else(|| "Task failed".to_string());
                    return Err(ProviderError::api_error(
                        PROVIDER_NAME,
                        500,
                        format!("Video generation failed: {}", error_msg),
                    ));
                }
                TaskStatus::Cancelled => {
                    return Err(ProviderError::cancelled(
                        PROVIDER_NAME,
                        "video_generation",
                        Some("Task was cancelled".to_string()),
                    ));
                }
                _ => {
                    // Still processing, continue polling
                }
            }
        }

        Err(ProviderError::timeout(
            PROVIDER_NAME,
            "Maximum retries exceeded waiting for video generation",
        ))
    }

    /// Create video task and wait for completion
    pub async fn generate_video(
        &self,
        prompt_text: Option<String>,
        prompt_image: Option<String>,
        model: Option<&str>,
        duration: Option<u32>,
        ratio: Option<String>,
        seed: Option<u64>,
    ) -> Result<VideoGenerationResponse, ProviderError> {
        // Create the task
        let task = self
            .create_video_task(prompt_text, prompt_image, model, duration, ratio, seed)
            .await?;

        // Poll until completion
        let completed_task = self.poll_task(&task.id).await?;

        // Extract video URLs
        let video_urls = completed_task.output.unwrap_or_default();

        Ok(VideoGenerationResponse {
            task_id: completed_task.id,
            video_urls,
            duration_seconds: duration.unwrap_or(self.config.default_video_duration),
        })
    }

    /// Transform image generation request to video generation
    fn transform_image_to_video_request(
        &self,
        request: &ImageGenerationRequest,
    ) -> CreateTaskRequest {
        let registry = get_runwayml_registry();
        let model = request.model.as_deref().unwrap_or("gen3a_turbo");
        let api_model = registry.get_api_model(model);

        // Map size to aspect ratio
        let ratio = request.size.as_ref().map(|size| {
            match size.as_str() {
                "1024x1024" | "512x512" => "1:1",
                "1792x1024" | "1280x720" => "16:9",
                "1024x1792" | "720x1280" => "9:16",
                "1280x768" => "5:3",
                "768x1280" => "3:5",
                _ => "16:9", // Default to 16:9
            }
            .to_string()
        });

        CreateTaskRequest {
            model: api_model.to_string(),
            prompt_text: Some(request.prompt.clone()),
            prompt_image: None,
            duration: Some(self.config.default_video_duration),
            ratio,
            seed: None,
            watermark: Some(self.config.watermark),
        }
    }

    /// Transform video response to image generation response
    fn transform_video_to_image_response(
        &self,
        video_response: VideoGenerationResponse,
    ) -> ImageGenerationResponse {
        let data: Vec<ImageData> = video_response
            .video_urls
            .into_iter()
            .map(|url| ImageData {
                url: Some(url),
                b64_json: None,
                revised_prompt: None,
            })
            .collect();

        ImageGenerationResponse {
            created: chrono::Utc::now().timestamp() as u64,
            data,
        }
    }
}

impl LLMProvider for RunwayMLProvider {
    fn name(&self) -> &'static str {
        PROVIDER_NAME
    }

    fn capabilities(&self) -> &'static [ProviderCapability] {
        &[ProviderCapability::ImageGeneration]
    }

    fn models(&self) -> &[ModelInfo] {
        &self.supported_models
    }

    fn get_supported_openai_params(&self, _model: &str) -> &'static [&'static str] {
        &["model", "prompt", "size", "n"]
    }

    async fn map_openai_params(
        &self,
        params: HashMap<String, Value>,
        _model: &str,
    ) -> Result<HashMap<String, Value>, ProviderError> {
        let mut mapped = HashMap::new();

        for (key, value) in params {
            match key.as_str() {
                "size" => {
                    // Map OpenAI size to Runway ratio
                    if let Some(size_str) = value.as_str() {
                        let ratio = match size_str {
                            "1024x1024" | "512x512" => "1:1",
                            "1792x1024" | "1280x720" => "16:9",
                            "1024x1792" | "720x1280" => "9:16",
                            _ => "16:9",
                        };
                        mapped.insert("ratio".to_string(), Value::String(ratio.to_string()));
                    }
                }
                "n" => {
                    // Runway generates one video at a time
                    // Store for reference but don't pass to API
                    mapped.insert("_n".to_string(), value);
                }
                _ => {
                    mapped.insert(key, value);
                }
            }
        }

        Ok(mapped)
    }

    async fn transform_request(
        &self,
        _request: ChatRequest,
        _context: RequestContext,
    ) -> Result<Value, ProviderError> {
        // Runway ML is primarily for video/image generation, not chat
        Err(ProviderError::not_supported(
            PROVIDER_NAME,
            "Chat completion is not supported by Runway ML. Use image_generation for video generation.",
        ))
    }

    async fn transform_response(
        &self,
        _raw_response: &[u8],
        _model: &str,
        _request_id: &str,
    ) -> Result<ChatResponse, ProviderError> {
        Err(ProviderError::not_supported(
            PROVIDER_NAME,
            "Chat completion is not supported by Runway ML",
        ))
    }

    fn get_error_mapper(&self) -> Box<dyn ErrorMapper<ProviderError>> {
        Box::new(RunwayMLErrorMapper)
    }

    async fn chat_completion(
        &self,
        _request: ChatRequest,
        _context: RequestContext,
    ) -> Result<ChatResponse, ProviderError> {
        Err(ProviderError::not_supported(
            PROVIDER_NAME,
            "Chat completion is not supported by Runway ML. Use image_generation for video generation.",
        ))
    }

    async fn chat_completion_stream(
        &self,
        _request: ChatRequest,
        _context: RequestContext,
    ) -> Result<Pin<Box<dyn Stream<Item = Result<ChatChunk, ProviderError>> + Send>>, ProviderError>
    {
        Err(ProviderError::not_supported(
            PROVIDER_NAME,
            "Streaming is not supported by Runway ML",
        ))
    }

    async fn image_generation(
        &self,
        request: ImageGenerationRequest,
        _context: RequestContext,
    ) -> Result<ImageGenerationResponse, ProviderError> {
        let task_request = self.transform_image_to_video_request(&request);

        // Submit the task
        let task = self.submit_task(&task_request).await?;

        // Poll until completion
        let completed_task = self.poll_task(&task.id).await?;

        // Build response
        let video_urls = completed_task.output.unwrap_or_default();
        let video_response = VideoGenerationResponse {
            task_id: completed_task.id,
            video_urls,
            duration_seconds: self.config.default_video_duration,
        };

        Ok(self.transform_video_to_image_response(video_response))
    }

    async fn health_check(&self) -> HealthStatus {
        if self.config.base.api_key.is_some() {
            HealthStatus::Healthy
        } else {
            HealthStatus::Unhealthy
        }
    }

    async fn calculate_cost(
        &self,
        model: &str,
        input_tokens: u32,
        output_tokens: u32,
    ) -> Result<f64, ProviderError> {
        // Runway pricing is per-second of video, not per token
        // Use pricing database for estimation if available
        let usage = crate::core::providers::base::pricing::Usage {
            prompt_tokens: input_tokens,
            completion_tokens: output_tokens,
            total_tokens: input_tokens + output_tokens,
            reasoning_tokens: None,
        };

        Ok(get_pricing_db().calculate(model, &usage))
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_provider_creation_without_api_key() {
        let config = RunwayMLConfig::default();
        let result = RunwayMLProvider::new(config);
        assert!(result.is_err());
    }

    #[test]
    fn test_provider_creation_with_api_key() {
        let config = RunwayMLConfig::new("test-api-key");
        let result = RunwayMLProvider::new(config);
        assert!(result.is_ok());
    }

    #[test]
    fn test_provider_name() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();
        assert_eq!(provider.name(), PROVIDER_NAME);
    }

    #[test]
    fn test_provider_capabilities() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();
        let capabilities = provider.capabilities();
        assert!(capabilities.contains(&ProviderCapability::ImageGeneration));
    }

    #[test]
    fn test_provider_models() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();
        let models = provider.models();
        assert!(!models.is_empty());
    }

    #[test]
    fn test_get_request_headers() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();
        let headers = provider.get_request_headers();

        assert!(headers.iter().any(|h| h.0 == "Authorization"));
        assert!(headers.iter().any(|h| h.0 == "Content-Type"));
    }

    #[test]
    fn test_transform_image_to_video_request() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();

        let request = ImageGenerationRequest {
            prompt: "A beautiful sunset over the ocean".to_string(),
            model: Some("gen3a_turbo".to_string()),
            n: Some(1),
            size: Some("1792x1024".to_string()),
            quality: None,
            response_format: None,
            style: None,
            user: None,
        };

        let task_request = provider.transform_image_to_video_request(&request);

        assert_eq!(task_request.model, "gen3a_turbo");
        assert_eq!(
            task_request.prompt_text,
            Some("A beautiful sunset over the ocean".to_string())
        );
        assert_eq!(task_request.ratio, Some("16:9".to_string()));
        assert_eq!(task_request.duration, Some(5));
    }

    #[test]
    fn test_transform_video_to_image_response() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();

        let video_response = VideoGenerationResponse {
            task_id: "task-123".to_string(),
            video_urls: vec!["https://example.com/video.mp4".to_string()],
            duration_seconds: 5,
        };

        let response = provider.transform_video_to_image_response(video_response);

        assert_eq!(response.data.len(), 1);
        assert!(response.data[0].url.is_some());
    }

    #[test]
    fn test_supported_openai_params() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();
        let params = provider.get_supported_openai_params("gen3a_turbo");

        assert!(params.contains(&"prompt"));
        assert!(params.contains(&"size"));
    }

    #[tokio::test]
    async fn test_chat_completion_not_supported() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();

        let request = ChatRequest {
            model: "gen3a_turbo".to_string(),
            messages: vec![],
            ..Default::default()
        };

        let context = RequestContext::default();
        let result = provider.chat_completion(request, context).await;

        assert!(result.is_err());
        assert!(matches!(
            result.unwrap_err(),
            ProviderError::NotSupported { .. }
        ));
    }

    #[test]
    fn test_health_check_with_api_key() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();

        let rt = tokio::runtime::Runtime::new().unwrap();
        let health = rt.block_on(provider.health_check());
        assert_eq!(health, HealthStatus::Healthy);
    }

    #[test]
    fn test_from_env_missing_api_key() {
        // Clear any existing env var
        unsafe {
            std::env::remove_var("RUNWAYML_API_KEY");
        }

        let result = RunwayMLProvider::from_env();
        assert!(result.is_err());
    }

    #[test]
    fn test_create_task_request_serialization() {
        let request = CreateTaskRequest {
            model: "gen3a_turbo".to_string(),
            prompt_text: Some("A cat playing piano".to_string()),
            prompt_image: None,
            duration: Some(5),
            ratio: Some("16:9".to_string()),
            seed: None,
            watermark: Some(false),
        };

        let json = serde_json::to_value(&request).unwrap();
        assert_eq!(json["model"], "gen3a_turbo");
        assert_eq!(json["promptText"], "A cat playing piano");
        assert_eq!(json["duration"], 5);
        assert_eq!(json["ratio"], "16:9");
    }

    #[test]
    fn test_task_status_deserialization() {
        let json =
            r#"{"id":"task-123","status":"SUCCEEDED","output":["https://example.com/video.mp4"]}"#;
        let task: TaskResponse = serde_json::from_str(json).unwrap();
        assert_eq!(task.status, TaskStatus::Succeeded);
        assert_eq!(task.output.unwrap().len(), 1);
    }

    #[tokio::test]
    async fn test_map_openai_params() {
        let config = RunwayMLConfig::new("test-api-key");
        let provider = RunwayMLProvider::new(config).unwrap();

        let mut params = HashMap::new();
        params.insert("size".to_string(), serde_json::json!("1792x1024"));
        params.insert("n".to_string(), serde_json::json!(1));

        let mapped = provider
            .map_openai_params(params, "gen3a_turbo")
            .await
            .unwrap();

        assert!(mapped.contains_key("ratio"));
        assert_eq!(mapped.get("ratio").unwrap(), "16:9");
    }
}