Skip to main content
The images endpoint allows you to search for images using AI to understand and refine your query based on conversation context.

Endpoint

http://localhost:3000/api/images
Replace localhost:3000 with your Perplexica instance URL if running on a different host or port.

Request body

query
string
required
The image search query.
chatModel
object
required
Defines the chat model to be used for understanding and refining the query. Get available providers and models from the /api/providers endpoint.
chatHistory
array
An array of message pairs representing the conversation history. Each pair consists of a role (either human or assistant) and the message content.Example:
[
  ["human", "Show me photos of cats"],
  ["assistant", "Here are some images of cats..."]
]

Response

images
array
A list of image search results. The structure of each image object depends on the search provider’s response format.

Request example

curl -X POST http://localhost:3000/api/images \
  -H "Content-Type: application/json" \
  -d '{
    "query": "golden retriever puppies",
    "chatModel": {
      "providerId": "550e8400-e29b-41d4-a716-446655440000",
      "key": "gpt-4o-mini"
    },
    "chatHistory": []
  }'

Response example

{
  "images": [
    {
      "url": "https://example.com/image1.jpg",
      "title": "Golden Retriever Puppy",
      "thumbnail": "https://example.com/thumb1.jpg"
    },
    {
      "url": "https://example.com/image2.jpg",
      "title": "Cute Golden Retriever Puppies",
      "thumbnail": "https://example.com/thumb2.jpg"
    }
  ]
}
The AI model processes your query and conversation history to refine the search and return more relevant results.

Error responses

500
Internal Server Error
Returned if an error occurs while searching images.

Build docs developers (and LLMs) love