with open("gateway.py", "r") as f: code = f.read() # Let's completely remove API_KEY forwarding from llama_auth_headers and just leave it to default. # WAIT. In start.sh I removed `env -u API_KEY`. So `llama-swap` now knows `API_KEY`. # Since `llama-swap` knows `API_KEY`, we MUST provide it when sending requests from `gateway.py` to `llama-swap`. # And we ARE doing that. # What does `llama_auth_headers()` return now? old_headers = """def llama_auth_headers() -> dict[str, str]: return {"Authorization": f"Bearer {API_KEY}"} if API_KEY else {}""" # If we are STILL getting Invalid API Key, and `API_KEY` is sent, maybe `llama-swap` doesn't support the `API_KEY` environment variable in the way we expect, OR it requires something else. # Let's try passing the user's `key_from_header` straight to `llama-swap` if they provide one! # Wait! We can't do that easily because `execute_completion` doesn't take the user's key. # But wait, if `API_KEY` is set to "sk-gemini" (as you mentioned), and `gateway.py` sends `Authorization: Bearer sk-gemini`, why would `llama-swap` reject it? # Let's check `llama-swap` docs. `llama-swap` expects the Bearer token to match the API_KEY environment variable. # Wait, `llama_auth_headers` is using `LLAMA_API_KEY`! Let me check what I actually committed.