Backend defines the interface that all Azure AI Gateway backends must implement. Each backend only provides what is unique to its API format. The shared HTTP mechanics (request execution, error handling, streaming fallback) are handled by the Client.
| 34 | // The shared HTTP mechanics (request execution, error handling, streaming fallback) |
| 35 | // are handled by the Client. |
| 36 | type Backend interface { |
| 37 | // ListModels returns the list of models available for this backend |
| 38 | ListModels(context.Context) ([]string, error) |
| 39 | |
| 40 | // BuildEndpoint constructs the full API endpoint URL for the given model |
| 41 | BuildEndpoint(baseURL, model string) string |
| 42 | |
| 43 | // AuthHeader returns the header name and value for authentication. |
| 44 | // Each APIM backend uses a different auth header: |
| 45 | // Bedrock: "Authorization", "Bearer <key>" |
| 46 | // Azure OpenAI: "api-key", "<key>" |
| 47 | // Vertex AI: "x-goog-api-key", "<key>" |
| 48 | AuthHeader() (name, value string) |
| 49 | |
| 50 | // PrepareRequest prepares the HTTP request body for this backend's API format |
| 51 | PrepareRequest(msgs []*chat.ChatCompletionMessage, opts *domain.ChatOptions) ([]byte, error) |
| 52 | |
| 53 | // ParseResponse parses the HTTP response body into text content |
| 54 | ParseResponse(body []byte) (string, error) |
| 55 | } |
| 56 | |
| 57 | // Client implements the Azure AI Gateway vendor for Fabric. |
| 58 | // It supports multiple backends (Bedrock, Azure OpenAI, Vertex AI) through |
no outgoing calls
no test coverage detected