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
| Concept | Gemini (native) | DeepSeek |
|---|---|---|
| SDK | google-genai | openai + base_url |
| Base URL / auth | GEMINI_API_KEY | https://api.deepseek.com + DEEPSEEK_API_KEY |
| Turns | contents[] (user/model) | messages[] (user/assistant) |
| System prompt | config.system_instruction | messages[] with role: system |
| Max output | config.max_output_tokens | max_tokens (optional) |
| Response text | response.text | choices[0].message.content |
| Model | gemini-2.5-flash | deepseek-chat / deepseek-reasoner |
Before / after
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) 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
model→assistant; flattenpartsintocontent. - System instruction → a
systemmessage; readchoices[0].message.content. deepseek-reasoneradds reasoning content + longer outputs — handle and cost separately.- Tools move to OpenAI’s
tools/tool_callsformat. - Re-tune prompts and re-run evals.
What to do next
- Convert Gemini
contents→ OpenAI-shapemessages(system as a message, renamemodel→assistant). - Use the OpenAI SDK with DeepSeek’s base URL/key; choose
deepseek-chator-reasoner. - Port tools and re-run evals.
- 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.