curl
Test your agentgateway Kubernetes deployment using curl.
Before you begin
Get the gateway URL
export INGRESS_GW_ADDRESS=$(kubectl get svc -n agentgateway-system agentgateway-proxy \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo "Gateway address: $INGRESS_GW_ADDRESS"export INGRESS_GW_ADDRESS=$(kubectl get svc -n agentgateway-system agentgateway-proxy \
-o jsonpath='{.status.loadBalancer.ingress[0].hostname}')
echo "Gateway address: $INGRESS_GW_ADDRESS"After port-forwarding, the gateway is accessible at http://localhost:8080. Use localhost:8080 wherever the instructions reference $INGRESS_GW_ADDRESS.
kubectl port-forward -n agentgateway-system svc/agentgateway-proxy 8080:80Send a request
Replace <route-path> with the path configured in your HTTPRoute (for example, /openai).
curl "http://$INGRESS_GW_ADDRESS/<route-path>" \
-H "content-type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "Hello from Kubernetes!"}
]
}' | jqExample output:
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 11,
"completion_tokens": 10,
"total_tokens": 21
}
}Authentication
If agentgateway requires authentication, include an Authorization header.
curl "http://$INGRESS_GW_ADDRESS/<route-path>" \
-H "content-type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}]
}' | jq