> ## Documentation Index
> Fetch the complete documentation index at: https://nvd-54.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google places 集成

> 使用 LangChain JavaScript 集成 Google places tool。

The Google Places Tool allows your agent to utilize the Google Places API in order to find addresses,
phone numbers, website, etc. from text about a location listed on Google Places.

## 设置

You will need to get an API key from [Google here](https://developers.google.com/maps/documentation/places/web-service/overview)
and [enable the new Places API](https://console.cloud.google.com/apis/library/places.googleapis.com). Then, set your API key
as `process.env.GOOGLE_PLACES_API_KEY` or pass it in as an `apiKey` constructor argument.

## 用法

<Tip>
  请参阅[此部分了解安装 LangChain 包的通用说明](/oss/javascript/langchain/install)。
</Tip>

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/openai @langchain/community @langchain/core
```

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { GooglePlacesAPI } from "@langchain/community/tools/google_places";
import { OpenAI } from "@langchain/openai";
import { initializeAgentExecutorWithOptions } from "@langchain/classic/agents";

export async function run() {
  const model = new OpenAI({
    temperature: 0,
  });

  const tools = [new GooglePlacesAPI()];

  const executor = await initializeAgentExecutorWithOptions(tools, model, {
    agentType: "zero-shot-react-description",
    verbose: true,
  });

  const res = await executor.invoke({
    input: "Where is the University of Toronto - Scarborough? ",
  });

  console.log(res.output);
}
```

## 相关内容

* Tool [conceptual guide](/oss/javascript/langchain/tools)
* Tool [how-to guides](/oss/javascript/langchain/tools)

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档连接到](/use-these-docs) Claude、VSCode 等工具，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/tools/google_places.mdx) 或 [提交 issue](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
