guidellm.backends.openai.common
Shared helpers for OpenAI-compatible HTTP and WebSocket backends.
build_headers(api_key, existing_headers=None)
Build headers with bearer authentication for OpenAI-compatible requests.
Merges the Authorization bearer token (if api_key is set) with any existing headers. User-provided headers take precedence over the bearer token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key | SecretStr | str | None | Optional API key for Bearer authentication | required |
existing_headers | dict[str, str] | None | Optional headers to merge in | None |
Returns:
| Type | Description |
|---|---|
dict[str, str] | None | Headers dict, or |
Source code in src/guidellm/backends/openai/common.py
format_ws_error(err)
Format a WebSocket error payload into a human-readable message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
err | Any | Error value from a realtime | required |
Returns:
| Type | Description |
|---|---|
str | Message suitable for :class: |
Source code in src/guidellm/backends/openai/common.py
resolve_validate_kwargs(validate_backend, target, api_routes)
Build httpx request keyword arguments from backend validation settings.
validate_backend may be False/equivalent (skip validation), True (default GET against the /health route key), a route key present in api_routes (resolved to {target}/{path}), a full URL string, or a dict that includes url and optionally method (default GET).
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None | Keyword arguments suitable for |