Migrate from OpenAI to India-Hosted API in One Line
A step-by-step migration guide showing how to switch from OpenAI to IndicStack's India-hosted inference without rewriting any code.
The Migration
If you use the OpenAI SDK today, migrating to India-hosted inference takes exactly one line change. No code rewrite. No new SDK. No new abstractions.
IndicStack's API is OpenAI-compatible - same endpoint format, same request/response schema, same streaming behavior. You change your base_url and you're done.
Python
from openai import OpenAI
# Before - routed through US servers
# client = OpenAI(
# base_url="https://api.openai.com/v1",
# api_key="sk-..."
# )
# After - India-hosted inference
client = OpenAI(
base_url="https://api.indicstack.ai/v1",
api_key="isk_your_api_key"
)
# Everything below stays identical
response = client.chat.completions.create(
model="sarvam-30b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain the DPDP Act in simple terms"}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
Node.js / TypeScript
import OpenAI from 'openai';
// Before
// const client = new OpenAI({ baseURL: 'https://api.openai.com/v1' });
// After - one line
const client = new OpenAI({
baseURL: 'https://api.indicstack.ai/v1',
apiKey: 'isk_your_api_key',
});
const response = await client.chat.completions.create({
model: 'sarvam-30b',
messages: [
{ role: 'user', content: 'Explain GST input tax credit' }
],
stream: true,
});
for await (const chunk of response) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
cURL
curl https://api.indicstack.ai/v1/chat/completions \
-H "Authorization: Bearer isk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "sarvam-30b",
"messages": [
{"role": "user", "content": "Explain DPDP Act in simple terms"}
],
"temperature": 0.7
}'
What Stays the Same
Everything you already know works unchanged:
- Chat completions - same
/v1/chat/completionsendpoint - Streaming - SSE with same
stream: trueparameter - Function calling - same
toolsandtool_choiceparameters - JSON mode - same
response_format: { type: "json_object" } - System prompts - same
systemrole messages - Temperature, max_tokens, top_p - all standard parameters supported
- Error codes - same HTTP status codes and error shapes
What Changes
| Dimension | OpenAI | IndicStack |
|---|---|---|
| Base URL | api.openai.com/v1 | api.indicstack.ai/v1 |
| API key prefix | sk- | isk_ |
| Models | GPT-4o, GPT-4o-mini, etc. | sarvam-30b, krutrim-2, etc. |
| Inference location | US (Virginia/Oregon) | India |
| Billing | USD | INR + GST |
| Data jurisdiction | US law (CLOUD Act) | Indian law |
Choosing a Model
IndicStack offers models across three tiers:
Economy - Fast, cheap, high-volume. Best for chatbots, classification, simple extraction.
krutrim-2(12B, 22 Indic languages)openhathi-7b(Hindi-focused)
Default - Balanced performance and cost. Best for most production workloads.
sarvam-30b(30B MoE, 22+ languages, Apache 2.0)sarvam-m(24B, strong multilingual)
Premium - Highest quality for complex reasoning.
sarvam-105b(106B, complex tasks)
All models support Indian languages natively - not through a translation layer.
Streaming
Streaming works identically to OpenAI. Server-sent events, same chunk format:
stream = client.chat.completions.create(
model="sarvam-30b",
messages=[{"role": "user", "content": "Write a poem in Tamil"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Environment Variables
For production deployments, set your base URL and key via environment:
export OPENAI_BASE_URL=https://api.indicstack.ai/v1
export OPENAI_API_KEY=isk_your_api_key
Most OpenAI SDK wrappers (LangChain, LlamaIndex, Vercel AI SDK) respect these environment variables, so you may not need to change any code at all.
LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://api.indicstack.ai/v1",
api_key="isk_your_api_key",
model="sarvam-30b"
)
response = llm.invoke("Summarize RBI's data localization circular")
Vercel AI SDK
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
const { text } = await generateText({
model: openai('sarvam-30b', {
baseURL: 'https://api.indicstack.ai/v1',
apiKey: 'isk_your_api_key',
}),
prompt: 'Explain DPDP Act compliance requirements',
});
What You Get After Migration
- India data residency - All inference on Indian infrastructure
- INR billing - Predictable costs, proper GST invoices
- No CLOUD Act exposure - Indian company, Indian jurisdiction
- Per-client metering - Track usage by project or customer
- No-training guarantee - Your data is never used for model improvement
- Configurable retention - 30 days, 7 days, or zero
Next Steps
- Request early access to get your API key
- Change your base URL
- Run your existing test suite - everything should pass
- Deploy to production on Indian infrastructure