Migrating from Google Gemini to DeepSeek: A Practical Guide

DeepSeek is OpenAI-compatible, so this is “Gemini → OpenAI shape, pointed at DeepSeek.” Convert Gemini’s native contents into OpenAI messages once, then use the OpenAI SDK with DeepSeek’s base URL. If you were already on Gemini’s OpenAI-compatibility endpoint, it’s just a base-URL/key/model swap.

API concept mapping

Gemini native → DeepSeek (OpenAI-compatible, as of June 2026).
ConceptGemini (native)DeepSeek
SDK google-genaiopenai + base_url
Base URL / auth GEMINI_API_KEYhttps://api.deepseek.com + DEEPSEEK_API_KEY
Turns contents[] (user/model)messages[] (user/assistant)
System prompt config.system_instructionmessages[] with role: system
Max output config.max_output_tokensmax_tokens (optional)
Response text response.textchoices[0].message.content
Model gemini-2.5-flashdeepseek-chat / deepseek-reasoner

Before / after

Before — Gemini native
from google import genai
from google.genai import types
client = genai.Client()

resp = client.models.generate_content(
  model="gemini-2.5-flash",
  contents="Explain rate limits in one line.",
  config=types.GenerateContentConfig(system_instruction="You are concise.", max_output_tokens=1024),
)
print(resp.text)
After — DeepSeek (OpenAI SDK)
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["DEEPSEEK_API_KEY"], base_url="https://api.deepseek.com")

resp = client.chat.completions.create(
  model="deepseek-chat",
  messages=[
      {"role": "system", "content": "You are concise."},   # was system_instruction
      {"role": "user", "content": "Explain rate limits in one line."},
  ],
)
print(resp.choices[0].message.content)
Watch for these
  • Role rename: Gemini modelassistant; flatten parts into content.
  • System instruction → a system message; read choices[0].message.content.
  • deepseek-reasoner adds reasoning content + longer outputs — handle and cost separately.
  • Tools move to OpenAI’s tools/tool_calls format.
  • Re-tune prompts and re-run evals.

What to do next

  1. Convert Gemini contents → OpenAI-shape messages (system as a message, rename modelassistant).
  2. Use the OpenAI SDK with DeepSeek’s base URL/key; choose deepseek-chat or -reasoner.
  3. Port tools and re-run evals.
  4. DeepSeek is usually the cheapest target — confirm with the cost calculator. The remap mirrors Gemini → OpenAI.

Frequently asked questions

Can I skip learning DeepSeek's API?
Yes — DeepSeek implements the OpenAI chat API, so you use the OpenAI SDK with DeepSeek's base URL. The only real work is converting Gemini's native contents format into OpenAI messages.
What if I'm already on Gemini's OpenAI-compatibility endpoint?
Then it's trivial: change the base_url to https://api.deepseek.com, swap to a DeepSeek key, and set the model to deepseek-chat.
Will costs drop?
Usually a lot — DeepSeek is among the cheapest providers. Run your token counts through the cost calculator to quantify the savings before cutover.