IndicStack
Platform
ConsultingModelsAgentsComplianceBlog
Request Early Access
IndicStack

Product

  • Platform
  • Models
  • Agents
  • Consulting

Solutions

  • IT Services & Agencies
  • SaaS Startups
  • Regulated Industries
  • WhatsApp Automation

Company

  • About
  • Compliance
  • Blog

Legal

  • Privacy Policy
  • Terms of Service

IndicStack Consultancy Services LLP — Built for Indian AI builders.

29 May 2026tutorialmigrationdeveloper

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/completions endpoint
  • Streaming - SSE with same stream: true parameter
  • Function calling - same tools and tool_choice parameters
  • JSON mode - same response_format: { type: "json_object" }
  • System prompts - same system role messages
  • Temperature, max_tokens, top_p - all standard parameters supported
  • Error codes - same HTTP status codes and error shapes

What Changes

DimensionOpenAIIndicStack
Base URLapi.openai.com/v1api.indicstack.ai/v1
API key prefixsk-isk_
ModelsGPT-4o, GPT-4o-mini, etc.sarvam-30b, krutrim-2, etc.
Inference locationUS (Virginia/Oregon)India
BillingUSDINR + GST
Data jurisdictionUS 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

  1. Request early access to get your API key
  2. Change your base URL
  3. Run your existing test suite - everything should pass
  4. Deploy to production on Indian infrastructure