AI Gateway expects Lua code in a string format. For a short script, write it directly in the Policy’s config:
ai_gateway_policies:
- ref: post-function
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
display_name: Post-Function - Inline Script
name: post-function
type: post-function
config:
access:
- 'kong.log.info("hello world")
'
Make sure to replace the following placeholders with your own values:
AI_GATEWAY_ID: The id of your AI Gateway.
For a longer script, save it to a file and load it into an environment variable:
export FUNCTION_LUA=$(cat function.lua)
Then reference the environment variable in your Post-Function Policy configuration:
ai_gateway_policies:
- ref: post-function
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
display_name: Post-Function - Script From File
name: post-function
type: post-function
config:
access:
- !env FUNCTION_LUA
Make sure to replace the following placeholders with your own values:
AI_GATEWAY_ID: The id of your AI Gateway.