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

# Quickstart

> Provision a knowledge base, upload a document, and run a grounded chat in minutes.

This walkthrough takes you from an API key to a grounded, cited answer. It assumes you have an organization with a default environment and tenant (created automatically when you sign up).

<Steps>
  <Step title="Set your key and base URL">
    ```bash theme={null}
    export AUTOSAGE_KEY="sk_live_your_key_here"
    export AUTOSAGE_URL="https://api.autosage.ai/api/v1"
    ```
  </Step>

  <Step title="Find your tenant">
    List the tenants your key can access. Note the `id` you want to work in.

    ```bash theme={null}
    curl "$AUTOSAGE_URL/tenants" \
      -H "Authorization: Bearer $AUTOSAGE_KEY"
    ```
  </Step>

  <Step title="Create a knowledge base">
    ```bash theme={null}
    curl -X POST "$AUTOSAGE_URL/knowledge-bases" \
      -H "Authorization: Bearer $AUTOSAGE_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "tenant_id": "TENANT_ID",
        "name": "Support docs",
        "description": "Product help center content"
      }'
    ```

    Save the returned knowledge base `id`.
  </Step>

  <Step title="Upload a document">
    Uploads are a two-step flow: request a presigned URL, then upload the file straight to storage.

    ```bash theme={null}
    # 1. Request an upload URL
    curl -X POST "$AUTOSAGE_URL/documents/presign" \
      -H "Authorization: Bearer $AUTOSAGE_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "kb_id": "KB_ID",
        "tenant_id": "TENANT_ID",
        "filename": "handbook.pdf",
        "mime_type": "application/pdf",
        "size_bytes": 482913
      }'

    # 2. Upload the file to the returned upload_url
    curl -X PUT "UPLOAD_URL" \
      -H "Content-Type: application/pdf" \
      --data-binary @handbook.pdf
    ```

    Processing starts automatically once the file lands. Poll status until it is `processed`:

    ```bash theme={null}
    curl "$AUTOSAGE_URL/documents/status?document_id=DOCUMENT_ID" \
      -H "Authorization: Bearer $AUTOSAGE_KEY"
    ```

    <Info>See [Document ingestion](/developers/lifecycles/ingestion) for the full pipeline and supported file types.</Info>
  </Step>

  <Step title="Create a chat and ask a question">
    ```bash theme={null}
    curl -X POST "$AUTOSAGE_URL/chats" \
      -H "Authorization: Bearer $AUTOSAGE_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "id": "CHAT_UUID",
        "tenant_id": "TENANT_ID",
        "knowledge_base_id": "KB_ID",
        "model": "MODEL_ID",
        "message": "What is our refund window?"
      }'
    ```

    The response includes the assistant's grounded answer, the source passages it cited, and usage information.
  </Step>

  <Step title="Stream the next turn (optional)">
    For live progress and final answer content, use the streaming endpoint with the `chat_id` from the previous step:

    ```bash theme={null}
    curl -N -X POST "$AUTOSAGE_URL/chats/CHAT_ID/messages/stream" \
      -H "Authorization: Bearer $AUTOSAGE_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "content": "And how do I start a return?",
        "model": "MODEL_ID"
      }'
    ```

    See [Chat & streaming](/developers/guides/chat-and-stream) for handling the event stream.
  </Step>
</Steps>

## What next

<CardGroup cols={2}>
  <Card title="Build an agent" icon="robot" href="/developers/guides/build-an-agent">
    Turn this knowledge base into a reusable, deployable agent.
  </Card>

  <Card title="Serve your end users" icon="users" href="/developers/concepts/tenancy">
    Isolate each of your customers with tenants and external subjects.
  </Card>
</CardGroup>
