Response language
Bayle renders error messages in English or Brazilian Portuguese. Successful responses carry generated content, which is unaffected by this: it is only error prose that gets translated.
Asking for a language
Section titled “Asking for a language”Send Accept-Language. A tag beginning with the two letters pt, in any case, selects Brazilian
Portuguese. Anything else, including no header at all, selects English.
curl https://api.bayle.ai/embeddings \ -H "Authorization: Bearer bad-key" \ -H "Accept-Language: pt-BR" \ -H "Content-Type: application/json" \ -d '{"model": "bad-model-id", "input": "hello"}'{ "error": { "message": "Sua chave de API da Bayle está ausente ou não pôde ser verificada.", "type": "authentication_error", "param": null, "code": "invalid_api_key" }}The tag may appear anywhere in a multi-tag header, so fr-FR;q=0.9,pt;q=0.5,en;q=0.3 selects
Portuguese. Quality values are accepted but ignored: this is a presence check for a pt-prefixed
tag, not weighted negotiation. pt, pt-BR, and pt-PT all select the same Brazilian
Portuguese messages.
Knowing which language you got
Section titled “Knowing which language you got”Every response carries Content-Language, either en or pt-BR, on success and error alike. You
can read it without parsing message text.
curl -sD - https://api.bayle.ai/models -o /dev/null | grep -i content-languageOn a streaming chat completion the header is committed alongside the initial 200, before the
outcome is known, so it is present whichever way the stream ends. An error event arriving
mid-stream is rendered in the language negotiated at the start of the request.
Don’t match on message text
Section titled “Don’t match on message text”Because message is translated, code that matches on it works until someone changes a header.
Branch on error.code, which is stable across both languages. See Errors.