Migrating from DeepSeek to Google Gemini: A Practical Guide

Because DeepSeek uses the OpenAI shape, the fast path is Gemini’s OpenAI-compatibility endpoint — just change the base URL, key, and model. Move to Gemini’s native google-genai SDK only when you need features the compat layer doesn’t expose.

Fast path — Gemini’s OpenAI-compatible endpoint

After — Gemini via the OpenAI SDK
import os
from openai import OpenAI
# Before (DeepSeek): base_url="https://api.deepseek.com", key=DEEPSEEK_API_KEY
client = OpenAI(
  api_key=os.environ["GEMINI_API_KEY"],
  base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
)
resp = client.chat.completions.create(
  model="gemini-2.5-flash",
  messages=[
      {"role": "system", "content": "You are concise."},
      {"role": "user", "content": "Explain rate limits in one line."},
  ],
)
print(resp.choices[0].message.content)

Same SDK, same message shape — only the base URL, key, and model change.

Native path — concept mapping

DeepSeek (OpenAI-compatible) → Gemini native (as of June 2026).
ConceptDeepSeekGemini (native)
SDK openai + base_urlgoogle-genai
Turns messages[] (user/assistant)contents[] (user/model)
System prompt messages[] role: systemconfig.system_instruction
Max output max_tokensconfig.max_output_tokens
Assistant role assistantmodel
Response text choices[0].message.contentresponse.text
Tools tools + tool_callsconfig.tools (declarations)
After — Gemini native
from google import genai
from google.genai import types
client = genai.Client()  # GEMINI_API_KEY

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)
Watch for these
  • Prefer the compat endpoint unless you need native-only features — it’s a config change.
  • Native role rename: assistantmodel; messagescontents/parts.
  • System message → config.system_instruction; read response.text.
  • Long-prompt pricing tier on Gemini Pro; re-budget.
  • Re-tune prompts and re-run evals.

What to do next

  1. Start with Gemini’s OpenAI-compatibility endpoint — likely a one-line change from DeepSeek.
  2. If you need native features, port messagescontents (rename assistantmodel) and the system prompt → system_instruction.
  3. Re-price with the cost calculator; reverse route is Gemini → DeepSeek.

Frequently asked questions

What's the easiest way to move DeepSeek → Gemini?
Use Gemini's OpenAI-compatibility endpoint. Since your DeepSeek code already uses the OpenAI SDK, you only change the base URL to Gemini's compat path, swap the key, and set a Gemini model.
When do I need the native SDK?
When you want Gemini-specific capabilities not exposed through the compatibility layer. Then port to google-genai: contents/parts, the model role, a system_instruction, and response.text.
Do costs change much?
Possibly — Gemini Flash tiers are cheap, but watch the higher pricing band for very long prompts on Gemini Pro. Confirm with the cost calculator on your real token mix.