--- title: Copilot emoji: 📊 colorFrom: gray colorTo: pink sdk: docker pinned: false --- ## Required Secret This app requires two secrets at startup. Set one of these Hugging Face Space Secrets: - `GH_TOKEN` (preferred) - `GITHUB_TOKEN` (fallback) - `API_TOKEN` (required for incoming API requests) The container will fail fast if `GH_TOKEN`/`GITHUB_TOKEN` or `API_TOKEN` is missing. ## Hugging Face Setup 1. Open your Space. 2. Go to `Settings` -> `Variables and secrets`. 3. Add a **Secret** named `GH_TOKEN`. 4. Add a **Secret** named `API_TOKEN`. 5. Paste your token values. 6. Save and restart/redeploy the Space. ## Notes - Do not hardcode tokens in code or Dockerfile. - Startup only logs token length, never token value. - If `/v1/models` still returns `Not authenticated`, the token likely lacks Copilot entitlement/permissions. - Requests to `/v1/*` without `Authorization: Bearer ` (or `X-API-Key: `) return `401`. ## Example ```bash curl https://kaballas-copilot.hf.space/copilot/v1/models \ -H "Authorization: Bearer $API_TOKEN" curl -X POST https://kaballas-copilot.hf.space/copilot/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $API_TOKEN" \ -d '{ "model": "gpt-4.1", "messages": [ {"role": "user", "content": "Hello"} ] }' ``` Configuration reference: https://huggingface.co/docs/hub/spaces-config-reference