llm server
llm server
The llm server binding accepts inbound LLM API requests from an http server, resolving each request's dialect and optionally authorizing its credentials with a guard, before forwarding it to the exit binding.
llm_server:
type: llm
kind: server
options:
dialect: openai
authorization:
my_api_key_guard:
credentials: "Bearer {credentials}"
exit: llm_proxyConfiguration (* required)
options
object
The server kind llm specific options.
options:
dialect: openai
authorization:
my_api_key_guard:
credentials: "Bearer {credentials}"options.dialect
enum[openai,anthropic,aws-bedrock]
Fixes the dialect assumed for every inbound request, instead of detecting it per request.
The dialects available to the llm binding are:
| Dialect | API | Request path | Credentials header |
|---|---|---|---|
openai | OpenAI Chat Completions | /v1/chat/completions | authorization |
anthropic | Anthropic Messages | /v1/messages | x-api-key |
aws-bedrock ★Zilla Plus | Amazon Bedrock Converse | /model/{modelId}/converse, /model/{modelId}/converse-stream | authorization |
When dialect is omitted, each request is offered to every available dialect, and must be recognized by exactly one of them:
openairecognizes aPOSTto/v1/chat/completionswithcontent-type: application/json, with or without parameters such ascharset.anthropicrecognizes aPOSTto/v1/messages, or any request carrying ananthropic-versionheader, or anx-api-keyheader without anauthorizationheader.aws-bedrock★Zilla Plus recognizes aPOSTto/model/{modelId}/converseor/model/{modelId}/converse-stream.
A request recognized by no dialect, or by more than one, is rejected. When dialect is set to openai or anthropic, the request path and method are not checked. ★Zilla Plus When dialect is set to aws-bedrock, a request that isn't a POST to /model/{modelId}/converse or /model/{modelId}/converse-stream is rejected with 404 Not Found.
Once the dialect is resolved:
- a request whose
content-typeis notapplication/jsonis rejected with415 Unsupported Media Type - an
anthropicrequest must carry theanthropic-version: 2023-06-01header, or it is rejected with400 Bad Request - a request body that can't be parsed is rejected with
400 Bad Request
options.authorization
objectas map of namedobjectproperties
Authorization by a named guard, used to validate the credentials of each inbound request. The credentials are read from the header that the resolved dialect expects them in: authorization for openai, x-api-key for anthropic.
A request whose credentials header is missing, does not match the credentials template, or whose extracted credentials the guard rejects, is rejected with a 401 Unauthorized response, using the dialect's own error body. Once authorized, the guard session is carried to the next binding, where it can satisfy guarded routes and supply outbound credentials to an llm client.
aws-bedrock, the credentials are read from the authorization header, and a rejected request returns 403 Forbidden.authorization:
my_api_key_guard:
credentials: "Bearer {credentials}"authorization.credentials
string| Default:Bearer {credentials}Pattern:.*\\{credentials\\}.*
Template matched against the inbound credentials header, extracting the captured value in place of the required {credentials} placeholder and passing it to the named guard to authorize the request.
The default suits the openai authorization: Bearer <key> header. The anthropic x-api-key header carries the key without a prefix, so set credentials: "{credentials}" for it.
routes
arrayofobject
Routes to the exit binding, selected only by the guarded roles of the inbound request's authorization. The first route whose guarded roles are satisfied is followed. A request that matches no route is rejected.
routes:
- guarded:
my_api_key_guard:
- premium
exit: llm_proxy_premiumroutes[].guarded
objectas map of namedarrayofstring
Roles required by the named guard.
routes:
- guarded:
my_api_key_guard:
- premiumroutes[].exit
string
Next binding when following this route.
routes:
- exit: llm_proxy_premiumexit
string
Default exit binding when no conditional routes are viable.
exit: echo_servertelemetry
object
Defines the desired telemetry for the binding.
telemetry.metrics
array
Telemetry metrics to track
telemetry:
metrics:
- stream.*telemetry.attributes
objectas map of namedstringproperties
Telemetry attributes to add to the binding metrics.
Token usage
A streaming openai request is forwarded with stream_options.include_usage set to true, so that the token usage reported by the upstream LLM server can be recorded by the llm metrics. The final chunk carrying token usage is returned to the caller only when the request itself sets stream_options.include_usage to true.
Errors
Errors are returned in the error body format of the request's dialect, such as {"error":{...}} for openai or {"type":"error","error":{...}} for anthropic. ★Zilla Plus For aws-bedrock, the error type is returned in the x-amzn-errortype header, with a {"message":...} body.
| Status | Cause |
|---|---|
400 Bad Request | The request body can't be parsed, an anthropic request has no supported anthropic-version header, or a request section was rejected by an llm proxy guardrail or cannot be translated to the dialect of the llm client. |
401 Unauthorized | The request's credentials were missing or rejected by the authorization guard. |
403 Forbidden ★Zilla Plus | An aws-bedrock request's credentials were missing or rejected by the authorization guard. |
404 Not Found ★Zilla Plus | An aws-bedrock request isn't a POST to a Converse path. |
415 Unsupported Media Type | The request content-type is not application/json. |
502 Bad Gateway | The upstream LLM server could not be reached. |
| Upstream status | The upstream LLM server rejected the request, for example with 429 Too Many Requests. The upstream error message is preserved, even when translated from a different dialect. |

