Files
litellm/litellm/llms/novita/chat/transformation.py
Krish Dholakia d37cc63250 Add new model provider Novita AI (#7582) (#9527)
* Add new model provider Novita AI (#7582)

* feat: add new model provider Novita AI

* feat: use deepseek r1 model for examples in Novita AI docs

* fix: fix tests

* fix: fix tests for novita

* fix: fix novita transformation

* ci: fix ci yaml

* fix: fix novita transformation and test (#10056)

---------

Co-authored-by: Jason <ggbbddjm@gmail.com>
2025-05-12 21:49:30 -07:00

34 lines
1.0 KiB
Python

"""
Support for OpenAI's `/v1/chat/completions` endpoint.
Calls done in OpenAI/openai.py as Novita AI is openai-compatible.
Docs: https://novita.ai/docs/guides/llm-api
"""
from typing import List, Optional
from ....types.llms.openai import AllMessageValues
from ...openai.chat.gpt_transformation import OpenAIGPTConfig
class NovitaConfig(OpenAIGPTConfig):
def validate_environment(
self,
headers: dict,
model: str,
messages: List[AllMessageValues],
optional_params: dict,
litellm_params: dict,
api_key: Optional[str] = None,
api_base: Optional[str] = None,
) -> dict:
if api_key is None:
raise ValueError(
"Missing Novita AI API Key - A call is being made to novita but no key is set either in the environment variables or via params"
)
headers["Authorization"] = f"Bearer {api_key}"
headers["Content-Type"] = "application/json"
headers["X-Novita-Source"] = "litellm"
return headers