Skip to main content

ChatNovita

Novita AI: The most cost-effective, stable, and scalable inference platform โ€” delivering production-ready performance at a lower cost.

Overviewโ€‹

Model featuresโ€‹

Tool callingStructured outputJSON modeImage inputAudio inputVideo inputToken-level streamingNative asyncToken usageLogprobs
โŒโœ…โœ…โŒโŒโŒโŒโŒโœ…โŒ

Setupโ€‹

To access Novita AI models you'll need to create a Novita account and get an API key.

Credentialsโ€‹

Head to this page to sign up to Novita AI and generate an API key. Once you've done this set the NOVITA_API_KEY environment variable:

import getpass
import os

if "NOVITA_API_KEY" not in os.environ:
os.environ["NOVITA_API_KEY"] = getpass.getpass("Enter your Novita API key: ")

Installationโ€‹

The LangChain Novita integration lives in the langchain-community package:

pip install -qU langchain-community

Instantiationโ€‹

Now we can instantiate our model object and generate chat completions:

from langchain_community.chat_models.novita import ChatNovita
from langchain_core.messages import HumanMessage, SystemMessage

llm = ChatNovita(
model="gryphe/mythomax-l2-13b",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
# other params...
)

Invocationโ€‹

messages = [
SystemMessage(
content="You are a helpful assistant that translates English to French."
),
HumanMessage(
content="Translate this sentence from English to French. I love programming."
),
]

ai_msg = llm.invoke(messages)

print(ai_msg.content)

Chainingโ€‹

We can chain our model with a prompt template like so:

from langchain_core.prompts import ChatPromptTemplate

prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"You are a helpful assistant that translates {input_language} to {output_language}.",
),
("human", "{input}"),
]
)

chain = prompt | llm
chain.invoke(
{
"input_language": "English",
"output_language": "German",
"input": "I love programming.",
}
)
API Reference:ChatPromptTemplate

API referenceโ€‹

For detailed documentation of Novita AI LLM APIs, head to our API reference


Was this page helpful?