Skip to main content

Vallkey python

vallkey

Route ghost-key requests through Vallkey using the supported HTTP clients below.

Vallkey gives you ghost keys: stand-in API keys that only work within your rules, and that you can kill in one click. This package sends every request that carries a ghost key to Vallkey instead of the provider, with the same path, so supported clients do not need a base URL override. Requests without a ghost key are not touched.

pip install vallkey

That is all: once it is installed in the app's environment, it turns on when Python starts, with no import and no variable. Requests without a ghost key are left alone. VALLKEY_AUTO=0 turns it off, also from a .env file your app loads, since each request checks it.

On AWS Lambda, add one line. Lambda adds your code and layers to Python's path after Python has started, so the package cannot turn itself on there and the ghost key goes straight to the provider, which refuses it. Make this the first line of your handler file:

import vallkey.auto

npx vallkey connect adds it for you in SAM and Serverless Framework projects.

Put your ghost key where the real key was (for example OPENAI_API_KEY=gk_openai_...) and use the SDK as usual:

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), urllib3 on its own (SDKs generated by OpenAPI Generator), botocore (boto3, including S3 buckets named in the address), aiohttp and urllib. Libraries imported later are covered too, so the order of imports does not matter.

Variable
VALLKEY_AUTO=0 Turns it off
VALLKEY_API The Vallkey server, if not https://api.vallkey.com
VALLKEY_DEBUG=1 Logs each request sent to Vallkey (never the key)

To set up ghost keys from your .env files, use the command line tool: npx vallkey init.

Docs: https://vallkey.com/docs/python/

Web pages and mobile apps (short-lived keys)

Keep the ghost key on your server, and give each signed-in user a short-lived key instead. It expires in minutes and can only do what the ghost key allows.

from vallkey.session import create_session_key  # reads VALLKEY_GHOST_KEY

key = create_session_key(user=user.id, ttl_seconds=900)["session_key"]
# send key to the page or app

See https://vallkey.com/docs/browsers/.

Compatibility and security

Read the transport boundaries and security policy. Local transport tests do not certify every SDK version or cloud deployment. Use a dedicated key and verify requests from the actual application after deployment.

Metadata

Release files for vallkey 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vallkey 0.4.0
File Size Uploaded Provenance Actions
vallkey-0.4.0.tar.gz 13.6 kB With provenance Details for vallkey-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vallkey 0.4.0
File Interpreter ABI Platform Actions
vallkey-0.4.0-py3-none-any.whl Python 3 none any Details for vallkey-0.4.0-py3-none-any.whl

Total release size: 24.6 kB

Release files / vallkey-0.4.0.tar.gz

Download URL vallkey-0.4.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
34633e69c0b379202d4ddd725b660239ec8d980ccc829f3e8d068d7a0988f964
BLAKE2b-256 checksum
How to use checksums
446f25e89ad4ceb6943914b637ea2d6c3d19cae2cb1c3e93b9eb7bdf086f1eb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / vallkey-0.4.0-py3-none-any.whl

Download URL vallkey-0.4.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d67c2d379df89142ff89e6c6d90e77884ca0b57642c0b522a2bb3c6977615e7c
BLAKE2b-256 checksum
How to use checksums
1cf6e18b00042c86f55b613d3e4c9b9b727d8ffa12b88947899d3f2c75972774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for vallkey 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vallkey-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page