pub fn parse_openai_request(
body: &[u8],
carry_raw: bool,
) -> Option<ModelRequest>Expand description
Parse an OpenAI Chat Completions request body into the normalized ModelRequest.
carry_raw: when true (all-OpenAI-dialect ladder), the original JSON is stored in
raw for verbatim carry — only the model is swapped, every other field survives intact.
When false (translation path to Anthropic ladder), raw is Null so
anthropic_wire_body reconstructs from the translated normalized fields.
Returns None if:
- the body isn’t valid JSON or lacks a
messagesarray, OR - a user message contains an
image_urlwith an http(s) URL (non-translatable; caller should have already fallen back viaenforce_can_handlebut this is a defense-in-depth guard —None→BadRequestrather than silently dropping the image).