Thank you very much for the quick response and for adding the image search feature to the Agent API. I really appreciate you and the team taking the feedback into consideration and implementing it so quickly.
I’ll give it a try right away. This is exactly the functionality I was looking for.
Thanks again to you and the team for your support!
Even if you specify multiple tools like this, only one of them will be used.
Consequently, the output will only contain the results from that single tool.
★For the SONAR model:
By specifying return_images=True,
it was possible to return both citation URLs and image URLs.
Even if you specify multiple tools like this, only one of them will be used.
Consequently, the output will only contain the results from that single tool.
★For the SONAR model:
By specifying return_images=True,
it was possible to return both citation URLs and image URLs.
The Agent API can run both web_search and image_search in the same response. I tested the configuration below, and both tools ran in all nine tests.
Please try this with your query. It explicitly asks the model to use both tools and gives it enough steps to complete the searches:
from perplexity import Perplexity
client = Perplexity()
response = client.responses.create(
model="openai/gpt-6-luna",
input=query,
instructions=(
"Use web_search to find sources for the answer. "
"Also use image_search to find relevant images. "
"Call both tools before answering. Cite the web sources."
),
tools=[
{"type": "web_search"},
{"type": "image_search", "max_results": 5},
],
max_steps=4,
)
print(response.output_text)
for item in response.output:
if item.type == "image_search_results":
for image in item.results:
print(image.image_url, image.origin_url)
Unlike Sonar’s top-level images field, Agent API image URLs appear in image_search_results items within response.output, separately from the answer text (image-search guide). Your application should still handle empty image results or tool failures.
When requesting lengthy output for a complex query using the “fast” preset, setting max_steps=1 resulted in the output containing only one of the two—either the citation URL or the image URL—rather than both.
However, when I set max_steps=2, the output included both the citation URL and the image URL.