Appearance
curl walkthrough
Upload a document, wait for it to be ready, then ask a question and print the answer with its source files.
Before you start
Bash, curl and jq. Create a Read & write API key in the console.
Set these environment variables. Keep the API key private.
bash
export LAB0_API_KEY='lab0_sk_replace_with_your_key'
export LAB0_BASE_URL='https://app.lab0.ai/app'
export LAB0_NAMESPACE='quickstart'Save a document
Save the following as plan.md, or download it:
md
# Plan
The rollout uses quillfeather checklists.The example uploads this file by default. Set LAB0_FILE_PATH to use another path, and change the prompt to match its contents.
Upload, wait and ask
Save this as quickstart.sh, or download the example.
sh
#!/usr/bin/env bash
set -euo pipefail
: "${LAB0_API_KEY:?Set LAB0_API_KEY to a Read & write key}"
base="${LAB0_BASE_URL:-https://app.lab0.ai/app}"
base="${base%/}"
namespace="${LAB0_NAMESPACE:-quickstart}"
file="${LAB0_FILE_PATH:-plan.md}"
request() {
curl --fail-with-body --silent --show-error --max-time 200 \
--header "Authorization: Bearer $LAB0_API_KEY" "$@"
}
uploaded="$(request --form "file=@$file" --form "namespace=$namespace" \
"$base/api/knowledge/files")"
file_id="$(printf '%s' "$uploaded" | jq -er '.id')"
ready=false
for ((attempt = 0; attempt < 90; attempt++)); do
document="$(request "$base/api/knowledge/files/$file_id")"
status="$(printf '%s' "$document" | jq -r '.status')"
if [[ "$status" == ready ]]; then ready=true; break; fi
if [[ "$status" == failed ]]; then
printf '%s' "$document" | jq -r '.error' >&2
exit 1
fi
sleep 2
done
if [[ "$ready" != true ]]; then
echo "Processing timed out; inspect file $file_id before trying again." >&2
exit 1
fi
body="$(jq -n --arg namespace "$namespace" --arg file "$file_id" \
'{prompt:"How is the rollout run?",namespace:$namespace,file_ids:[$file]}')"
request --header 'Content-Type: application/json' --data "$body" \
"$base/api/knowledge/respond" | jq .Run it from the directory containing plan.md:
bash
bash quickstart.shThe example stops on an HTTP error, a failed upload or a processing timeout. Once the file is ready, it asks “How is the rollout run?” using only the uploaded file.
Read the result
A successful response contains answer, sources and model. The document says that the rollout uses quillfeather checklists; verify that the answer reflects that and that sources identifies plan.md. Exact wording and the model name can vary.
The file stays in your namespace for later questions. See cleanup when you finish, or continue with streaming answers and the API reference.