Hello,
Has anyone used the Perplexity Agent API with Spring AI?
I am trying to add Perplexity support in embabel . Since /chat/completions/ does not support agent, I have to use v1/agent but then I use the Spring AI’s OpenAI api’s but I ran into the below error.
{
"error": {
"message": "validation failed: input array cannot be empty",
"type": "invalid_request",
"code": 400
}
}
After debugging further, what I understood is, it is because of the request format used by Spring AI.
I can reproduce the same error using the curl if I use the same request format.
curl https://api.perplexity.ai/v1/agent \
-H “Authorization: Bearer $PERPLEXITY_API_KEY” \
-H “Content-Type: application/json” \
-d '{
"model": "perplexity/sonar",
"messages": \[
{"role": "system", "content": "Say OK"},
{"role": "user", "content": "test"}
\],
"temperature": 0.6,
"max_tokens": 100
}’ | jq
For eg: if I change the URL to https://api.perplexity.ai/chat/completions and the model , it works fine. Therefore, the issue is the way currently Spring AI send the request to the Perplexity .
Before digging further into the Spring AI request model, I am wondering whether anyone has really successfully been able to use Spring AI to use the agent API?
Just changing the URL to https://api.perplexity.ai/v1/responses as mentioned in the doc OpenAI Compatibility - Perplexity also did not work.