Mesh-aware service-to-service helpers for Vercel Python
Project description
Vercel Mesh for Python
vercel-mesh is a thin httpx-shaped layer for service-to-service calls over
Vercel Mesh.
It automatically resolves the current Vercel OIDC token and sends it as
x-vercel-trusted-oidc-idp-token so one service can call another through Mesh
without manually wiring auth headers.
Installation
pip install vercel-mesh
Sync usage
import os
import vercel.mesh as mesh
response = mesh.get(os.environ["PAYMENTS_API_BASE_URL"])
response.raise_for_status()
data = response.json()
Async usage
import os
import vercel.mesh as mesh
async with mesh.AsyncClient() as client:
response = await client.get(os.environ["PAYMENTS_API_BASE_URL"])
response.raise_for_status()
data = response.json()
Reusing a client
import os
import vercel.mesh as mesh
with mesh.Client(timeout=10.0) as client:
response = client.post(os.environ["PAYMENTS_API_BASE_URL"], json={"ok": True})
vercel.mesh.Client and vercel.mesh.AsyncClient subclass httpx.Client and
httpx.AsyncClient, so methods like get, post, request, build_request,
send, and stream all work as expected.
Raw httpx
If you already have your own httpx client, reuse the auth layer directly:
import httpx
from vercel.mesh import TrustedOidcAuth
auth = TrustedOidcAuth()
async with httpx.AsyncClient(auth=auth) as client:
response = await client.get("https://example.vercel.app")
Framework context
When this code runs inside a Vercel Function, the package reads the incoming
x-vercel-oidc-token header via vercel.headers.set_headers(...), just like
the existing vercel.oidc helpers.
from collections.abc import Callable
from fastapi import FastAPI, Request
from vercel.headers import set_headers
app = FastAPI()
@app.middleware("http")
async def vercel_context_middleware(request: Request, call_next: Callable):
set_headers(request.headers)
return await call_next(request)
If no request-scoped token is available, vercel-mesh falls back to the same
local refresh and environment variable behavior as vercel.oidc.
Responses are standard httpx.Response objects.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vercel_mesh-0.1.0.tar.gz.
File metadata
- Download URL: vercel_mesh-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fae305dd21ce14941aa874c649ffd9a1b760db48d41da013106fc0b03460653
|
|
| MD5 |
6f9c5adcc8df85d0f0896451a8ea9845
|
|
| BLAKE2b-256 |
5bf70b11eb28b89016459fd592f5cb493b3b6e4ab50dea159799d5c2a9671749
|
File details
Details for the file vercel_mesh-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vercel_mesh-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c34ab43e58e8dece897ddce58a981a131041cae453d7644d9dafbf60499814b1
|
|
| MD5 |
c637f088bb7f9fd66e970199bb4905f2
|
|
| BLAKE2b-256 |
cba4d98f5efb98938c9f1b19449b795740683b15fea6d4f5ac84aba689b7890b
|