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
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
| Concept | DeepSeek | Gemini (native) |
|---|---|---|
| SDK | openai + base_url | google-genai |
| Turns | messages[] (user/assistant) | contents[] (user/model) |
| System prompt | messages[] role: system | config.system_instruction |
| Max output | max_tokens | config.max_output_tokens |
| Assistant role | assistant | model |
| Response text | choices[0].message.content | response.text |
| Tools | tools + tool_calls | config.tools (declarations) |
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:
assistant→model;messages→contents/parts. - System message →
config.system_instruction; readresponse.text. - Long-prompt pricing tier on Gemini Pro; re-budget.
- Re-tune prompts and re-run evals.
What to do next
- Start with Gemini’s OpenAI-compatibility endpoint — likely a one-line change from DeepSeek.
- If you need native features, port
messages→contents(renameassistant→model) and the system prompt →system_instruction. - 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.