Trawley
Search API

Chat endpoint

A conversational endpoint that answers questions over a scraper's results.

The chat endpoint runs a small agent over a scraper's results. You send a conversation, and it replies in natural language, calling search and aggregation tools internally to ground its answer in real records. It is what powers the in-dashboard "chat with your results" panel.

The chat endpoint is session-authenticated today. Unlike hybrid search and the results endpoint (which are reached by scraper ID), chat requires a logged-in session, so it is currently usable from the Trawley web app rather than as a standalone public API. External programmatic access waits on API authentication (issue #45). For server-to-server natural language querying today, call hybrid search directly.

Request

text
POST https://api.trawley.ai/v1/scrapers/{scraperId}/chat

Body

json
{
  "messages": [
    { "role": "user", "content": "Which listings dropped in price this week?" }
  ]
}

The messages array follows the AI SDK UI message format. The response is a streamed text reply.

What it does under the hood

The endpoint gives its model three tools and lets it choose:

  • search results using hybrid search for "find" and "filter" questions.
  • aggregate results for "how many", "average", "min", and "max" questions.
  • browse results with pagination when no query is needed.

It always grounds answers in tool output rather than inventing data, and returns a readable summary.

If you are building your own chat experience, you usually do not need this endpoint. Wrap hybrid search as a tool in your own agent instead. See the Vercel AI SDK guide for that pattern, which gives you full control over the model and prompt.

What's next