Skip to main content

normalize_base_url

Function normalize_base_url 

Source
pub fn normalize_base_url(raw: &str) -> Result<String, ProviderError>
Expand description

Trims a base URL to what mentra’s transports expect.

They append v1/chat/completions, v1/responses and v1/models themselves, but every gateway publishes its URL with /v1 on the end, because that is the form the OpenAI SDKs take. Pasting the published URL would otherwise produce /v1/v1/… and a puzzling 404, so strip a trailing /v1 here rather than making each user discover the difference.

One rule for both wires, which is what keeps “paste the URL as published” true whichever one RuntimeBuilder::with_wire selects: they differ in the path they append, never in the base they append it to.