Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): 3.5.0
Describe the issue:
Following the documentation on Register agent - OpenSearch Documentation I have registered an agent:
POST /_plugins/_ml/agents/_register
{
"name": "opensearch agent",
"type": "conversational",
"description": "Test conversational agent",
"model": {
"model_id": "gemini-2.5-pro",
"model_provider": "gemini/v1beta/generatecontent",
"credentials": {
"api_key": "xyz"
},
"parameters": {
"system_prompt": "You are an expert data analyst with access to OpenSearch indices"
}
},
"tools": [
{
"type": "ListIndexTool"
},
{
"type": "SearchIndexTool"
}
],
"memory": {
"type": "conversation_index"
}
}
But when testing it:
POST /_plugins/_ml/agents/TmMRQJ0Ba60ZVyos9x8l/_execute
{
"input": "What tools do you have access to?"
}
It returns the following error:
{
"status": 400,
"error": {
"type": "OpenSearchStatusException",
"reason": "Invalid Request",
"details": "Error from remote service: {\n \"error\": {\n \"code\": 400,\n \"message\": \"API key not valid. Please pass a valid API key.\",\n \"status\": \"INVALID_ARGUMENT\",\n \"details\": [\n {\n \"@type\": \"type.googleapis.com/google.rpc.ErrorInfo\",\n \"reason\": \"API_KEY_INVALID\",\n \"domain\": \"googleapis.com\",\n \"metadata\": {\n \"service\": \"generativelanguage.googleapis.com\"\n }\n },\n {\n \"@type\": \"type.googleapis.com/google.rpc.LocalizedMessage\",\n \"locale\": \"en-US\",\n \"message\": \"API key not valid. Please pass a valid API key.\"\n }\n ]\n }\n}\n"
}
}
The API key I’m using is correct, it’s working when used in another tool.