Skip to content

Documentation v1.0.0


Documentation / @openassistant/places / placeSearch

Variable: placeSearch

const placeSearch: OpenAssistantTool<typeof placeSearchParameters, PlaceSearchLlmResult, PlaceSearchAdditionalData, FoursquareToolContext>

Defined in: packages/tools/places/src/placeSearch.ts:319

Place Search Tool

This tool searches for places using the Foursquare Places API. It can search for places by name, category, or other criteria within a specified location or area.

TIP

If you don't know the coordinates of the location, you can use the geocoding tool to get it.

Example user prompts:

  • "Find coffee shops near Times Square"
  • "Search for restaurants within 2km of the Eiffel Tower"
  • "What are the best rated hotels in San Francisco?"
  • "Find gas stations near me"
  • "Find open restaurants now"
  • "Find expensive restaurants in Manhattan"

Example

typescript
import { placeSearch, PlaceSearchTool } from "@openassistant/places";
import { convertToVercelAiTool, ToolCache } from '@openassistant/utils';
import { generateText } from 'ai';

// you can use ToolCache to save the place search dataset for later use
const toolResultCache = ToolCache.getInstance();

const placeSearchTool: PlaceSearchTool = {
  ...placeSearch,
  toolContext: {
    getFsqToken: () => process.env.FSQ_TOKEN!,
  },
  onToolCompleted: (toolCallId, additionalData) => {
    toolResultCache.addDataset(toolCallId, additionalData);
  },
};

generateText({
  model: openai('gpt-4.1', { apiKey: key }),
  prompt: 'Find coffee shops near Times Square',
  tools: {
    placeSearch: convertToVercelAiTool(placeSearchTool),
  },
});

For a more complete example, see the Places Tools Example using Next.js + Vercel AI SDK.

Released under the MIT License.