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

# 回答 API

> ライブウェブ検索、スクレイピング、クロールに基づくAI回答 — 古いインデックスではありません。

Olostepの`/v1/answers`エンドポイントを通じて、自然言語でウェブを検索し、AIによる回答やデータを希望するJSON形式で返すことができます。これにより、製品を実世界のデータやソースに基づかせたり、データポイントやスプレッドシートを豊かにすることができます。

* 質問をしたり、AIに豊かにしたいデータポイントを提供
* オプション: 希望するJSON構造を指定

これにより:

* ウェブ上でデータを検索し、クリーンアップ、検証して返します
* 回答を生成するために使用されたソースを返します
* データが検証できない場合は`NOT_FOUND`値で不確実性を処理します

APIの詳細については、[回答エンドポイントAPIリファレンス](/api-reference/answers/create)を参照してください。

デフォルトでは、一般的なウェブインデックスとコスト効率の良いLLMバリデーターを使用しています。

エンタープライズ顧客は、独自の業界特化型ウェブインデックス、排他的なプライベートデータ（電話番号やメールを含む）、およびユースケースに最適なカスタムLLMモデルにアクセスできます。アクセスについては、[info@olostep.com](mailto:info@olostep.com)までお問い合わせください。

## ユースケース

回答エンドポイントは以下の用途に使用できます:

* AIアプリケーションを実世界のデータや事実に基づかせる
* 採用、金融、コンサルティング、営業のためにスプレッドシートやデータポイントを豊かにする

以下は、回答エンドポイントによって強化されたAI駆動のスプレッドシートのデモです:
[https://www.olostep.com/demos/spreadsheet-enrich](https://www.olostep.com/demos/spreadsheet-enrich)

## インストール

<CodeGroup>
  ```python Python theme={null}
  pip install olostep
  ```

  ```javascript Node theme={null}
  npm install olostep
  ```

  ```bash cURL theme={null}
  # curlはmacOS、Linux、Windowsでデフォルトで利用可能です
  ```

  ```javascript Node (API) theme={null}
  npm install node-fetch
  ```

  ```bash Python (API) theme={null}
  pip install requests
  ```
</CodeGroup>

## 使用法

質問をして、出力をガイドするためのJSONスキーマを渡します。`json`パラメータを渡さない場合、APIは`result`フィールド内に回答テキストを含むjsonオブジェクトを返します。

<CodeGroup>
  ```python Python theme={null}
  from olostep import Olostep

  client = Olostep(api_key="YOUR_REAL_KEY")

  answer = client.answers.create(
      task="J.K.ローリングの最新の本は何ですか？",
      json_format={"book_title": "", "author": "", "release_date": ""},
  )

  print(answer.json_content)
  print(answer.sources)
  ```

  ```js Node theme={null}
  import Olostep from 'olostep'

  const client = new Olostep({ apiKey: 'YOUR_REAL_KEY' })

  const answer = await client.answers.create({
    task: 'J.K.ローリングの最新の本は何ですか？',
    jsonFormat: { book_title: '', author: '', release_date: '' },
  })

  console.log(answer.json_content)
  console.log(answer.sources)
  ```

  ```bash cURL theme={null}
  curl -s -X POST "https://api.olostep.com/v1/answers" \
    -H "Authorization: Bearer $OLOSTEP_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "task": "J.K.ローリングの最新の本は何ですか？",
      "json": {"book_title": "", "author": "", "release_date": ""}
    }'
  ```

  ```bash CLI theme={null}
  olostep answer "J.K.ローリングの最新の本は何ですか？" \
    --json-format '{"book_title":"","author":"","release_date":""}'
  ```

  ```js Node (API) theme={null}
  const res = await fetch('https://api.olostep.com/v1/answers', {
    method: 'POST',
    headers: { 'Authorization': 'Bearer <YOUR_API_KEY>', 'Content-Type': 'application/json' },
    body: JSON.stringify({
      task: 'J.K.ローリングの最新の本は何ですか？',
      json: { book_title: '', author: '', release_date: '' }
    })
  })
  console.log(await res.json())
  ```

  ```python Python (API) theme={null}
  import requests, json

  endpoint = "https://api.olostep.com/v1/answers"
  payload = {
    "task": "J.K.ローリングの最新の本は何ですか？",
    "json": {"book_title": "", "author": "", "release_date": ""}
  }
  headers = {"Authorization": "Bearer <YOUR_API_KEY>", "Content-Type": "application/json"}

  response = requests.post(endpoint, json=payload, headers=headers)
  print(json.dumps(response.json(), indent=2))
  ```
</CodeGroup>

## レスポンス

他のOlostepエンドポイントと同様に、`answer`オブジェクトがレスポンスとして返されます。`answer`オブジェクトには、`id`や`result`などのプロパティがあります。

```json theme={null}
{
  "id": "answer_9bi0sbj9xa",
  "object": "answer",
  "created": 1760327323,
  "metadata": {},
  "task": "J.K.ローリングの最新の本は何ですか？",
  "result": {
    "json_content": "{\"book_title\":\"The Hallmarked Man\",\"author\":\"J.K. Rowling (as Robert Galbraith)\",\"release_date\":\"2 September 2025\"}",
    "json_hosted_url": "https://olostep-storage.s3.us-east-1.amazonaws.com/answer_9bi0sbj9xa.json",
    "sources": [
      "https://strikefans.com/the-books/",
      "https://www.facebook.com/groups/496943608606523/posts/1136830134617864/",
      "https://robert-galbraith.com/strike-books/",
      "https://www.novelsuspects.com/series-list/robert-galbraith-cormoran-strike-series-in-order/",
      "https://www.reddit.com/r/books/comments/1na833a/jk_rowlings_new_strike_novel_900_pages_of_romance/",
      "https://www.harrypotter.com/writing-by-jk-rowling",
      "https://stories.jkrowling.com/book-news/",
      "https://deadline.com/2024/09/jk-rowling-writing-futuristic-novel-1236093909/",
      "https://www.reddit.com/r/FantasticBeasts/comments/1cl1shn/jk_rowling_may_2024_ive_got_six_more_books_in_my/",
      "https://www.jkrowling.com/news/"
    ]
  }
}
```

リクエストした回答は、`json`パラメータに従ってフォーマットされ、`response.result.json_content`にあり、ソースのリストは`response.result.sources`にあります。構造化データにアクセスするために、文字列化されたJSONを解析することができます。

```json theme={null}
{
  "book_title": "The Hallmarked Man",
  "author": "J.K. Rowling",
  "release_date": "September 2, 2025"
}
```

ソースの例:

```json theme={null}
[
    "https://www.harrypotter.com/writing-by-jk-rowling",
    "https://stories.jkrowling.com/book-news/",
    "https://deadline.com/2024/09/jk-rowling-writing-futuristic-novel-1236093909/",
    "https://www.reddit.com/r/FantasticBeasts/comments/1cl1shn/jk_rowling_may_2024_ive_got_six_more_books_in_my/",
    "https://www.jkrowling.com/news/"
]
```

`json`パラメータを渡さない場合、APIは`result`フィールド内に回答テキストを含むjsonオブジェクトを返します。

```json theme={null}
{
  "result": "J.K.ローリングの最新の本はThe Hallmarked Manです。"
}
```

### 柔軟な`json`パラメータ

* 空の値を持つJSONオブジェクトをスキーマとして提供するか、希望するデータを説明する文字列を提供します。
* エージェントが自信を持てない場合、そのフィールドには`NOT_FOUND`が返されます。

<CodeGroup>
  ```python Python theme={null}
  from olostep import Olostep

  client = Olostep(api_key="YOUR_REAL_KEY")

  answer = client.answers.create(
      task="React 30はいつリリースされますか？",
      json_format={"release_date": ""},
  )

  print(answer.json_content)
  ```

  ```js Node theme={null}
  import Olostep from 'olostep'

  const client = new Olostep({ apiKey: 'YOUR_REAL_KEY' })

  const answer = await client.answers.create({
    task: 'React 30はいつリリースされますか？',
    jsonFormat: { release_date: '' },
  })

  console.log(answer.json_content)
  ```

  ```python Python (API) theme={null}
  import requests, json

  endpoint = "https://api.olostep.com/v1/answers"
  payload = {
    "task": "React 30はいつリリースされますか？", 
    "json": {
      "release_date": ""
    }
  }
  headers = {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json"
  }
  response = requests.post(endpoint, json=payload, headers=headers)
  print(json.dumps(response.json(), indent=2))
  ```

  ```bash CLI theme={null}
  olostep answer "React 30はいつリリースされますか？" --json-format '{"release_date":""}'
  ```
</CodeGroup>

これにより、以下が返されます:

```json theme={null}
{
  "release_date": "NOT_FOUND"
}
```

## 料金

回答は1リクエストあたり20クレジットです。
