How to configure Sarvam Chat Completion API endpoint? #3449
singhal-shagun
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi!
I wanted to configure Sarvam AI API to use their Sarvam-105B model with pi coding agent.
As per the model's documentation here, it supports OpenAI-compatible chat completions format. For example, a multi-turn chat completion request would look something like this:
However, I observed that pi's requests were being sent in the following format: :
{ "model": "sarvam-105b", "input": [ { "role": "system", "content": "PI_SYSTEM_PROMPT" }, { "role": "user", "content": [ { "type": "input_text", "text": "hi" } ] }, { "role": "user", "content": [ { "type": "input_text", "text": "hi" } ] }, { "role": "user", "content": [ { "type": "input_text", "text": "hi" } ] }, { "role": "user", "content": [ { "type": "input_text", "text": "hi" } ] } ], . . .This was resulting in the API returning
Error: 400 body.messages.1.user.content : Input should be a valid string.To make the chat completions request work, I had to intercept the requests using Burp Proxy and change them to the following format:
{ "model": "sarvam-105b", "input": [ { "role": "system", "content": "PI_SYSTEM_PROMPT" }, { "role": "user", "content":"hi" }, { "role": "user", "content": "hi" }, { "role": "user", "content": "input_text", }, { "role": "user", "content": "input_text", } ], . . .What configuration changes do I need to make in my Pi setup so that its requests are sent in this format?
Right now, my
settings.jsonis as follows:{ "defaultModel": "sarvam-105b", "defaultProvider": "sarvam", "enableSkillCommands": true, "lastChangelogVersion": "0.67.68", "packages": [ "npm:@ollama/pi-web-search" ], "theme": "dark", "retry": { "enabled": true }, "showHardwareCursor": false, "doubleEscapeAction": "none", "treeFilterMode": "default", "steeringMode": "one-at-a-time" }and my
models.jsonis as follows:{ "providers": { "sarvam": { "baseUrl": "https://api.sarvam.ai/v1", "api": "openai-completions", "apiKey": "API_KEY_SARVAM", "compat": { "supportsDeveloperRole": false, "supportsReasoningEffort": false }, "models": [ { "id": "sarvam-105b", "name": "Sarvam-105B", "input": ["text"], "contextWindow": 128000, "reasoning": false } ] } } }A more detailed documentation of Sarvam's chat completions endpoint is here.
All reactions