After configuring the Key Authentication plugin, you can verify that it was configured correctly and is working, by sending requests with and without the API key you created for your Consumer.
The following request is valid, as it includes the apikey required by the Consumer:
curl -X POST "http://localhost:8000/anything" \
--no-progress-meter --fail-with-body \
-H "Content-Type: application/json"\
-H "apikey: hello_world"\
-H "Authorization: Bearer $OPENAI_API_KEY" \
--json '{
"tools": [
{
"type": "mcp",
"server_label": "gitmcp",
"server_url": "https://api.githubcopilot.com/mcp/",
"require_approval": "never",
"headers": {
"Authorization": "Bearer '$GITHUB_PAT'"
}
}
],
"input": "How do I use GitHub MCP?"
}'
You should see the following response:
On the following request, include an invalid value for apikey:
curl -X POST "http://localhost:8000/anything" \
--no-progress-meter --fail-with-body \
-H "Content-Type: application/json"\
-H "apikey: another_key"\
-H "Authorization: Bearer $OPENAI_API_KEY" \
--json '{
"tools": [
{
"type": "mcp",
"server_label": "gitmcp",
"server_url": "https://api.githubcopilot.com/mcp/",
"require_approval": "never",
"headers": {
"Authorization": "Bearer '$GITHUB_PAT'"
}
}
],
"input": "How do I use GitHub MCP?"
}'
You should see the following response:
Now, remove the required apikey from the request entirely:
curl -X POST "http://localhost:8000/anything" \
--no-progress-meter --fail-with-body \
-H "Content-Type: application/json"\
-H "Authorization: Bearer $OPENAI_API_KEY" \
--json '{
"tools": [
{
"type": "mcp",
"server_label": "gitmcp",
"server_url": "https://api.githubcopilot.com/mcp/",
"require_approval": "never",
"headers": {
"Authorization": "Bearer '$GITHUB_PAT'"
}
}
],
"input": "How do I use GitHub MCP?"
}'
You should see the following response:
Unauthorized: No API key found in request