/Python

Get started

Python

Send any Python SDK through Vallkey without changing your code.

The vallkey Python package sends every request that carries a ghost key to Vallkey, with the same path, so no SDK needs a base URL. Requests without a ghost key are not touched. It has no dependencies and works with Python 3.8 or newer.

Terminal
pip install vallkey # no code change at all:VALLKEY_AUTO=1 python app.py

Or turn it on in code with import vallkey.auto, anywhere: libraries imported later are covered too. Then put the ghost key where the real key was and use the SDK as usual:

Python
# .env: OPENAI_API_KEY=gk_openai_...from openai import OpenAI client = OpenAI()  # no base_url needed

It covers httpx and httpx2 (OpenAI, Anthropic and most new SDKs), requests (Stripe, Twilio and most others), aiohttp and urllib. VALLKEY_DEBUG=1 logs each request it sends to Vallkey (never the key).

For web pages and mobile apps, your server can make a short-lived key for each signed-in user, from the ghost key in VALLKEY_GHOST_KEY:

Python
from vallkey.session import create_session_key key = create_session_key(user=user.id)  # { session_key, expires_at, expires_in, user }

Still have a question?

We read every email, usually within a day.

Contact support