Try Chat Free Docs Pricing AI Analysis Repo Insights Free Tools About Blog
Sign in Get started free
< Back to blog
Tutorial Velona Team ·9 September 2026 ·8 min read

How to Use DeepSeek API in India: Complete Guide for Developers

DeepSeek API gives your application access to AI models

DeepSeek has become a popular choice for developers building AI applications, coding tools, chatbots and automation workflows.

If you want to use DeepSeek inside your own application, you do not need to use a chat interface manually. You can connect your application directly to a DeepSeek model through an API.

For developers in India, the important parts are getting an API key, choosing the right model, sending the request correctly and understanding how API usage is billed.

This guide shows how to use the DeepSeek API with Python and an OpenAI-compatible API endpoint.

By the end, you will have a basic Python application that can send a prompt to a DeepSeek model and print the generated response.

What you need before starting

You need:

If you are using Velona, you can access DeepSeek models through its AI API platform and use INR-based billing for your API usage.

Create your Python project

Start by creating a new directory:

mkdir deepseek-python
cd deepseek-python

Create a virtual environment:

python -m venv venv

Activate it on Linux or macOS:

source venv/bin/activate

On Windows, use:

venv\Scripts\activate

A virtual environment keeps your project's Python dependencies separate from other projects.

Install the OpenAI Python SDK

DeepSeek-compatible APIs can be accessed using the OpenAI Python SDK when the API follows the OpenAI-compatible request format.

Install the package:

pip install openai

You can now use the SDK to create your API client.

Create your API key

Your API key is what allows your application to authenticate with the API.

Treat it as a secret.

Do not put the key directly into Python code that you plan to publish on GitHub or distribute to other developers.

Instead, store it as an environment variable.

Store the API key securely

Create a .env file in your project:

API_KEY=your_api_key_here

Install python-dotenv:

pip install python-dotenv

Then add .env to your .gitignore file:

.env

This prevents the secret from being accidentally committed to your source repository.

Connect Python to the DeepSeek API

Now create a file called main.py.

For an OpenAI-compatible Velona endpoint, the basic setup looks like this:

import os
from dotenv import load_dotenv
from openai import OpenAI

load_dotenv()

client = OpenAI(
    api_key=os.getenv("API_KEY"),
    base_url="https://velona.in/v1"
)

The API key is loaded from the environment rather than being written directly into the source code.

The base_url tells the SDK where to send the API request.

Send your first DeepSeek request

Once the client is configured, you can make a chat completion request.

response = client.chat.completions.create(
    model="YOUR_DEEPSEEK_MODEL",
    messages=[
        {
            "role": "user",
            "content": "Explain Python APIs in simple language."
        }
    ]
)

print(response.choices[0].message.content)

Replace YOUR_DEEPSEEK_MODEL with the current DeepSeek model ID available through the API.

If the request succeeds, the generated response will be printed in your terminal.

How the request works

The request contains three important pieces.

The model

model="YOUR_DEEPSEEK_MODEL"

This tells the API which model should process your request.

The messages

messages=[
    {
        "role": "user",
        "content": "Explain Python APIs in simple language."
    }
]

This contains the conversation sent to the model.

The response

response.choices[0].message.content

This extracts the generated text from the API response.

The complete flow is:

Python application
       |
       v
OpenAI-compatible SDK
       |
       v
Velona API
       |
       v
DeepSeek model
       |
       v
Generated response
       |
       v
Python application

Use a reusable function

Instead of writing the API request every time you need an AI response, turn it into a function.

def ask_deepseek(prompt):
    response = client.chat.completions.create(
        model="YOUR_DEEPSEEK_MODEL",
        messages=[
            {
                "role": "user",
                "content": prompt
            }
        ]
    )

    return response.choices[0].message.content

You can then call the function whenever your application needs an AI response:

answer = ask_deepseek(
    "Give me three Python project ideas."
)

print(answer)

This structure is much easier to reuse when building a larger application.

Add system instructions

You can give the model additional instructions using a system message.

response = client.chat.completions.create(
    model="YOUR_DEEPSEEK_MODEL",
    messages=[
        {
            "role": "system",
            "content": "You are a helpful Python programming assistant."
        },
        {
            "role": "user",
            "content": "Explain Python decorators."
        }
    ]
)

The system message establishes instructions for the model, while the user message contains the current request.

This becomes useful when building specialized applications.

For example, you could create an AI assistant designed specifically for programming questions, customer support or document summarization.

Handle DeepSeek API errors

API requests can fail, so your application should handle exceptions.

try:
    response = client.chat.completions.create(
        model="YOUR_DEEPSEEK_MODEL",
        messages=[
            {
                "role": "user",
                "content": "Explain APIs."
            }
        ]
    )

    print(response.choices[0].message.content)

except Exception as error:
    print("API request failed")
    print(error)

During development, the returned error can help you identify whether the problem is related to authentication, the model, the request or the API service.

Check your model ID

One common mistake is using a model name that is no longer available or is spelled incorrectly.

Model IDs should not be guessed.

Check the current model catalog and use the exact model identifier provided by your API provider.

This is particularly important because AI model catalogs can change over time.

Understand DeepSeek API usage and cost

AI API usage is generally based on the amount of processing your application consumes.

For text models, this is commonly measured in tokens.

Input tokens
      +
Output tokens
      |
      v
Model usage
      |
      v
API cost

Your input includes the content sent to the model. The generated answer contributes to output usage.

A short request and response may consume relatively few tokens, while a long conversation with large amounts of context can consume considerably more.

If you are using an INR-based API wallet, the corresponding usage cost can be deducted from your available balance.

Why long prompts can increase usage

Consider a simple request:

Explain recursion in Python.

Now compare it with a request containing:

System instructions
+
Previous conversation
+
Large document
+
User question
+
Additional context

The second request contains much more input.

When building production applications, send the context that the model actually needs instead of automatically sending everything available.

Build a simple DeepSeek-powered application

Once your basic API request works, you can turn it into a small application.

For example, a command-line AI assistant:

while True:
    prompt = input("You: ")

    if prompt.lower() == "exit":
        break

    answer = ask_deepseek(prompt)

    print("AI:", answer)

Now your terminal becomes a simple AI interface.

You: Explain APIs
AI: An API is...

You: What is Python?
AI: Python is...

You: exit

This is a very small application, but the same API function can later be connected to a web application, chatbot or backend service.

Keep the API key on the backend

If you are building a web application, do not expose your DeepSeek API key in frontend JavaScript.

A safer architecture is:

Browser
   |
   v
Your backend
   |
   | API key
   v
Velona API
   |
   v
DeepSeek model
   |
   v
Your backend
   |
   v
Browser

The browser sends the user's request to your server. Your server then authenticates with the AI API and returns the result.

This keeps your secret API credentials on the server.

Use the smallest working request first

If your DeepSeek integration does not work, avoid debugging your entire application at once.

Start with a minimal request:

response = client.chat.completions.create(
    model="YOUR_DEEPSEEK_MODEL",
    messages=[
        {
            "role": "user",
            "content": "Say hello."
        }
    ]
)

Once this works, add conversation history, application logic, databases and other features one step at a time.

This makes it much easier to identify where a problem was introduced.

Common problems when using DeepSeek API

Invalid API key

Check that your environment variable contains the correct key.

print(
    "API key loaded"
    if os.getenv("API_KEY")
    else "API key missing"
)

Do not print the actual key.

Invalid model

Use the exact model ID available from the current model catalog.

Incorrect endpoint

If you are using an OpenAI-compatible endpoint, verify that your base_url is correct.

Insufficient balance

If your API account uses prepaid credits, check that there is enough balance for your request.

Unexpected usage

Check for application loops, repeated retries or automated processes that may be making more requests than expected.

Why use DeepSeek through an API?

An API allows DeepSeek models to become part of your own software rather than remaining separate from your application.

You can use the model for:

The important shift is from manually using an AI interface to making AI functionality part of your application's backend.

Final thoughts

Using the DeepSeek API with Python can be reduced to a simple process:

Create API key
      |
      v
Install SDK
      |
      v
Configure endpoint
      |
      v
Choose DeepSeek model
      |
      v
Send prompt
      |
      v
Receive response
      |
      v
Use response in your application

Once you have this working, you can build much more around the same foundation.

If you are an Indian developer, an INR-based API setup can also make it easier to manage your AI development budget without treating API usage as an unfamiliar foreign-currency expense.

With Velona, you can access DeepSeek and other AI models through an API and use the same general developer workflow to experiment, build and deploy AI-powered applications.

Start with one simple request. Once it works, add your application logic around it.

That first successful API response is the point where DeepSeek stops being just an AI model you use and becomes a capability you can build into your own software.