# GitHub Copilot

## Install the skill

```bash
npx skills@1.7.4 add https://docs.azta.ai --skill azta-api --agent github-copilot
```

Add `-g` to install for every project. Other ways to install are on [Azta API skill](/skills/azta-api).

## Paste the prompt

**Agent mode in VS Code.** Open Copilot Chat, switch to agent mode and paste the prompt below.

**Copilot coding agent.** Create an issue in your repository, paste the prompt below as the issue body and assign the issue to Copilot. It works in the background and opens a pull request for you to review.

## The prompt

```text
Integrate the Azta API into this codebase. Azta answers legal and regulatory questions, and every answer links to the provisions it cites.

Start here:

1. Read https://docs.azta.ai/llms.txt for the docs index. If the azta-api skill is installed, use it instead and follow its references.
2. Use the HTTP client this codebase already has, or the OpenAI SDK pointed at the Azta base URL. Do not add another SDK.

Build this:

1. Configuration. Read the API key from the AZTA_API_KEY environment variable and the base URL from AZTA_BASE_URL, defaulting to https://api.azta.ai/v1. Never write a key into source. Add both to .env.example, with a sandbox placeholder for the key, and tell me to create a sandbox key in the console.
2. First call. Send a question to POST /responses with background set to true. Generate one Idempotency-Key per question and send it on the create request. On 429, 500 and 503, wait for the Retry-After seconds (1 second when missing) and retry with the same Idempotency-Key, at most 3 attempts. Do not retry 400, 401, 402 or 403. Poll GET /responses/{id} every 5 seconds until the status is completed, failed or cancelled, and honour Retry-After on a 429 or 503 while polling.
3. Sources. Render output_text and place a [n] marker from each annotations entry, using the offsets the API returns. Offsets count Unicode code points, not UTF-16 units: in JavaScript slice with Array.from(text), never string indexes. Under the text, list the sources with their titles and URLs. If annotations is empty, render the text without markers.
4. Webhook. Add a webhook endpoint that receives response events. Verify the Standard Webhooks signature on the raw request body with AZTA_WEBHOOK_SECRET before parsing it, reject a bad signature, or a webhook-timestamp more than 300 seconds from now, with 400, skip a webhook-id you already handled, and answer 2xx fast. Add AZTA_WEBHOOK_SECRET to .env.example.
5. Errors. Branch on error.code, never on the message text. Show the user a short message of your own and log the response request id.
6. Tests. Write a test for the source rendering: markers land at the right offsets, the sources list shows each URL, and an empty annotations array renders plain text. Add a test for the retry path that proves the Idempotency-Key is reused.

Run the sandbox call once to check it works, show me the output, and list the files you changed.
```

When the agent is done, check the first call in the sandbox, read the source rendering test, and see [Sources](/guides/sources) and [Webhooks](/guides/webhooks) for what to expect.
