Expand description
The byte-level model splice.
The request body is never deserialized: the splice finds the
top-level "model" key, optionally replaces its string value, and
fixes Content-Length. Everything else - tool schemas, betas,
context_management - passes through byte for byte, which is the
whole reason the gateway forwards instead of re-encoding.
Enumsยง
- Splice
Error - Why a body could not be spliced. Both are loud by design: a splice that silently forwarded the wrong model would be worse than a failure naming the session.
Functionsยง
- find_
top_ ๐level_ model - Locate the top-level
"model"string value: its byte span (excluding the quotes) and its content. Scans with a string/escape state machine so a"model"that is only a nested key or a value elsewhere is skipped. - read_
string ๐ - Read a JSON string starting at
start(the opening quote). Returns the raw content bytes and the index just past the closing quote. - skip_ws ๐
- splice_
model - Extract the top-level
modelstring and, whenreplacementisSome, rewrite it in place. Returns the (possibly new) body and the extracted model. Nested"model"keys are never touched: only a string key at brace depth 1 counts. - unescape ๐
- Model names are plain ASCII slugs in practice; unescape the two escapes that could appear around them and reject exotic ones rather than misreporting the name.
Type Aliasesยง
- Model
Span ๐ - The located top-level model: its byte span (excluding the quotes) and its content.