> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yourouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Search

> Google Custom Search Engine、または YouRouter 既定エンジンで検索します。

**Endpoint:** `GET /customsearch/v1`

`cx` を指定して Google Custom Search を実行します。省略時は YouRouter の既定検索エンジンを使います。

Web の最新情報、社内ドキュメント探索、独自サイト向けの Programmable Search などに使えます。

<Note>
  検索も [ゼロ完了保険](/ja/features/zero-completion-insurance) の対象です。失敗や空結果は成功 completion として課金されません。
</Note>

<CodeGroup>
  ```python Python theme={null}
  import os
  import requests
  import json

  response = requests.get(
      "https://api.yourouter.ai/customsearch/v1",
      headers={"Authorization": f"Bearer {os.environ['YOUROUTER_API_KEY']}"},
      params={
          "q": "how to set up billing",
          "cx": "YOUR_CUSTOM_SEARCH_ENGINE_ID",
          "num": 3
      }
  )
  print(json.dumps(response.json(), indent=2))
  ```

  ```bash cURL theme={null}
  curl "https://api.yourouter.ai/customsearch/v1?q=billing&cx=YOUR_CX_ID" \
    -H "Authorization: Bearer $YOUROUTER_API_KEY"
  ```
</CodeGroup>

### パラメータ

| パラメータ        | 型       | 説明            | 必須  |
| ------------ | ------- | ------------- | --- |
| `q`          | string  | 検索クエリ         | はい  |
| `cx`         | string  | CSE ID。省略時は既定 | いいえ |
| `num`        | integer | 返す件数（1〜10）    | いいえ |
| `start`      | integer | 先頭インデックス      | いいえ |
| `siteSearch` | string  | サイト限定         | いいえ |

<Card title="レスポンス形式" icon="code">
  成功時は `items` 配列に検索結果が入ります。

  ```json theme={null}
  {
    "kind": "customsearch#search",
    "items": [
      {
        "kind": "customsearch#result",
        "title": "Billing Information - Example Docs",
        "link": "https://docs.example-app.ai/billing"
      }
    ]
  }
  ```
</Card>

## 代表的なユースケース

<AccordionGroup>
  <Accordion title="自社ドキュメントの Q&A">
    ドキュメントドメインだけを索引する CSE を作り、検索上位をモデルに渡して根拠付き回答を作れます。
  </Accordion>

  <Accordion title="リアルタイム Web 取得">
    最新記事やページを取得してから要約・推論に回します。
  </Accordion>
</AccordionGroup>
