The Mocking Policy allows you to provide mock endpoints to test APIs in development against your existing services. You provide an api_specification with either Swagger 2.0 or OpenAPI 3.0. When the Mocking Policy matches an incoming request against a path and method defined in the spec, it returns response examples. When using the Mocking Policy, AI Gateway never contacts the upstream AI Model Provider.
The Policy lets you test an AI Gateway’s configuration against realistic responses without spending tokens. You can attach the Policy to an AI Model and give it an API specification describing that AI Model’s route, for example POST /v1/chat/completions with a provider-shaped response example. The Policy matches the full request path, so the spec path must include the AI Model’s route path. You can also attach the Policy to an AI MCP Server, an AI Agent, or an AI Consumer, or apply it globally.
Mocked responses carry an X-Kong-Mocking-Plugin: true response header, so a client can tell a mock from a real completion.