Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/protocols/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ pub struct ChatCompletionRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub echo: Option<bool>,

/// Reasoning effort level for reasoning models (low, medium, high)
/// Reasoning effort level supported by OpenAI-compatible vLLM servers.
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option<ReasoningEffort>,

Expand Down Expand Up @@ -855,9 +855,14 @@ fn default_reasoning_effort() -> Option<ReasoningEffort> {
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum ReasoningEffort {
None,
Minimal,
Low,
Medium,
High,
#[serde(rename = "xhigh")]
XHigh,
Max,
}

// ============= Input/Output Items =============
Expand Down
21 changes: 21 additions & 0 deletions tests/test_openai_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,24 @@ async fn test_openai_router_chat_with_reasoning_fields() {
// Verify it's a valid chat completion response
assert_eq!(chat_response["object"], "chat.completion");
}

#[test]
fn reasoning_effort_accepts_current_vllm_values() {
for value in ["none", "minimal", "low", "medium", "high", "xhigh", "max"] {
let request: vllm_router_rs::protocols::spec::ChatCompletionRequest =
serde_json::from_value(serde_json::json!({
"model": "test-model",
"messages": [{"role": "user", "content": "hello"}],
"reasoning_effort": value
}))
.unwrap();
assert_eq!(
serde_json::to_value(request).unwrap()["reasoning_effort"],
value
);

let reasoning: vllm_router_rs::protocols::spec::ResponseReasoningParam =
serde_json::from_value(serde_json::json!({"effort": value})).unwrap();
assert_eq!(serde_json::to_value(reasoning).unwrap()["effort"], value);
}
}