The Policy serves messages on the Route of the entity it’s attached to. Reference it from the policies array on an AI Model, AI Agent, or AI MCP Server that defines config.route, then send requests to that path. A global Kafka Consume Policy runs on every AI Gateway Route, so requests only reach it where a Route already exists.
In http-get mode, send a GET request to the path with no query parameters. The Policy returns the records available for every topic in config.topics, keyed by topic name and then by partition:
{
"ai-events": {
"partitions": {
"0": {
"high_watermark": 1,
"last_stable_offset": 1,
"errcode": 0,
"records": [
{
"value": {"event": "prompt_received", "model": "gpt-4o"},
"key": "",
"timestamp": 1787305085262,
"offset": 0
}
],
"aborted_transactions": {}
}
}
}
}
Each entry in records carries the message value, key, timestamp, and offset. When config.message_deserializer is json, value is a parsed object. When it’s noop, value is the raw message as a string.
Which records a request returns depends on config.auto_offset_reset. When it’s set to latest (default), it returns only messages produced after the Policy started consuming. earliest returns messages from the beginning of the topic.
Responses aren’t immediate. A request can take several seconds to return, even when records are already available on the topic.