{
"error": {
"message": "No allowed providers are available for the selected model.",
"code": 404
}
}
When trying to connect to any free language model, it gives the aforementioned error. Below is the code for testing. It returned the correct answer once yesterday, and then the error mentioned above occurred. I have changed the API key; what could be the problem?
import requests
import json
Ваш API-ключ OpenRouter
api_key = "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"
Конечная точка API
url = "https://openrouter.ai/api/v1/chat/completions"
Заголовки запроса
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
"HTTP-Referer": "<YOUR_SITE_URL>", # Необязательно. URL сайта для ранжирования на openrouter.ai.
"X-Title": "<YOUR_SITE_NAME>", # Необязательно. Название сайта для ранжирования на openrouter.ai.
}
Полезная нагрузка запроса
payload = {
"model": "z-ai/glm-4.5-air:free", # Укажите модель Deepseek V3 0324
"messages": [
{"role": "system", "content": "Вы полезный помощник."},
{"role": "user", "content": "Объясните квантовые вычисления простыми словами."}
],
"temperature": 0.7,
"max_tokens": 1000
}
Выполнение запроса
response = requests.post(url, headers=headers, data=json.dumps(payload))
Печать ответа
print(json.dumps(response.json(), indent=4))