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

# Quickstart

> Get a search result in under 5 minutes.

## 1. Get your API key

Create one from the **API Keys** section of the [console](https://console.lighton.ai) and copy it. You will not see it again. Then set it as an environment variable:

```bash theme={null}
export LIGHTON_API_KEY=your_api_key_here
```

See [Authentication](/authentication) for more on key management.

## 2. Upload a document

<CodeGroup>
  ```python Python SDK theme={null}
  from lighton import File, LightOn, Workspace

  workspace_id = 42  # replace with your workspace ID

  with LightOn() as client:  # reads LIGHTON_API_KEY from the environment
      workspace = Workspace.get(client, workspace_id)
      doc = workspace.ingest(File(path="handbook.pdf"))
      print(doc.id, doc.status)
  ```

  ```python Plain Python theme={null}
  import os
  import requests

  workspace_id = 42  # replace with your workspace ID
  headers = {"Authorization": f"Bearer {os.environ['LIGHTON_API_KEY']}"}

  with open("handbook.pdf", "rb") as f:
      response = requests.post(
          "https://api.lighton.ai/api/v3/files",
          headers=headers,
          data={"workspace_id": workspace_id},
          files={"file": f},
      )
  print(response.json())
  ```
</CodeGroup>

The response returns the new file with its `id` and a `status` of `pending`:

```json theme={null}
{"id": 12345, "status": "pending", "workspace_id": 42}
```

Indexing takes a few seconds. Poll until `status` is `embedded`:

<CodeGroup>
  ```python Python SDK theme={null}
  from lighton import File, LightOn

  file_id = 1234  # the ID returned by the upload above

  with LightOn() as client:
      doc = File.get(client, file_id)
      doc.wait()  # polls until ingestion reaches a terminal status
      print(doc.status)
  ```

  ```python Plain Python theme={null}
  import os
  import time
  import requests

  file_id = 1234  # the ID returned by the upload above
  headers = {"Authorization": f"Bearer {os.environ['LIGHTON_API_KEY']}"}

  for _ in range(60):  # give up after ~2 minutes
      response = requests.get(
          f"https://api.lighton.ai/api/v3/files/{file_id}",
          headers=headers,
      )
      status = response.json()["status"]
      if status == "embedded":
          break
      time.sleep(2)
  print(status)
  ```
</CodeGroup>

## 3. Search it

<CodeGroup>
  ```python Python SDK theme={null}
  from lighton import LightOn

  workspace_id = 42  # replace with your workspace ID

  with LightOn() as client:
      response = client.search(
          "What is the vacation policy at LightOn?",
          workspaces=[workspace_id],
          max_results=3,
      )
      for result in response.results:
          source = result.source
          print(f"[p.{source.page_start}–{source.page_end}, score={result.score:.2f}]")
          print(result.content[:120])
          print()
  ```

  ```python Plain Python theme={null}
  import os
  import requests

  workspace_id = 42  # replace with your workspace ID
  headers = {"Authorization": f"Bearer {os.environ['LIGHTON_API_KEY']}"}

  response = requests.post(
      "https://api.lighton.ai/api/v3/search",
      headers=headers,
      json={
          "query": "What is the vacation policy at LightOn?",
          "workspace_id": [workspace_id],
          "max_results": 3,
      },
  )
  for result in response.json()["results"]:
      print(f"[p.{result['source']['page_start']}–{result['source']['page_end']}, score={result['score']:.2f}]")
      print(result["content"][:120])
      print()
  ```
</CodeGroup>

```
[p.4–4, score=0.94]
Employees are entitled to 25 days of paid leave per year...

[p.4–4, score=0.87]
Unused vacation days carry over up to a maximum of 10 days...

[p.7–7, score=0.71]
Public holidays are in addition to the annual leave entitlement...
```

Three API calls: upload, wait, search. That's the full pipeline.

<Card title="Next: Authentication" icon="key" href="/authentication">
  Learn how API keys work and how to handle auth errors.
</Card>
