Python Quickstart
Calling your project's gateway API from a Python service, and when a Python backend is justified at all.
Python is reserved for batch / ML / specialized libraries (per ADR 2026-05-10, TS-by-Default Backend Language Policy).
For CRUD, webhooks, billing, content management, third-party API proxies — use backends/gateway/ (TypeScript + Hono). A new Python service is only justified when at least one applies:
- Batch / queued work that is too long for edge runtimes (>5s typical)
- ML / scientific compute that depends on the Python ecosystem (transformers, vLLM, etc.)
- Specialized libraries with no comparable TS port
There is no published nebutra-sdk Python package. This page covers calling the gateway's REST
API from a justified Python service (FastAPI / Django) — not general-purpose backend work.
Calling the gateway
Every gateway endpoint is plain REST, documented via OpenAPI at /docs and /openapi.json on
your gateway host — call it with httpx or requests like any HTTP API:
import httpx
resp = httpx.get(
"https://your-gateway-host/api/v1/ai/models",
headers={"x-service-token": service_token},
)Service-to-service authentication
Internal calls use a short-lived HS256 JWT (x-service-token) signed with the shared
SERVICE_SECRET, verified by @nebutra/auth's verifyServiceToken on the TypeScript side. Sign
the same claim shape with any standard JWT library (e.g. pyjwt) — there is no Python SDK, just a
shared secret and a JWT contract.
import jwt
import time
token = jwt.encode(
{"service": "my-python-worker", "iat": int(time.time())},
SERVICE_SECRET,
algorithm="HS256",
)Related
How is this guide?
Last updated on