Getting Started with SUTRA
SUTRA is a family of large multi-lingual language (LMLMs) models pioneered by Two Platforms. SUTRA’s dual-transformer approach extends the power of both MoE and Dense AI language model architectures, delivering cost-efficient multilingual capabilities for over 50+ languages. It powers scalable AI applications for conversation, search, and advanced reasoning, ensuring high-performance across diverse languages, domains and applications.
Your First API CallCopied!
SUTRA API uses an API format compatible with OpenAI. By modifying the configuration, you can use the OpenAI SDK or softwares compatible with the OpenAI API to access the SUTRA API.
PARAM |
VALUE |
---|---|
base_url |
|
api_key |
apply for an API Key |
Invoke the Chat APICopied!
Once you have obtained an API key, you can access the SUTRA API using the following example scripts. This is a non-stream example, you can set the stream
parameter to true
to get stream response.
curl -X POST "https://api.two.ai/v2/chat/completions" \
-H "Authorization: $SUTRA_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept text/event-stream" \
-d '{
"model": "sutra-light",
"messages": [
{"role": "user", "content": "मुझे मंगल ग्रह के बारे में 5 पैराग्राफ दीजिए"}
]
}'
import os
from openai import OpenAI
url = 'https://api.two.ai/v2';
client = OpenAI(base_url=url,
api_key=os.environ.get("SUTRA_API_KEY"))
stream = client.chat.completions.create(model='sutra-light',
messages = [{"role": "user", "content": "मुझे मंगल ग्रह के बारे में 5 पैराग्राफ दीजिए"}],
max_tokens=1024,
temperature=0,
stream=True)
for chunk in stream:
if len(chunk.choices) > 0:
content = chunk.choices[0].delta.content
finish_reason = chunk.choices[0].finish_reason
if content and finish_reason is None:
print(content, end='', flush=True)
import { OpenAI } from 'openai';
async function testSutra() {
const url = 'https://api.two.ai/v2';
const client = new OpenAI({
apiKey: process.env.SUTRA_API_KEY,
baseURL: url,
})
const stream = await client.beta.chat.completions.stream(
{
model: 'sutra-light',
messages: [ { role: 'user', content: 'मुझे मंगल ग्रह के बारे में 5 पैराग्राफ दीजिए' } ],
}
);
for await (const chunk of stream) {
if (chunk.choices.length > 0) {
const content = chunk.choices[0].delta?.content;
const finishReason = chunk.choices[0].finish_reason;
if (content && finishReason === null) {
process.stdout.write(content);
}
}
}
}
(async (): Promise => { await testSutra(); process.exit(0); })();
FeaturesCopied!
Explore our key offerings, features and easy to integrate API
-
Read the API Reference
-
Try out SUTRA Tokenizer on Hugging Face
-
Code for sample apps can be found on our Github page.
Follow @two_platforms on Twitter for future project updates.