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

# API Reference

> HTTP endpoints, authentication, request bodies, and generated OpenAPI schemas.

## Overview

LLMLayer exposes REST endpoints under `https://api.llmlayer.dev/api/v2`. Authenticate every request with a Bearer token.

```bash theme={null}
Authorization: Bearer YOUR_LLMLAYER_API_KEY
```

<Warning>
  Keep API keys server-side. Do not expose them in browser code.
</Warning>

## Endpoints

<CardGroup cols={2}>
  <Card title="Answer" icon="sparkles" href="/api-reference/endpoint/answer">
    `/api/v2/answer` - web-grounded LLM responses.
  </Card>

  <Card title="Answer Stream" icon="stream" href="/api-reference/endpoint/stream-answer">
    `/api/v2/answer_stream` - Server-Sent Events for streaming answers.
  </Card>

  <Card title="Web Search" icon="magnifying-glass" href="/api-reference/endpoint/web-search">
    `/api/v2/web_search` - raw search results.
  </Card>

  <Card title="Scraper" icon="window" href="/api-reference/endpoint/scrape">
    `/api/v2/scrape` - single-page markdown, HTML, or screenshot extraction.
  </Card>

  <Card title="Extract" icon="wand-magic-sparkles" href="/api-reference/endpoint/extract">
    `/api/v2/extract` - structured data, summaries, Q\&A, links, and brand profiles.
  </Card>

  <Card title="Map" icon="sitemap" href="/api-reference/endpoint/map">
    `/api/v2/map` - website URL discovery.
  </Card>

  <Card title="Crawl" icon="spider" href="/api-reference/endpoint/crawl">
    `/api/v2/crawl_stream` - streamed markdown pages from a website.
  </Card>
</CardGroup>

## First Request

<CodeGroup>
  ```python Python theme={null}
  from llmlayer import LLMLayerClient

  client = LLMLayerClient(api_key="YOUR_LLMLAYER_API_KEY")

  response = client.answer(
      query="What happened in AI today?",
      model="llmlayer-web",
      search_type="news",
      return_sources=True,
  )

  print(response.answer)
  ```

  ```typescript TypeScript theme={null}
  import { LLMLayerClient } from 'llmlayer';

  const client = new LLMLayerClient({
    apiKey: process.env.LLMLAYER_API_KEY,
  });

  const response = await client.answer({
    query: 'What happened in AI today?',
    model: 'llmlayer-web',
    searchType: 'news',
    returnSources: true,
  });

  console.log(response.answer);
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.llmlayer.dev/api/v2/answer \
    -H "Authorization: Bearer YOUR_LLMLAYER_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "query": "What happened in AI today?",
      "model": "llmlayer-web",
      "search_type": "news",
      "return_sources": true
    }'
  ```
</CodeGroup>

## Field Naming

Raw HTTP request bodies use the field names shown in the OpenAPI schemas. The Python SDK follows Python naming conventions for method arguments, and the TypeScript SDK uses `camelCase` for many convenience options.

Examples:

| Raw HTTP            | Python SDK          | TypeScript SDK    |
| ------------------- | ------------------- | ----------------- |
| `return_sources`    | `return_sources`    | `returnSources`   |
| `json_schema`       | `json_schema`       | `jsonSchema`      |
| `main_content_only` | `main_content_only` | `mainContentOnly` |
| `statusCode`        | `statusCode`        | `statusCode`      |
| `structured_data`   | `structured_data`   | `structured_data` |

## Related Guides

<CardGroup cols={2}>
  <Card title="Errors & Refunds" icon="triangle-exclamation" href="/errors">
    Shared error format and refund behavior.
  </Card>

  <Card title="Models and Pricing" icon="dollar-sign" href="/models-pricing">
    Supported model IDs and pricing formulas.
  </Card>
</CardGroup>
