This repository contains practical examples demonstrating various features and use cases of Kong API Gateway.
- AI Image Generation - OpenAI DALL-E 3 & Whisper integration
- AI Prompt Compressor - LLM prompt optimization & compression
- Kafka HTTP Mediation - HTTP β Kafka protocol mediation
- Kafka SSE with Authentication - Kafka SSE streaming with OIDC
- Kafka Schema Validation - Event gateway with schema registry
- Solace HTTP Mediation - HTTP β Solace PubSub+ messaging
- Request Callout - API enrichment with backend services
Each example is self-contained and includes:
- Complete configuration files
- Docker Compose setup
- Detailed documentation
- Step-by-step instructions
- Testing procedures
General requirements for all examples:
- Docker
- Docker Compose
- curl (for testing)
- Kong Enterprise license (for enterprise features)
Demonstrates how to use Kong's Request Callout plugin to enrich API requests with data from multiple backend services.
Key Features:
- Sequential API calls
- Request/response transformation
- Mock backend services
- Data enrichment patterns
Technologies:
- Kong Request Callout plugin
- Kong Mocking plugin
- OpenAPI specifications
Shows how to use Kong API Gateway to mediate between HTTP and Kafka protocols.
Key Features:
- HTTP to Kafka message production
- Kafka to HTTP consumption
- Server-Sent Events (SSE) streaming
- Synchronous and asynchronous patterns
Technologies:
- Kong Kafka Upstream plugin
- Kong Kafka Consumer plugin
- Apache Kafka
- Server-Sent Events
Demonstrates how to consume Kafka messages via Server-Sent Events (SSE) with OpenID Connect (OIDC) authentication.
Key Features:
- Kafka message consumption via SSE
- OIDC authentication integration
- Keycloak for identity management
Technologies:
- Kong Kafka Consumer plugin
- Kong OIDC plugin
- Apache Kafka
- Server-Sent Events
Demonstrates how to use Kong Gateway as an event gateway with Kafka integration, including schema validation using a Schema Registry.
Key Features:
- Kafka message production with schema validation
- Multiple consumption patterns (REST and SSE)
- Schema Registry integration
- Avro and JSON schema support
Technologies:
- Kong Kafka plugins
- Apache Kafka
- Apicurio Schema Registry (Confluent-compatible)
- Avro schemas
Demonstrates how to use Kong's AI Proxy Advanced plugin to create an AI gateway for image generation and audio transcription services.
Key Features:
- OpenAI DALL-E 3 image generation
- OpenAI Whisper audio transcription
- AI request routing and load balancing
- Token counting and latency optimization
- Request/response logging
Technologies:
- Kong AI Proxy Advanced plugin
- OpenAI API (DALL-E 3, Whisper)
- AI request balancing and retries
- CORS support
Shows how to use Kong's AI Prompt Compressor plugin to optimize LLM requests by compressing prompts while maintaining semantic meaning.
Key Features:
- Intelligent prompt compression
- Token-based compression strategies
- LLM request optimization
- Configurable compression ranges
- Integration with local LLM models
Technologies:
- Kong AI Prompt Compressor plugin
- Kong AI Proxy Advanced plugin
- LLMlingua compression service
- Local LLM models (Qwen2.5)
Demonstrates how to use Kong API Gateway to mediate between HTTP and Solace PubSub+ messaging.
Key Features:
- HTTP to Solace message production
- Queue-based messaging patterns
- Message transformation and routing
- Persistent message delivery
- Authentication integration
Technologies:
- Kong Solace Upstream plugin
- Solace PubSub+ Standard
- Message queues and topics
- Basic authentication
- Clone this repository:
git clone https://github.com/your-username/kong-examples.git
cd kong-examples
- Set up your Kong Enterprise license:
export KONG_LICENSE_DATA='{"license":{"version":1,...}}'
- Choose an example and follow its specific README instructions.
kong-api-gw-examples/
βββ README.md
βββ ai-image-generation/
β βββ README.md
β βββ docker-compose.yaml
β βββ docker-compose.ee.yaml
β βββ kong-config/
β β βββ kong.yaml
β βββ ee.env
β βββ konnect.env
βββ ai-prompt-compressor/
β βββ README.md
β βββ docker-compose.yaml
β βββ docker-compose.ee.yaml
β βββ kong-config/
β β βββ kong.yaml
β βββ ee.env
β βββ konnect.env
βββ kafka-http-mediation/
β βββ README.md
β βββ docker-compose.yaml
β βββ kong-config/
β βββ kong.yaml
βββ kafka-schema-validation/
β βββ README.md
β βββ docker-compose.yaml
β βββ docker-compose.ee.yaml
β βββ kong-config/
β β βββ kong.yaml
β βββ avro-schema.json
β βββ json-schema.json
βββ kafka-sse-with-auth/
β βββ README.md
β βββ docker-compose.yaml
β βββ kong-config/
β β βββ kong.yaml
β βββ realm-export.json
βββ request-callout/
β βββ README.md
β βββ docker-compose.yaml
β βββ kong-config/
β β βββ kong.yaml
β βββ mock-api.yaml
βββ solace-http-mediation/
βββ README.md
βββ docker-compose.yaml
βββ docker-compose.ee.yaml
βββ kong-config/
β βββ kong.yaml
βββ ee.env
βββ konnect.env
Contributions are welcome! Please feel free to submit a Pull Request.
When adding a new example:
- Create a new directory with a descriptive name
- Include a comprehensive README
- Provide all necessary configuration files
- Add the example to this main README
- Ensure all code is well-documented
This project is licensed under the Apache 2.0 License.