Skip to main content
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).
1

Set your key and base URL

export AUTOSAGE_KEY="sk_live_your_key_here"
export AUTOSAGE_URL="https://api.autosage.ai/api/v1"
2

Find your tenant

List the tenants your key can access. Note the id you want to work in.
curl "$AUTOSAGE_URL/tenants" \
  -H "Authorization: Bearer $AUTOSAGE_KEY"
3

Create a knowledge base

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.
4

Upload a document

Uploads are a two-step flow: request a presigned URL, then upload the file straight to storage.
# 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:
curl "$AUTOSAGE_URL/documents/status?document_id=DOCUMENT_ID" \
  -H "Authorization: Bearer $AUTOSAGE_KEY"
See Document ingestion for the full pipeline and supported file types.
5

Create a chat and ask a question

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.
6

Stream the next turn (optional)

For live progress and final answer content, use the streaming endpoint with the chat_id from the previous step:
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 for handling the event stream.

What next

Build an agent

Turn this knowledge base into a reusable, deployable agent.

Serve your end users

Isolate each of your customers with tenants and external subjects.