Kgateway Backend API

Define routable backends such as AI providers (OpenAI, Azure, Gemini), AWS Lambda functions, or static servers for use by Gateways. Reference Backend resources in HTTPRoute to route traffic to external services.

OpenAPI Specification

kgateway-backend-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: kgateway Kubernetes Gateway AIBackend Backend API
  description: kgateway is the most widely deployed gateway in Kubernetes for microservices and AI agents. It is a feature-rich, fast, and flexible Kubernetes-native ingress controller and next-generation API gateway built on top of Envoy proxy and the Kubernetes Gateway API. kgateway provides custom resource definitions (CRDs) under the gateway.kgateway.dev API group for configuring traffic policies, backends, direct responses, gateway extensions, gateway parameters, HTTP listener policies, and AI backends. These resources are managed through the Kubernetes API server.
  version: 2.1.0
  contact:
    name: kgateway
    url: https://kgateway.dev
  license:
    name: Apache 2.0
    url: https://github.com/kgateway-dev/kgateway/blob/main/LICENSE
servers:
- url: https://{kubernetes-api-server}/apis/gateway.kgateway.dev/v1alpha1
  description: Kubernetes API Server - kgateway Custom Resources
  variables:
    kubernetes-api-server:
      default: kubernetes.default.svc
      description: The Kubernetes API server hostname
security:
- BearerAuth: []
tags:
- name: Backend
  description: Define routable backends such as AI providers (OpenAI, Azure, Gemini), AWS Lambda functions, or static servers for use by Gateways. Reference Backend resources in HTTPRoute to route traffic to external services.
paths:
  /namespaces/{namespace}/backends:
    get:
      operationId: listBackends
      summary: Kgateway List Backend resources
      description: List all Backend resources in the specified namespace. Backends define routable external services such as AI providers, AWS Lambda functions, or static servers.
      tags:
      - Backend
      parameters:
      - $ref: '#/components/parameters/Namespace'
      - $ref: '#/components/parameters/LabelSelector'
      - $ref: '#/components/parameters/Limit'
      - $ref: '#/components/parameters/Continue'
      responses:
        '200':
          description: Successfully retrieved list of Backend resources.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BackendList'
        '401':
          description: Unauthorized
    post:
      operationId: createBackend
      summary: Kgateway Create a Backend
      description: Create a Backend resource to define a routable backend such as an AI provider, AWS Lambda function, or static server.
      tags:
      - Backend
      parameters:
      - $ref: '#/components/parameters/Namespace'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Backend'
      responses:
        '201':
          description: Successfully created Backend.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Backend'
        '401':
          description: Unauthorized
        '409':
          description: Conflict - resource already exists
  /namespaces/{namespace}/backends/{name}:
    get:
      operationId: getBackend
      summary: Kgateway Get a Backend
      description: Retrieve a specific Backend resource by name and namespace.
      tags:
      - Backend
      parameters:
      - $ref: '#/components/parameters/Namespace'
      - $ref: '#/components/parameters/Name'
      responses:
        '200':
          description: Successfully retrieved Backend.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Backend'
        '401':
          description: Unauthorized
        '404':
          description: Backend not found
    put:
      operationId: replaceBackend
      summary: Kgateway Replace a Backend
      description: Replace a specific Backend resource.
      tags:
      - Backend
      parameters:
      - $ref: '#/components/parameters/Namespace'
      - $ref: '#/components/parameters/Name'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Backend'
      responses:
        '200':
          description: Successfully replaced Backend.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Backend'
        '401':
          description: Unauthorized
        '404':
          description: Backend not found
    delete:
      operationId: deleteBackend
      summary: Kgateway Delete a Backend
      description: Delete a specific Backend resource.
      tags:
      - Backend
      parameters:
      - $ref: '#/components/parameters/Namespace'
      - $ref: '#/components/parameters/Name'
      responses:
        '200':
          description: Successfully deleted Backend.
        '401':
          description: Unauthorized
        '404':
          description: Backend not found
components:
  schemas:
    Backend:
      type: object
      description: Backend defines a routable backend such as an AI provider, AWS Lambda function, or static server for use by Gateways.
      properties:
        apiVersion:
          type: string
          enum:
          - gateway.kgateway.dev/v1alpha1
        kind:
          type: string
          enum:
          - Backend
        metadata:
          $ref: '#/components/schemas/ObjectMeta'
        spec:
          type: object
          description: BackendSpec defines the desired state of a Backend.
          properties:
            type:
              type: string
              description: Type of the backend.
              enum:
              - Static
              - AWS
              - AI
            static:
              type: object
              description: Static backend configuration.
              properties:
                hosts:
                  type: array
                  description: List of static hosts.
                  items:
                    type: object
                    properties:
                      host:
                        type: string
                        description: Hostname or IP address.
                      port:
                        type: integer
                        description: Port number.
                      tls:
                        type: object
                        description: TLS configuration for the host.
                        properties:
                          sni:
                            type: string
            aws:
              type: object
              description: AWS Lambda backend configuration.
              properties:
                region:
                  type: string
                  description: AWS region.
                lambdaFunctionName:
                  type: string
                  description: Name of the AWS Lambda function.
                accountId:
                  type: string
                  description: AWS account ID.
                roleArn:
                  type: string
                  description: ARN of the IAM role to assume.
            ai:
              type: object
              description: AI provider backend configuration.
              properties:
                provider:
                  type: object
                  description: Configuration for the LLM provider.
                  properties:
                    type:
                      type: string
                      enum:
                      - openai
                      - azure
                      - gemini
                      - mistral
                    openai:
                      type: object
                      properties:
                        authToken:
                          type: object
                          properties:
                            secretRef:
                              type: object
                              properties:
                                name:
                                  type: string
                                namespace:
                                  type: string
                    azure:
                      type: object
                      properties:
                        endpoint:
                          type: string
                        deploymentName:
                          type: string
                        apiVersion:
                          type: string
                        authToken:
                          type: object
                          properties:
                            secretRef:
                              type: object
                              properties:
                                name:
                                  type: string
                                namespace:
                                  type: string
                    gemini:
                      type: object
                      properties:
                        authToken:
                          type: object
                          properties:
                            secretRef:
                              type: object
                              properties:
                                name:
                                  type: string
                                namespace:
                                  type: string
        status:
          type: object
          description: Status of the Backend.
          properties:
            conditions:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                  status:
                    type: string
                  reason:
                    type: string
                  message:
                    type: string
                  lastTransitionTime:
                    type: string
                    format: date-time
    ObjectMeta:
      type: object
      description: Standard Kubernetes object metadata.
      properties:
        name:
          type: string
          description: Name of the resource.
        namespace:
          type: string
          description: Namespace of the resource.
        labels:
          type: object
          additionalProperties:
            type: string
          description: Map of string keys and values for organizing resources.
        annotations:
          type: object
          additionalProperties:
            type: string
          description: Annotations for storing arbitrary metadata.
        resourceVersion:
          type: string
          description: An opaque value that represents the internal version of this object.
        creationTimestamp:
          type: string
          format: date-time
          description: Timestamp representing the server time when this object was created.
    BackendList:
      type: object
      description: List of Backend resources.
      properties:
        apiVersion:
          type: string
        kind:
          type: string
          enum:
          - BackendList
        metadata:
          type: object
          properties:
            continue:
              type: string
            resourceVersion:
              type: string
        items:
          type: array
          items:
            $ref: '#/components/schemas/Backend'
  parameters:
    Name:
      name: name
      in: path
      required: true
      description: The name of the resource.
      schema:
        type: string
    Namespace:
      name: namespace
      in: path
      required: true
      description: The Kubernetes namespace.
      schema:
        type: string
    Limit:
      name: limit
      in: query
      required: false
      description: Maximum number of resources to return.
      schema:
        type: integer
    Continue:
      name: continue
      in: query
      required: false
      description: Continue token for paginated list requests.
      schema:
        type: string
    LabelSelector:
      name: labelSelector
      in: query
      required: false
      description: A selector to restrict the list of returned objects by labels.
      schema:
        type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Kubernetes API bearer token authentication. Use a service account token or kubeconfig token.
externalDocs:
  description: kgateway API Reference Documentation
  url: https://kgateway.dev/docs/envoy/latest/reference/api/