Connection
Base URL, credentials and a reachable server.
Reject invalid name characters, line breaks, controls and non-ASCII input, allowing an empty value without creating an extra header.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
import re
TOKEN = re.compile(r"[!#$%&'*+.^_`|~0-9A-Za-z-]+")
def header_line(name, value):
if not isinstance(name, str) or not TOKEN.fullmatch(name):
raise ValueError("header name")
if not isinstance(value, str) or any(not 32 <= ord(c) <= 126 for c in value):
raise ValueError("ASCII header value")
return name + ": " + value