Skip to content

Python HTTPX NordRouter bilan

python
import os
import httpx

with httpx.Client(timeout=60) as client:
    response = client.post(
        "https://nordrouter.com/v1/chat/completions",
        headers={"Authorization": f"Bearer {os.environ['NORDROUTER_API_KEY']}"},
        json={
            "model": "anthropic/claude-sonnet-4.6",
            "messages": [{"role": "user", "content": "Привет!"}],
        },
    )
    response.raise_for_status()
    print(response.json()["choices"][0]["message"]["content"])

httpx.AsyncClient uchun so'rov parametrlari bir xil, ammo qo'ng'iroqlar await orqali amalga oshiriladi.

Barcha dasturlar