← Quickstart

Python quickstart

Python 3.10+, httpx-based. async + sync both work.

1. Install

pip install httpx
# or: uv add httpx

2. Configure

import os
import httpx

EDGIFY_API = "https://api.edgify.net"
EDGIFY_TOKEN = os.environ["EDGIFY_TOKEN"]  # service-account JWT

3. Mint a virtual key

r = httpx.post(
    f"{EDGIFY_API}/api/virtual-keys",
    headers={"authorization": f"Bearer {EDGIFY_TOKEN}"},
    json={
        "name": "python-quickstart",
        "provider_key_id": "<your provider_key_id>",
        "limit_profile_id": "<your limit_profile_id>",
    },
    timeout=10,
)
r.raise_for_status()
vk = r.json()
token = vk["token_one_time"]
print("virtual key:", vk["id"], "— save the token, it's shown once.")

4. Use it like the upstream

reply = httpx.post(
    "https://proxy.edgify.net/v1/chat/completions",
    headers={"authorization": f"Bearer {token}"},
    json={
        "model": "gpt-4o-mini",
        "messages": [{"role": "user", "content": "Say hi in 4 words."}],
    },
    timeout=30,
)
print(reply.json())