Skip to content

OpenAI Python SDK from NordRouter

Install the library:

bash
pip install openai

Set the key in the variable NORDROUTER_API_KEY, then:

python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NORDROUTER_API_KEY"],
    base_url="https://nordrouter.com/v1",
)

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-4.6",
    messages=[{"role": "user", "content": "Ответь: работает"}],
)

print(response.choices[0].message.content)

AsyncOpenAI is configured by the same api_key and base_url; Only the asynchronous method of calling changes.

Official SDK:openai/openai-python.

All programs·Common mistakes