from __future__ import annotations
import requests
from ..typing import Messages, AsyncResult
from .template import OpenaiTemplate
class DeepInfra(OpenaiTemplate):
url = "https://deepinfra.com"
login_url = "https://deepinfra.com/dash/api_keys"
base_url = "https://api.deepinfra.com/v1/openai"
working = True
active_by_default = True
default_model = "MiniMaxAI/MiniMax-M2.5"
@classmethod
def get_models(cls, **kwargs):
if not cls.models:
url = 'https://api.deepinfra.com/models/featured'
response = requests.get(url)
models = response.json()
cls.models = {model["model_name"]: {"id": model["model_name"], **model} for model in models if model.get("type") == "text-generation" or model.get("reported_type") == "text-to-image"}
cls.image_models = [model["model_name"] for model in models if model.get("reported_type") == "text-to-image"]
if cls.live == 0 and cls.models:
cls.live += 1
return cls.models
@classmethod
def get_headers(cls, stream: bool, api_key: str = None, headers: dict = None) -> dict:
headers = super().get_headers(stream, api_key, headers)
if not api_key:
headers["X-Deepinfra-Source"] = "model-embed"
headers["Origin"] = "https://deepinfra.com"
headers["Referer"] = "https://deepinfra.com/"
return headers
from __future__ import annotations
import requests
from ..typing import Messages, AsyncResult
from .template import OpenaiTemplate
class DeepInfra(OpenaiTemplate):
url = "https://deepinfra.com"
login_url = "https://deepinfra.com/dash/api_keys"
base_url = "https://api.deepinfra.com/v1/openai"
working = True
active_by_default = True
default_model = "MiniMaxAI/MiniMax-M2.5"
@classmethod
def get_models(cls, **kwargs):
if not cls.models:
url = 'https://api.deepinfra.com/models/featured'
response = requests.get(url)
models = response.json()
cls.models = {model["model_name"]: {"id": model["model_name"], **model} for model in models if model.get("type") == "text-generation" or model.get("reported_type") == "text-to-image"}
cls.image_models = [model["model_name"] for model in models if model.get("reported_type") == "text-to-image"]
if cls.live == 0 and cls.models:
cls.live += 1
return cls.models
@classmethod
def get_headers(cls, stream: bool, api_key: str = None, headers: dict = None) -> dict:
headers = super().get_headers(stream, api_key, headers)
if not api_key:
headers["X-Deepinfra-Source"] = "model-embed"
headers["Origin"] = "https://deepinfra.com"
headers["Referer"] = "https://deepinfra.com/"
return headers