litellm/docs/my-website
jtstothard ef76139e9a
fix(copilot): correct X-Initiator header so only the first turn of multi-turn agentic workflows consumes a premium request
This PR fixes GitHub Copilot billing behavior for multi-turn agentic workflows by implementing
proper X-Initiator header classification. Previously, all turns consumed a premium request.
After this fix, only the first user-initiated turn consumes a premium request; follow-up
assistant/tool turns (agent-initiated) do not.

**Changes:**

1. **New X-Initiator header classification** (common_utils.py):
   - Added `determine_x_initiator()` helper that analyzes input messages/items
   - Returns "user" if messages are user-only (new conversation = premium request)
   - Returns "agent" if messages contain assistant/tool roles (continuation = free)

2. **Wired X-Initiator header into completion paths**:
   - Chat API: chat/transformation.py sets X-Initiator from validate_environment()
   - Responses API: responses/transformation.py sets X-Initiator from validate_environment()
   - Main completion path: main.py passes X-Initiator through extra_headers

3. **Optional conversation correlation header**:
   - Added `copilot_conversation_id` metadata parameter for session-scoped billing
   - Sets X-Conversation-Id header when provided (optional, for caller opt-in)
   - Verified via API testing that billing is governed by X-Initiator, not session correlation

4. **Comprehensive test coverage**:
   - Unit tests for X-Initiator classification logic (test_conversation_id.py)
   - Integration tests for Chat API (test_github_copilot_transformation.py)
   - Integration tests for Responses API (test_github_copilot_responses_transformation.py)
   - Billing integration tests (test_github_copilot_billing.py)

**Billing impact:**
- Multi-turn agentic workflows: 1 premium request instead of N (where N = number of turns)
- Single-turn conversations: No change (still 1 premium request)
- Tool calls: 1 premium request for the full user→tool→tool_response→assistant exchange

Fixes: #25276

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 16:06:50 +01:00
..
blog apply content guidelines: scale/resilience narrative, FAQ, Key Takeaways, Conclusion CTA 2026-04-11 18:12:32 -07:00
docs fix(copilot): correct X-Initiator header so only the first turn of multi-turn agentic workflows consumes a premium request 2026-04-21 16:06:50 +01:00
img feat(guardrails): optional skip system message in unified guardrail inputs (#25481) 2026-04-11 08:53:24 -07:00
release_notes [Nit] Small docs fix, fixing img + folder name (#25171) 2026-04-04 18:14:32 -07:00
src Merge pull request #25463 from BerriAI/litellm_oss_staging_04_09_2026 2026-04-13 17:25:53 -07:00
static docs: cleanup image 2026-03-30 09:26:46 -07:00
.gitignore Inkeep searchbar and chat added to the Docs (#12030) 2025-06-26 10:13:42 -07:00
babel.config.js updating docs 2023-08-12 11:30:32 -07:00
Dockerfile build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
docusaurus.config.js docs: cleanup (#25026) 2026-04-02 15:18:24 -07:00
index.md fix keys 2023-08-17 16:13:52 -07:00
package-lock.json [Fix] Remove neon CLI dependency and pin all JS dependencies 2026-04-01 16:15:32 -07:00
package.json [Fix] Remove neon CLI dependency and pin all JS dependencies 2026-04-01 16:15:32 -07:00
README.md updating docs 2023-08-12 11:30:32 -07:00
sidebars-release-notes.js update: ui and layout change 2026-03-17 01:55:27 +05:30
sidebars.js Merge pull request #25616 from BerriAI/main 2026-04-13 08:43:43 +05:30

Website

This website is built using Docusaurus 2, a modern static website generator.

Installation

$ yarn

Local Development

$ yarn start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

Build

$ yarn build

This command generates static content into the build directory and can be served using any static contents hosting service.

Deployment

Using SSH:

$ USE_SSH=true yarn deploy

Not using SSH:

$ GIT_USER=<Your GitHub username> yarn deploy

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the gh-pages branch.