Skip to main content
Kong API Gateway is a cloud-native API gateway that provides powerful traffic management, security, and observability features. When combined with Cerebras’s ultra-fast inference, Kong enables you to build scalable, secure AI applications with advanced routing, authentication, and monitoring capabilities.

Prerequisites

Quick Start

This guide uses Kong Konnect (cloud-managed) with a local data plane for testing. All commands are copy-paste ready.
1

Get your Cerebras API Key

  1. Go to https://cloud.cerebras.ai
  2. Sign in or create an account
  3. Navigate to API Keys in the dashboard
  4. Click Create API Key
  5. Copy the key (starts with csk-)
2

Generate Kong Konnect Personal Access Token

  1. Sign in to Kong Konnect
  2. Click your profile icon (top-right corner)
  3. Select Personal Access Tokens
  4. Click Generate Token
  5. Give it a name like cerebras-integration
  6. Click Generate
  7. Copy the token immediately (starts with kpat_)
3

Set up environment variables

Export your API keys:
4

Install decK

Install decK (Kong’s configuration tool):
5

Deploy Kong Gateway

Run Kong’s quickstart script to deploy a local data plane connected to Konnect:
This script:
  • Creates a control plane in Konnect
  • Deploys a local Kong Gateway data plane using Docker
  • Configures everything to work together
Wait for the script to complete. You should see confirmation that Kong Gateway is running.
6

Create Gateway Service and Route

Create a service and route for Cerebras:
7

Configure AI Proxy Plugin

Add the AI Proxy plugin to route traffic to Cerebras:
8

Test your integration

Send a test request:
You should receive a response from Cerebras routed through Kong!

What’s Happening?

  1. Kong Gateway runs locally in Docker (port 8000)
  2. Kong Konnect manages the control plane in the cloud
  3. AI Proxy plugin intercepts requests to /chat and routes them to Cerebras
  4. Your Cerebras API key is securely injected by the plugin
  5. Responses flow back through Kong to your client

Using Different Models

To use a different Cerebras model, update the plugin configuration:

Advanced Configuration

Using Different Cerebras Models

Kong’s AI Proxy plugin supports all Cerebras models. Simply update the model configuration:

Benefits of Using Kong with Cerebras

  • Centralized Management: Manage all AI API traffic through a single gateway
  • Security: Add authentication, rate limiting, and IP whitelisting
  • Observability: Monitor request patterns, latency, and errors
  • Load Balancing: Distribute traffic across multiple Cerebras endpoints
  • Caching: Reduce costs and improve response times with intelligent caching
  • Transformation: Modify requests and responses without changing your application code

Available Models

Kong AI Proxy supports all Cerebras models: Update the model.name field in your Kong configuration to switch between models.

Troubleshooting

This usually indicates an issue with your Cerebras API key configuration:
  1. Verify your CEREBRAS_API_KEY environment variable is set correctly
  2. Check that the API key is valid and active in your Cerebras dashboard
  3. Ensure the header value format is correct: Bearer YOUR_API_KEY
  4. Test direct Cerebras API access to isolate the issue:
Enable debug logging in Kong to troubleshoot plugin issues:
Common issues to check:
  • Plugin is enabled and properly configured
  • Environment variables are correctly set
  • Service and route configurations match
  • Upstream connectivity to Cerebras API
Yes! Kong’s AI Proxy plugin fully supports streaming responses from Cerebras. Simply include "stream": true in your request:
The streaming response will be passed through Kong in real-time, maintaining the low latency benefits of Cerebras inference.
Kong provides several ways to monitor your Cerebras API usage:
  1. Kong Vitals: Built-in analytics for request metrics
  2. Prometheus Metrics: Export metrics for monitoring systems
  3. Custom Logging: Configure detailed request/response logging
  4. Datadog Integration: Send metrics and logs to Datadog
Example Prometheus metrics setup:
Access metrics at: http://localhost:8001/metrics

Next Steps

Additional Resources