Sarvam.ai
LiteLLM supports all the text models from Sarvam ai
Usage​
import os
from litellm import completion
# Set your Sarvam API key
os.environ["SARVAM_API_KEY"] = ""
messages = [{"role": "user", "content": "Hello"}]
response = completion(
model="sarvam/sarvam-m",
messages=messages,
)
print(response)
Usage with LiteLLM Proxy Server​
Here's how to call a Sarvam.ai model with the LiteLLM Proxy Server
-
Modify the
config.yaml:model_list:- model_name: my-modellitellm_params:model: sarvam/<your-model-name> # add sarvam/ prefix to route as Sarvam providerapi_key: api-key # api key to send your model -
Start the proxy:
$ litellm --config /path/to/config.yaml -
Send a request to LiteLLM Proxy Server:
- OpenAI Python v1.0.0+
- curl
import openaiclient = openai.OpenAI(api_key="sk-1234", # pass litellm proxy key, if you're using virtual keysbase_url="http://0.0.0.0:4000" # litellm-proxy-base url)response = client.chat.completions.create(model="my-model",messages=[{"role": "user","content": "what llm are you"}],)print(response)curl --location 'http://0.0.0.0:4000/chat/completions' \--header 'Authorization: Bearer sk-1234' \--header 'Content-Type: application/json' \--data '{"model": "my-model","messages": [{"role": "user","content": "what llm are you"}]}'